Compare commits

...

6 Commits
main ... main

Author SHA1 Message Date
Paweł Skórzewski
12fe073db0 DataLoader link update 2024-12-04 10:28:50 +01:00
Paweł Skórzewski
d9f660474c Ulepszony wykład 7 o uczeniu nienadzorowanym 2024-04-25 12:11:06 +02:00
Paweł Skórzewski
7bf375944a Lab. 5 i wyk. 6 2024-04-18 09:44:59 +02:00
Paweł Skórzewski
a367ed7abf Uaktualnienie lab. 5 2024-04-11 10:45:55 +02:00
Paweł Skórzewski
2af4ea2178 Wykład 5 2024-04-11 10:45:41 +02:00
Paweł Skórzewski
afd3d92f3f Wykład 3 2024-03-21 10:29:30 +01:00
7 changed files with 1260 additions and 1100 deletions

View File

@ -44,23 +44,16 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 15,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"[[332187.32537534]\n", "[279661.8663101 279261.14658016 522543.09697553 243798.45172733\n",
" [369587.77676738]\n", " 408919.21577439 272940.5507781 367515.38801642 592972.56867895\n",
" [488428.70420785]\n", " 418509.89826131 943578.7139463 ]\n"
" [300013.00301966]\n",
" [412118.79730411]\n",
" [283333.7605634 ]\n",
" [275209.84706017]\n",
" [361970.50784352]\n",
" [272402.36116539]\n",
" [328635.55642844]]\n"
] ]
} }
], ],
@ -84,7 +77,7 @@
"def preprocess(data):\n", "def preprocess(data):\n",
" \"\"\"Wstępne przetworzenie danych\"\"\"\n", " \"\"\"Wstępne przetworzenie danych\"\"\"\n",
" data = data.replace({\"parter\": 0, \"poddasze\": 0}, regex=True)\n", " data = data.replace({\"parter\": 0, \"poddasze\": 0}, regex=True)\n",
" data = data.applymap(np.nan_to_num) # Zamienia \"NaN\" na liczby\n", " data = data.map(np.nan_to_num) # Zamienia \"NaN\" na liczby\n",
" return data\n", " return data\n",
"\n", "\n",
"\n", "\n",
@ -101,7 +94,7 @@
"data_train, data_test = train_test_split(data, test_size=0.2)\n", "data_train, data_test = train_test_split(data, test_size=0.2)\n",
"\n", "\n",
"# Uczenie modelu\n", "# Uczenie modelu\n",
"y_train = pd.DataFrame(data_train[\"cena\"])\n", "y_train = pd.Series(data_train[\"cena\"])\n",
"x_train = pd.DataFrame(data_train[FEATURES])\n", "x_train = pd.DataFrame(data_train[FEATURES])\n",
"model = LinearRegression() # definicja modelu\n", "model = LinearRegression() # definicja modelu\n",
"model.fit(x_train, y_train) # dopasowanie modelu\n", "model.fit(x_train, y_train) # dopasowanie modelu\n",
@ -154,14 +147,14 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 16,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"Błąd średniokwadratowy wynosi 1179760250402.185\n" "Błąd średniokwadratowy wynosi 137394744518.31197\n"
] ]
} }
], ],
@ -182,14 +175,14 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": 17,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"-10.712011261173265\n" "0.2160821272059249\n"
] ]
} }
], ],
@ -213,7 +206,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 19,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -225,14 +218,6 @@
"F-score: 1.0\n", "F-score: 1.0\n",
"Model score: 1.0\n" "Model score: 1.0\n"
] ]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/pawel/.local/lib/python3.10/site-packages/sklearn/utils/validation.py:1111: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().\n",
" y = column_or_1d(y, warn=True)\n"
]
} }
], ],
"source": [ "source": [
@ -254,7 +239,7 @@
"data_train, data_test = train_test_split(data_iris, test_size=0.2)\n", "data_train, data_test = train_test_split(data_iris, test_size=0.2)\n",
"\n", "\n",
"# Uczenie modelu\n", "# Uczenie modelu\n",
"y_train = pd.DataFrame(data_train[\"Iris setosa?\"])\n", "y_train = pd.Series(data_train[\"Iris setosa?\"])\n",
"x_train = pd.DataFrame(data_train[FEATURES])\n", "x_train = pd.DataFrame(data_train[FEATURES])\n",
"model = LogisticRegression() # definicja modelu\n", "model = LogisticRegression() # definicja modelu\n",
"model.fit(x_train, y_train) # dopasowanie modelu\n", "model.fit(x_train, y_train) # dopasowanie modelu\n",

View File

@ -714,7 +714,7 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"Tutaj artykuł o tym, jak stworzyć dataloader dla danych z własnego pliku CSV: https://androidkt.com/load-pandas-dataframe-using-dataset-and-dataloader-in-pytorch" "Proces wczytywania danych i przetwarzania ich przez sieć ułatwiają klasy `Dataset` i `DataLoader`: https://pytorch.org/tutorials/beginner/basics/data_tutorial.html"
] ]
} }
], ],
@ -735,7 +735,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.10.12" "version": "3.12.3"
}, },
"livereveal": { "livereveal": {
"start_slideshow_at": "selected", "start_slideshow_at": "selected",

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long