This commit is contained in:
shoney 2023-06-21 11:13:32 +00:00
parent 861fe965c0
commit 80306a2b67

View file

@ -2,9 +2,64 @@
"cells": [ "cells": [
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 3,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Collecting seaborn\n",
" Using cached seaborn-0.12.2-py3-none-any.whl (293 kB)\n",
"Collecting pandas>=0.25\n",
" Using cached pandas-2.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.3 MB)\n",
"Collecting numpy!=1.24.0,>=1.17\n",
" Downloading numpy-1.25.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (17.6 MB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m17.6/17.6 MB\u001b[0m \u001b[31m1.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",
"\u001b[?25hCollecting matplotlib!=3.6.1,>=3.1\n",
" Using cached matplotlib-3.7.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.6 MB)\n",
"Collecting contourpy>=1.0.1\n",
" Using cached contourpy-1.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (300 kB)\n",
"Collecting cycler>=0.10\n",
" Using cached cycler-0.11.0-py3-none-any.whl (6.4 kB)\n",
"Collecting pillow>=6.2.0\n",
" Using cached Pillow-9.5.0-cp310-cp310-manylinux_2_28_x86_64.whl (3.4 MB)\n",
"Requirement already satisfied: python-dateutil>=2.7 in /home/shoney/dev/.venv/lib/python3.10/site-packages (from matplotlib!=3.6.1,>=3.1->seaborn) (2.8.2)\n",
"Collecting pyparsing>=2.3.1\n",
" Downloading pyparsing-3.1.0-py3-none-any.whl (102 kB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m102.6/102.6 kB\u001b[0m \u001b[31m829.5 kB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",
"\u001b[?25hCollecting kiwisolver>=1.0.1\n",
" Using cached kiwisolver-1.4.4-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (1.6 MB)\n",
"Collecting fonttools>=4.22.0\n",
" Using cached fonttools-4.40.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.2 MB)\n",
"Requirement already satisfied: packaging>=20.0 in /home/shoney/dev/.venv/lib/python3.10/site-packages (from matplotlib!=3.6.1,>=3.1->seaborn) (23.1)\n",
"Collecting pytz>=2020.1\n",
" Using cached pytz-2023.3-py2.py3-none-any.whl (502 kB)\n",
"Collecting tzdata>=2022.1\n",
" Using cached tzdata-2023.3-py2.py3-none-any.whl (341 kB)\n",
"Requirement already satisfied: six>=1.5 in /home/shoney/dev/.venv/lib/python3.10/site-packages (from python-dateutil>=2.7->matplotlib!=3.6.1,>=3.1->seaborn) (1.16.0)\n",
"Installing collected packages: pytz, tzdata, pyparsing, pillow, numpy, kiwisolver, fonttools, cycler, pandas, contourpy, matplotlib, seaborn\n",
"Successfully installed contourpy-1.1.0 cycler-0.11.0 fonttools-4.40.0 kiwisolver-1.4.4 matplotlib-3.7.1 numpy-1.25.0 pandas-2.0.2 pillow-9.5.0 pyparsing-3.1.0 pytz-2023.3 seaborn-0.12.2 tzdata-2023.3\n",
"\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.0.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m23.1.2\u001b[0m\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n",
"Collecting scikit-learn\n",
" Using cached scikit_learn-1.2.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.6 MB)\n",
"Requirement already satisfied: numpy>=1.17.3 in /home/shoney/dev/.venv/lib/python3.10/site-packages (from scikit-learn) (1.25.0)\n",
"Collecting scipy>=1.3.2\n",
" Using cached scipy-1.10.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (34.4 MB)\n",
"Collecting joblib>=1.1.1\n",
" Using cached joblib-1.2.0-py3-none-any.whl (297 kB)\n",
"Collecting threadpoolctl>=2.0.0\n",
" Using cached threadpoolctl-3.1.0-py3-none-any.whl (14 kB)\n",
"Installing collected packages: threadpoolctl, scipy, joblib, scikit-learn\n",
"Successfully installed joblib-1.2.0 scikit-learn-1.2.2 scipy-1.10.1 threadpoolctl-3.1.0\n",
"\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.0.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m23.1.2\u001b[0m\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n"
]
}
],
"source": [ "source": [
"!python -m pip install seaborn\n", "!python -m pip install seaborn\n",
"!python -m pip install scikit-learn" "!python -m pip install scikit-learn"
@ -12,16 +67,32 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 4,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Collecting elasticsearch<7.0.0,>=6.4.0\n",
" Using cached elasticsearch-6.8.2-py2.py3-none-any.whl (90 kB)\n",
"Collecting urllib3>=1.21.1\n",
" Using cached urllib3-2.0.3-py3-none-any.whl (123 kB)\n",
"Installing collected packages: urllib3, elasticsearch\n",
"Successfully installed elasticsearch-6.8.2 urllib3-2.0.3\n",
"\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.0.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m23.1.2\u001b[0m\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n"
]
}
],
"source": [ "source": [
"!python -m pip install \"elasticsearch>=6.4.0,<7.0.0\"" "!python -m pip install \"elasticsearch>=6.4.0,<7.0.0\""
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 5,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -34,16 +105,24 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 6,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Got 22329 Hits:\n"
]
}
],
"source": [ "source": [
"print(\"Got %d Hits:\" % resp['hits']['total'])" "print(\"Got %d Hits:\" % resp['hits']['total'])"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 7,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -58,7 +137,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 8,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -68,7 +147,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 18, "execution_count": 14,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -86,7 +165,7 @@
"Name: 0, dtype: object" "Name: 0, dtype: object"
] ]
}, },
"execution_count": 18, "execution_count": 14,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -97,7 +176,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 10,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -121,7 +200,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 11,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -132,7 +211,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 12,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -220,15 +299,6 @@
"# 'categorypath':catpath_de})" "# 'categorypath':catpath_de})"
] ]
}, },
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df_eng[0]"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
@ -249,9 +319,20 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 13,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"data": {
"text/plain": [
"(10, 9)"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"df_eng.shape" "df_eng.shape"
] ]
@ -341,72 +422,198 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 66, "execution_count": 32,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"from sklearn.feature_extraction.text import CountVectorizer\n", "from sklearn.feature_extraction.text import CountVectorizer\n",
"n_gram_vectorizer = CountVectorizer(ngram_range=(1, 1))\n", "n_gram_vectorizer = CountVectorizer(ngram_range=(1, 1))\n",
"transformed_vector_name = n_gram_vectorizer.fit_transform(df_eng['name'])\n", "n_gram_vectorizer.fit(df_eng['name'] + df_eng['category'] )\n",
"transformed_vector_sdesc = n_gram_vectorizer.fit_transform(df_eng['sdesc'])\n", "transformed_vector_name = n_gram_vectorizer.transform(df_eng['name'])\n",
"transformed_vector_category = n_gram_vectorizer.fit_transform(df_eng['category'])\n", "transformed_vector_sdesc = n_gram_vectorizer.transform(df_eng['sdesc'])\n",
"transformed_vector_category = n_gram_vectorizer.transform(df_eng['category'])\n",
"\n", "\n",
"# vocabulary\n" "# vocabulary\n"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 72, "execution_count": 33,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"<10x40 sparse matrix of type '<class 'numpy.int64'>'\n", "{'denso': 22,\n",
"\twith 54 stored elements in Compressed Sparse Row format>" " 'dtm82363': 23,\n",
" 'thermostat': 33,\n",
" 'coolantthermostat': 21,\n",
" 'zf': 45,\n",
" '1043': 7,\n",
" '010': 1,\n",
" '297': 11,\n",
" 'automatic': 17,\n",
" 'transmissionautomatic': 37,\n",
" 'transmission': 36,\n",
" '1060': 8,\n",
" '040': 4,\n",
" '003': 0,\n",
" 'vaico': 43,\n",
" 'v10': 39,\n",
" '0131': 2,\n",
" 'camshaftcamshaft': 19,\n",
" 'v26': 41,\n",
" '0302': 3,\n",
" 'track': 35,\n",
" 'control': 20,\n",
" 'armtrack': 16,\n",
" 'arm': 15,\n",
" 'v30': 42,\n",
" '1250': 9,\n",
" 'suspension': 31,\n",
" 'kitsuspension': 27,\n",
" 'kit': 26,\n",
" '0474': 5,\n",
" 'tensioner': 32,\n",
" 'pulley': 29,\n",
" 'timing': 34,\n",
" 'belttensioner': 18,\n",
" '2660': 10,\n",
" 'mounting': 28,\n",
" 'transmissionmounting': 38,\n",
" '4245': 12,\n",
" 'shock': 30,\n",
" 'absorbershock': 14,\n",
" 'absorber': 13,\n",
" 'v24': 40,\n",
" '0908': 6,\n",
" 'wheel': 44,\n",
" 'hubwheel': 25,\n",
" 'hub': 24}"
] ]
}, },
"execution_count": 72, "execution_count": 33,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
], ],
"source": [ "source": [
"transformed_vector_name" "n_gram_vectorizer.vocabulary_"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 68, "execution_count": 34,
"metadata": {},
"outputs": [],
"source": [
"n_gram_vectorizer.vocabulary_.get('automatic transmission')"
]
},
{
"cell_type": "code",
"execution_count": 69,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"dict_items([('thermostat', 14), ('coolant', 6), ('automatic', 2), ('transmission', 17), ('camshaft', 4), ('track', 16), ('control', 5), ('arm', 1), ('suspension', 12), ('kit', 8), ('tensioner', 13), ('pulley', 10), ('timing', 15), ('belt', 3), ('mounting', 9), ('shock', 11), ('absorber', 0), ('wheel', 18), ('hub', 7)])" "(10, 46)"
] ]
}, },
"execution_count": 69, "execution_count": 34,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
], ],
"source": [
"transformed_vector_name.shape"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
" 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
" 0, 0],\n",
" [0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,\n",
" 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,\n",
" 0, 1],\n",
" [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,\n",
" 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,\n",
" 0, 1],\n",
" [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
" 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1,\n",
" 0, 0],\n",
" [0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0,\n",
" 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1,\n",
" 0, 0],\n",
" [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
" 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,\n",
" 0, 0],\n",
" [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
" 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1,\n",
" 0, 0],\n",
" [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,\n",
" 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1,\n",
" 0, 0],\n",
" [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,\n",
" 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1,\n",
" 0, 0],\n",
" [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
" 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1,\n",
" 1, 0]])"
]
},
"execution_count": 35,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"transformed_vector_name.toarray()"
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"17"
]
},
"execution_count": 37,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"n_gram_vectorizer.vocabulary_.get('automatic')"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'vocabulary' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[18], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m vocabulary\u001b[39m.\u001b[39mitems()\n",
"\u001b[0;31mNameError\u001b[0m: name 'vocabulary' is not defined"
]
}
],
"source": [ "source": [
"vocabulary.items()" "vocabulary.items()"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 70, "execution_count": 19,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -420,7 +627,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 71, "execution_count": 20,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -429,7 +636,7 @@
"((8, 19), (8, 16))" "((8, 19), (8, 16))"
] ]
}, },
"execution_count": 71, "execution_count": 20,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -440,44 +647,61 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 23,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [] "source": [
"import torch\n",
"import torch.nn as nn\n",
"import torch.nn.functional as F\n",
"import numpy as np"
]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": 21,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"ename": "ModuleNotFoundError", "ename": "AttributeError",
"evalue": "No module named 'torch'", "evalue": "values not found",
"output_type": "error", "output_type": "error",
"traceback": [ "traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[4], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mtorch\u001b[39;00m\n\u001b[1;32m 2\u001b[0m \u001b[39m# import numpy as np\u001b[39;00m\n\u001b[1;32m 3\u001b[0m \u001b[39m# Xtrain_ = torch.from_numpy(X_train.values).float()\u001b[39;00m\n\u001b[1;32m 4\u001b[0m \u001b[39m# Xtest_ = torch.from_numpy(x_test.values).float()\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[39m# Ytest_ = torch.from_numpy(y_test.values).view(1,-1)[0]\u001b[39;00m\n\u001b[1;32m 8\u001b[0m \u001b[39m# Ytrain_.shape\u001b[39;00m\n", "Cell \u001b[0;32mIn[21], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mtorch\u001b[39;00m\n\u001b[1;32m 2\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mnumpy\u001b[39;00m \u001b[39mas\u001b[39;00m \u001b[39mnp\u001b[39;00m\n\u001b[0;32m----> 3\u001b[0m Xtrain_ \u001b[39m=\u001b[39m torch\u001b[39m.\u001b[39mfrom_numpy(X_train\u001b[39m.\u001b[39;49mvalues)\u001b[39m.\u001b[39mfloat()\n\u001b[1;32m 4\u001b[0m Xtest_ \u001b[39m=\u001b[39m torch\u001b[39m.\u001b[39mfrom_numpy(x_test\u001b[39m.\u001b[39mvalues)\u001b[39m.\u001b[39mfloat()\n\u001b[1;32m 5\u001b[0m Xtrain_\u001b[39m.\u001b[39mshape\n",
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'torch'" "File \u001b[0;32m~/dev/.venv/lib/python3.10/site-packages/scipy/sparse/_base.py:771\u001b[0m, in \u001b[0;36mspmatrix.__getattr__\u001b[0;34m(self, attr)\u001b[0m\n\u001b[1;32m 769\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mgetnnz()\n\u001b[1;32m 770\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[0;32m--> 771\u001b[0m \u001b[39mraise\u001b[39;00m \u001b[39mAttributeError\u001b[39;00m(attr \u001b[39m+\u001b[39m \u001b[39m\"\u001b[39m\u001b[39m not found\u001b[39m\u001b[39m\"\u001b[39m)\n",
"\u001b[0;31mAttributeError\u001b[0m: values not found"
] ]
} }
], ],
"source": [ "source": [
"import torch\n", "\n",
"# import numpy as np\n", "Xtrain_ = torch.from_numpy(X_train).float()\n",
"# Xtrain_ = torch.from_numpy(X_train.values).float()\n", "Xtest_ = torch.from_numpy(x_test).float()\n",
"# Xtest_ = torch.from_numpy(x_test.values).float()\n", "Xtrain_.shape\n",
"# Xtrain_.shape\n", "Ytrain_ = torch.from_numpy(Y_train).view(1,-1)[0]\n",
"# Ytrain_ = torch.from_numpy(Y_train.values).view(1,-1)[0]\n", "Ytest_ = torch.from_numpy(y_test).view(1,-1)[0]\n",
"# Ytest_ = torch.from_numpy(y_test.values).view(1,-1)[0]\n", "Ytrain_.shape"
"# Ytrain_.shape"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 22,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"ename": "NameError",
"evalue": "name 'nn' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[22], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[39mclass\u001b[39;00m \u001b[39mNet\u001b[39;00m(nn\u001b[39m.\u001b[39mModule):\n\u001b[1;32m 3\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39m__init__\u001b[39m(\u001b[39mself\u001b[39m):\n\u001b[1;32m 4\u001b[0m \u001b[39msuper\u001b[39m(Net, \u001b[39mself\u001b[39m)\u001b[39m.\u001b[39m\u001b[39m__init__\u001b[39m()\n",
"\u001b[0;31mNameError\u001b[0m: name 'nn' is not defined"
]
}
],
"source": [ "source": [
"class Net(nn.Module):\n", "class Net(nn.Module):\n",
" \n", " \n",