2021-06-10 19:18:36 +02:00
|
|
|
{
|
|
|
|
"cells": [
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 1,
|
2021-07-05 15:01:40 +02:00
|
|
|
"id": "e6f9c155",
|
2021-06-10 19:18:36 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"import pandas as pd\n",
|
|
|
|
"import numpy as np\n",
|
|
|
|
"import matplotlib.pyplot as plt"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 2,
|
2021-07-05 15:01:40 +02:00
|
|
|
"id": "f688c561",
|
2021-06-10 19:18:36 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"delim = ';'\n",
|
|
|
|
"\n",
|
|
|
|
"base_path = '/opt/iui-datarelease1-sose2021/'\n",
|
|
|
|
"\n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"Xpickle_file = '../X2.pickle'\n",
|
2021-06-10 19:18:36 +02:00
|
|
|
"\n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"ypickle_file = '../y2.pickle'"
|
2021-06-10 19:18:36 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 3,
|
2021-07-05 15:01:40 +02:00
|
|
|
"id": "24a30600",
|
2021-06-10 19:18:36 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"THRESH = 0.1\n",
|
|
|
|
"LEEWAY = 1\n",
|
|
|
|
"EPOCH = 20\n",
|
|
|
|
"\n",
|
|
|
|
"DENSE_COUNT = 2\n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"DENSE_NEURONS = 1000\n",
|
2021-06-10 19:18:36 +02:00
|
|
|
"\n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"DENSE2_COUNT = 2\n",
|
2021-06-10 19:18:36 +02:00
|
|
|
"DENSE2_NEURONS = 600\n",
|
|
|
|
"\n",
|
|
|
|
"AVG_FROM = 10"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 4,
|
2021-07-05 15:01:40 +02:00
|
|
|
"id": "767b5a06",
|
2021-06-10 19:18:36 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"def plot_pd(data):\n",
|
|
|
|
" fig, axs = plt.subplots(4, 3, figsize=(3*3, 3*4))\n",
|
|
|
|
" t = data['Millis']\n",
|
|
|
|
" axs[0][0].plot(t, data['Acc1 X'])\n",
|
|
|
|
" axs[0][1].plot(t, data['Acc1 Y'])\n",
|
|
|
|
" axs[0][2].plot(t, data['Acc1 Z'])\n",
|
|
|
|
" axs[1][0].plot(t, data['Acc2 X'])\n",
|
|
|
|
" axs[1][1].plot(t, data['Acc2 Y'])\n",
|
|
|
|
" axs[1][2].plot(t, data['Acc2 Z'])\n",
|
|
|
|
" axs[2][0].plot(t, data['Gyro X'])\n",
|
|
|
|
" axs[2][1].plot(t, data['Gyro Y'])\n",
|
|
|
|
" axs[2][2].plot(t, data['Gyro Z'])\n",
|
|
|
|
" axs[3][0].plot(t, data['Mag X'])\n",
|
|
|
|
" axs[3][1].plot(t, data['Mag Y'])\n",
|
|
|
|
" axs[3][2].plot(t, data['Mag Z'])\n",
|
|
|
|
"\n",
|
|
|
|
" for a in axs:\n",
|
|
|
|
" for b in a:\n",
|
|
|
|
" b.plot(t, data['Force'])\n"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 5,
|
2021-07-05 15:01:40 +02:00
|
|
|
"id": "f50de79f",
|
2021-06-10 19:18:36 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"def plot_data(data):\n",
|
|
|
|
" fig, axs = plt.subplots(4, 3, figsize=(3*3, 3*4))\n",
|
|
|
|
" axs[0][0].plot(data[1])\n",
|
|
|
|
" axs[0][1].plot(data[2])\n",
|
|
|
|
" axs[0][2].plot(data[3])\n",
|
|
|
|
" axs[1][0].plot(data[4])\n",
|
|
|
|
" axs[1][1].plot(data[5])\n",
|
|
|
|
" axs[1][2].plot(data[6])\n",
|
|
|
|
" axs[2][0].plot(data[7])\n",
|
|
|
|
" axs[2][1].plot(data[8])\n",
|
|
|
|
" axs[2][2].plot(data[9])\n",
|
|
|
|
" axs[3][0].plot(data[10])\n",
|
|
|
|
" axs[3][1].plot(data[11])\n",
|
|
|
|
" axs[3][2].plot(data[12])\n",
|
|
|
|
"\n",
|
|
|
|
" for a in axs:\n",
|
|
|
|
" for b in a:\n",
|
|
|
|
" b.plot(data[13])\n"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 6,
|
2021-07-05 15:01:40 +02:00
|
|
|
"id": "db8d52e9",
|
2021-06-10 19:18:36 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"import pickle\n",
|
|
|
|
"\n",
|
|
|
|
"def load_pickles():\n",
|
|
|
|
" _p = open(Xpickle_file, 'rb')\n",
|
|
|
|
" X = pickle.load(_p)\n",
|
|
|
|
" _p.close()\n",
|
|
|
|
" \n",
|
|
|
|
" _p = open(ypickle_file, 'rb')\n",
|
|
|
|
" y = pickle.load(_p)\n",
|
|
|
|
" _p.close()\n",
|
|
|
|
" \n",
|
|
|
|
" return (np.asarray(X, dtype=pd.DataFrame), np.asarray(y, dtype=str))"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 7,
|
2021-07-05 15:01:40 +02:00
|
|
|
"id": "dff0b4cc",
|
2021-06-10 19:18:36 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"import os\n",
|
|
|
|
"\n",
|
|
|
|
"def load_data():\n",
|
|
|
|
" if os.path.isfile(Xpickle_file) and os.path.isfile(ypickle_file):\n",
|
|
|
|
" return load_pickles()\n",
|
|
|
|
" data = []\n",
|
|
|
|
" label = []\n",
|
|
|
|
" for user in range(0, user_count):\n",
|
|
|
|
" user_path = base_path + str(user) + '/split_letters_csv/'\n",
|
|
|
|
" for file in os.listdir(user_path):\n",
|
|
|
|
" file_name = user_path + file\n",
|
|
|
|
" letter = ''.join(filter(lambda x: x.isalpha(), file))[0]\n",
|
|
|
|
" data.append(pd.read_csv(file_name, delim))\n",
|
|
|
|
" label.append(letter)\n",
|
|
|
|
" return (np.asarray(data, dtype=pd.DataFrame), np.asarray(label, dtype=str), np.asarray(file_name))"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 8,
|
2021-07-05 15:01:40 +02:00
|
|
|
"id": "acd83b6d",
|
2021-06-10 19:18:36 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"name": "stdout",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
2021-07-05 15:01:40 +02:00
|
|
|
"CPU times: user 5.38 s, sys: 398 ms, total: 5.78 s\n",
|
|
|
|
"Wall time: 5.78 s\n"
|
2021-06-10 19:18:36 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
2021-06-23 10:12:11 +02:00
|
|
|
"(26179,)"
|
2021-06-10 19:18:36 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
"execution_count": 8,
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "execute_result"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"%%time\n",
|
|
|
|
"X, y = load_data()\n",
|
|
|
|
"\n",
|
|
|
|
"X.shape"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 9,
|
2021-07-05 15:01:40 +02:00
|
|
|
"id": "6c69c01d",
|
2021-06-10 19:18:36 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"def shorten(npList, thresh):\n",
|
|
|
|
" temp = npList['Force']\n",
|
|
|
|
" thresh = temp.max()*thresh\n",
|
|
|
|
" leeway = LEEWAY\n",
|
|
|
|
" \n",
|
|
|
|
" temps_over_T = np.where(temp > thresh)[0]\n",
|
|
|
|
" return npList[max(temps_over_T[0]-leeway,0):min(len(npList)-1,temps_over_T[-1]+leeway)].to_numpy()"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 10,
|
2021-07-05 15:01:40 +02:00
|
|
|
"id": "9c4b1131",
|
2021-06-10 19:18:36 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"name": "stdout",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
2021-07-05 15:01:40 +02:00
|
|
|
"CPU times: user 6.94 s, sys: 72.8 ms, total: 7.01 s\n",
|
|
|
|
"Wall time: 6.98 s\n"
|
2021-06-10 19:18:36 +02:00
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"%%time\n",
|
|
|
|
"\n",
|
|
|
|
"XX = np.array(list(map(shorten, X, [THRESH for _ in range(len(X))])),dtype=object)"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 11,
|
2021-07-05 15:01:40 +02:00
|
|
|
"id": "e60bd183",
|
2021-06-10 19:18:36 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
2021-06-23 10:12:11 +02:00
|
|
|
"image/png": "iVBORw0KGg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PC5vde+2b7Wr33noJDhxscq7Wf0n5RXb+Q58/c8wZWEvv2QT2pjpAWbOTKK3Ara9AQc+VdZnyfa2P5A2EqZfCTOuhiETIjjTGKWxCkp2wJF1cOQLFRt3Jjc94lLVX3sCOBIgcaiK0aaNgsTMaM9e048xc2YyE53UamOmf1O6G164Unll8m+Ged9VRke4EALO/jlUHYT3fw0ZY2Da5eFbfzTZ/wn89+cqlyhtJAydCtnT1fkxdaQ6X46Y0ypnqKzOQ25aPPF2a/hLs1OGw4W/hznfhte/DS/fAMd/Ey56CGzOXq9eGzPdpeow13tf40LHp0yuPwyvAPZEGDlXHQhpI9VyAb+KIbqq4OAaWP0wfPKQis8ueADs8VH8Ev2IgB8OfQ6H1sDhtVC0BWoLm95PH61+U1cVVB0Cdy24a1Scti0ShygX9Ig5MPFCFUsfDO5jTZdo9PpxWC2kxtu1Z6Y/s+8jePmbqhLppmWQl9832xECLn4Eqg7Da9+GglVw2g9V4mqssv8T+NdlkJwDCx+DGd8Aa9cu9eV1bmbmpRJnt9LQVwnyWeNh8Qr48Hfqmlh9GL7xL3WD2gu0MdNVSnfBqvuQO9/hh1bJusAEHrXdwG03LoKcmU2Z8+1RWwRrHoHP/gpHvoSrnovtA6a3+DyweYlyO1bsVWNZE2HMGcotOWQy5J4ASUPb/rzfZySeNUBdMVQfgcoDyjtWtBU++SN8/AdIyVPu4xMWdVg6ePjwYW644QaKi4sRQnDLLbdwxx13UFFRwTe+8Q2AaUKIFcBVUspKIYQA/gxcCDQAN0opvwIQQiwCfm6s+jdSyueM8dnAs0A8sAy4Q0q
|
2021-06-10 19:18:36 +02:00
|
|
|
"text/plain": [
|
|
|
|
"<Figure size 648x864 with 12 Axes>"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"metadata": {
|
|
|
|
"needs_background": "light"
|
|
|
|
},
|
|
|
|
"output_type": "display_data"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data": {
|
2021-06-23 10:12:11 +02:00
|
|
|
"image/png": "i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eZpIrilNtbvf0CA1mfERcztPTELQ9FUiowHQsH/+/wBZhqfuhkdug7/thuZj89/XAqHojOxzsqmfPE0kiVGhc55bnRXHudZBm4GwLd6q6iYhMoTlNjRFznD9ijRqu0ep6hyG1hOAJALmOiXQUPARVR3DJEaGzDAysmRrgYbu4Ulx0io4jSRJjwOHgSJJklokSfqIr9fkrwjDrVbeszaT5OgwdhYn8+wnN/Pw/1tPckwo//tsOTseeIt/HG5gQqvnYE0v5a1DfGxbPmqV7WyGifykyLmdJ60nISEfwuMhUgPJy9zTaXRXQV8tFN8AvbXw0FXwxAfF3/2YS1VnJMuyMOqaVTYxsTo7nkmdgcoO53URBoPM/ovdbCvUzBDmu8ouY/nkxbPt0Hockoqg+HroOg8jgfF/pAQafkZV5zBLrZRNTJgc6RSdhmvIsnyHLMtpsiwHy7KcKcvyQ75ek79izXBLkiR2FCXzzCc288+PbCAjLpxvPnee7Q+8ybeeP09ydCjvWuPciKR8TRT1PaMYLIcItp0Sd4EmcrdC8xHQTc3vH1H5gni87gH4zCnY8TWofg1+twFe/JLffgFcqjqjxt4xeken5ghBTayeh3FXedsgvaNT7ChKdmttmqhQNi/R8OKZNuTWE5CxDvJ3iCfdycotIpRAw48wGGQudlrvODGRHhdOflKk4qeh4BMcGW5JksTWwiSe/PhlPPbRjeQkRlLTNcK92/IJDVI7dYz8pEjGtXo6TN1Vw50w1CqEoCZyt4B2bLqk4iqVL0LGWohJh9Ao2PFl+OxpWPMhOP5X+PUq2Pc
|
2021-06-10 19:18:36 +02:00
|
|
|
"text/plain": [
|
|
|
|
"<Figure size 648x864 with 12 Axes>"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"metadata": {
|
|
|
|
"needs_background": "light"
|
|
|
|
},
|
|
|
|
"output_type": "display_data"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"from sklearn.preprocessing import RobustScaler, MaxAbsScaler, MinMaxScaler, StandardScaler\n",
|
|
|
|
"scaler = StandardScaler()\n",
|
|
|
|
"data = XX[0]\n",
|
|
|
|
"plot_data(data.T)\n",
|
|
|
|
"\n",
|
|
|
|
"plot_data(scaler.fit_transform(data))"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 12,
|
2021-07-05 15:01:40 +02:00
|
|
|
"id": "6e98530f",
|
2021-06-10 19:18:36 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"XXX = np.array(list(map(scaler.fit_transform, XX)),dtype=object)"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 13,
|
2021-07-05 15:01:40 +02:00
|
|
|
"id": "9049dc4b",
|
2021-06-10 19:18:36 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
2021-06-23 10:12:11 +02:00
|
|
|
"count 26179.000000\n",
|
|
|
|
"mean 48.405172\n",
|
|
|
|
"std 30.709627\n",
|
2021-06-10 19:18:36 +02:00
|
|
|
"min 6.000000\n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"50% 44.000000\n",
|
|
|
|
"90% 72.000000\n",
|
|
|
|
"91% 74.000000\n",
|
|
|
|
"92% 76.000000\n",
|
|
|
|
"93% 79.000000\n",
|
|
|
|
"94% 82.000000\n",
|
|
|
|
"95% 87.000000\n",
|
|
|
|
"96% 91.000000\n",
|
|
|
|
"97% 98.000000\n",
|
|
|
|
"98% 109.000000\n",
|
|
|
|
"99% 137.000000\n",
|
|
|
|
"max 1718.000000\n",
|
2021-06-10 19:18:36 +02:00
|
|
|
"dtype: float64"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"execution_count": 13,
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "execute_result"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"data": {
|
2021-06-23 10:12:11 +02:00
|
|
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uPsS4B7gMTP7MpGTpre4u/dmcElt6ypque2JEppb21l063l8YLJ+8ROJRUw3H7n7UmBpp2X3d3i8EbgwvtGkv/rThj186Zm1DMvJ4Ok7z2fKSF26KBIr3VEqCcPdefy1Hfzn7zcyvSiPn9xUTEFuZtCxRJKKSl0SQqg9zAO/28iTK3Yy9/ST+N51Z5OVoWvRRd4vlboErqElxN0//zuvllYz/0OncO/cU3XpokgPqdQlUA0tIa5esJwtVQ1865NncMP544KOJJLUVOoSqNU79vH2nnq9QbRInMTrjlKRHmkNhQH0fqIicaJSl8CsrzzA/b9dz+DMgRTlZwUdRyQlqNQlEC9t3Mu1j64gzYzn7riAEYN16aJIPGhMXfrcote288DvNnL6yUP56c3FFA4ZFHQkkZShUpc+9Z1lpfzolTI+Mm0k37/+bLIz9CMoEk96RUmfWrxyJ5ecWsiPP3MOaboWXSTuNKYufaY97LSHnbHDslXoIr1EpS59orElxPwnS2hoCXH6yZoXXaS3aPhFel1Ta4hrH13Bpt11/McnzuCa4jHd/yER6RGVuvS6teW1bHinjgc/NZ1rz1Whi/QmDb9Irzt01+i44dkBJxFJfSp16VUb3jnAvb9+i5yMNMaPyAk6jkjKU6lLr1mzcx/X/ngFZvDcHbMZqZuMRHqdxtSl1/x27TuEHV6460IVukgf0ZG69JqWtjBZGWkqdJE+pFKXXvHE8h38ak05Z4weGnQUkX5Fwy8Sd999cTM/eHkLl542kh/MOzvoOCL9ikpd4u7nq3bxoSkFPHqj5ncR6WsafpG4ag87oXCYovwsFbpIAFTqEje
|
2021-06-10 19:18:36 +02:00
|
|
|
"text/plain": [
|
|
|
|
"<Figure size 432x288 with 1 Axes>"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"metadata": {
|
|
|
|
"needs_background": "light"
|
|
|
|
},
|
|
|
|
"output_type": "display_data"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
2021-06-23 10:12:11 +02:00
|
|
|
"X_len = np.asarray(list(map(len, XX)))\n",
|
2021-06-10 19:18:36 +02:00
|
|
|
"l = []\n",
|
|
|
|
"sq_xlen = pd.Series(X_len)\n",
|
|
|
|
"ptiles = [x*0.01 for x in range(100)]\n",
|
|
|
|
"for i in ptiles:\n",
|
|
|
|
" l.append(sq_xlen.quantile(i))\n",
|
|
|
|
"plt.plot(l, ptiles)\n",
|
|
|
|
"sq_xlen.describe(percentiles=[x*0.01 for x in range(90,100)])"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 14,
|
2021-07-05 15:01:40 +02:00
|
|
|
"id": "8db3d74b",
|
2021-06-10 19:18:36 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
2021-06-23 10:12:11 +02:00
|
|
|
"((25918,), (53, 15))"
|
2021-06-10 19:18:36 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
"execution_count": 14,
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "execute_result"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"threshold_p = 0.99\n",
|
|
|
|
"len_mask = np.where(np.asarray(list(map(len, XX))) <= int(pd.Series(np.asarray(list(map(len, XXX)))).quantile(threshold_p)))\n",
|
|
|
|
"\n",
|
|
|
|
"X_filter = XX[len_mask]\n",
|
|
|
|
"y_filter = y[len_mask]\n",
|
|
|
|
"\n",
|
|
|
|
"X_filter.shape, X_filter[0].shape"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 15,
|
2021-07-05 15:01:40 +02:00
|
|
|
"id": "5c7afe06",
|
2021-06-10 19:18:36 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
2021-06-23 10:12:11 +02:00
|
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjMAAAKuCAYAAABUqp1fAAAAOXR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JT+JDtvtDMKDFYc849/gg2P0Z5z8reHNxTBszF0R4MAGvrDx6wTx8JdFd8E5N8GRn9MBXmUT4PmbtE81W4RDcN/F8PIvYPa58OWX4Msvwrc+hO/ths89BA1Hw7IfwN+/nr155DE7duzgtNNOY968ecyfP5/f/OY3ADQ3N3PWWWcBLBCRZSJSBSCaW0Rko4isEpFF9meJyOUissH6udwxfpSIrLa2uUUktwK0osqMqQBsyBSRCLz4Myhv0MrLQIjA2f8Oe1fD098f/r7XPqRfj/tK3LDdzmBQY6Z2Nkw7Cd65S38Pw6hijJlwEB76EmFx8xn/D9hfOie2rKBYqyHbXoWdK7Kzf6W0r3jLi3D+b+Gi22Hi4Y45lOgaC599UKclvnsPbFiWnbnkMR6Ph1/84hesW7eO5cuXc+utt7Ju3TpuvvlmzjjjDIA1wLPA9dYm5wKzrJ+rgN8DiEg1cANwLHAMcINtAFnrfMmx3ZKR+XaZIRxtNGku3IYMseavsPsdOP1fdT2XwZhznlZS3vof2Pzi0PerFKx5CBqOgcopcYt6raJ5KbXtWPwFaN0Om54b+lwMGcEYMy/9B+x+l79N/Ba7qKXP8XvYRYDApmczu9/eNu1SuvOj8Paf4MRrYdHn+19fBE77PtTMgqe+b54EMszEiRNZtEiLK2VlZcydO5ddu3bxyCOPcPnlUXHlLuAT1vulwN1KsxyoFJGJwDnAMqVUs1KqBVgGLLGWlSulliulFHC347NyAlNnxpBRgj3wzA+1S/3wz6S+3en/CtUz4NF/hkDX0Pb9+q2
|
2021-06-10 19:18:36 +02:00
|
|
|
"text/plain": [
|
|
|
|
"<Figure size 648x864 with 12 Axes>"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"metadata": {
|
|
|
|
"needs_background": "light"
|
|
|
|
},
|
|
|
|
"output_type": "display_data"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"from tensorflow.keras.preprocessing.sequence import pad_sequences\n",
|
|
|
|
"\n",
|
|
|
|
"X_filter = pad_sequences(X_filter, dtype=float, padding='post')\n",
|
|
|
|
"\n",
|
|
|
|
"plot_data(X_filter[0].T)"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 16,
|
2021-07-05 15:01:40 +02:00
|
|
|
"id": "d9f6b07e",
|
2021-06-10 19:18:36 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
2021-06-23 10:12:11 +02:00
|
|
|
"(25918, 137, 14)"
|
2021-06-10 19:18:36 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
"execution_count": 16,
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "execute_result"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"X_filter = np.array([np.delete(x, 0, 1) for x in X_filter])\n",
|
|
|
|
"X_filter.shape"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 17,
|
2021-07-05 15:01:40 +02:00
|
|
|
"id": "1218eb18",
|
2021-06-10 19:18:36 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"name": "stdout",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
2021-06-23 10:12:11 +02:00
|
|
|
"(20734, 137, 14)\n",
|
|
|
|
"(5184, 137, 14)\n",
|
|
|
|
"(20734, 52)\n",
|
|
|
|
"(5184, 52)\n"
|
2021-06-10 19:18:36 +02:00
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"from sklearn.model_selection import train_test_split\n",
|
|
|
|
"from sklearn.preprocessing import LabelEncoder, LabelBinarizer\n",
|
|
|
|
"import tensorflow as tf\n",
|
|
|
|
"\n",
|
|
|
|
"lb = LabelBinarizer()\n",
|
|
|
|
"\n",
|
|
|
|
"yt_filter = lb.fit_transform(y_filter)\n",
|
|
|
|
"\n",
|
|
|
|
"X_train, X_test, y_train, y_test = train_test_split(X_filter, yt_filter, test_size=0.2, random_state=177013)\n",
|
|
|
|
"\n",
|
|
|
|
"print(X_train.shape)\n",
|
|
|
|
"print(X_test.shape)\n",
|
|
|
|
"print(y_train.shape)\n",
|
|
|
|
"print(y_test.shape)"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 18,
|
2021-07-05 15:01:40 +02:00
|
|
|
"id": "d0aae270",
|
2021-06-10 19:18:36 +02:00
|
|
|
"metadata": {},
|
2021-06-23 10:12:11 +02:00
|
|
|
"outputs": [],
|
2021-06-10 19:18:36 +02:00
|
|
|
"source": [
|
2021-06-23 10:12:11 +02:00
|
|
|
"# import os\n",
|
2021-06-10 19:18:36 +02:00
|
|
|
"\n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"# # By users on card, could do by memory, but too lazy\n",
|
|
|
|
"# def get_least_used_gpu():\n",
|
|
|
|
"# a = [x.split('|') for x in os.popen('gpustat').read().split('\\n')[1:-1]]\n",
|
|
|
|
"# lu = min([x[-1].split() for x in a], key=len)\n",
|
|
|
|
"# lui = [i for i in range(len(a)) if a[i][3] == ''.join(lu)][0]\n",
|
|
|
|
"# print(f'Using {a[lui][0]}')\n",
|
|
|
|
"# return lui\n",
|
2021-06-10 19:18:36 +02:00
|
|
|
" \n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"# lu_gpu = get_least_used_gpu()"
|
2021-06-10 19:18:36 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 19,
|
2021-07-05 15:01:40 +02:00
|
|
|
"id": "e202c8cf",
|
2021-06-10 19:18:36 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"# FIRST CELL: set these variables to limit GPU usage.\n",
|
|
|
|
"os.environ['TF_FORCE_GPU_ALLOW_GROWTH'] = 'true' # this is required\n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"os.environ['CUDA_VISIBLE_DEVICES'] = '2' # set to '0' for GPU0, '1' for GPU1 or '2' for GPU2. Check \"gpustat\" in a terminal."
|
2021-06-10 19:18:36 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 20,
|
2021-07-05 15:01:40 +02:00
|
|
|
"id": "7b09f8fe",
|
2021-06-10 19:18:36 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"accs = []"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2021-07-05 15:01:40 +02:00
|
|
|
"execution_count": 21,
|
|
|
|
"id": "09a037ed",
|
2021-06-10 19:18:36 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"import tensorflow as tf\n",
|
|
|
|
"from tensorflow.keras.models import Sequential\n",
|
|
|
|
"from tensorflow.keras.layers import Dense, Flatten, BatchNormalization, Dropout\n",
|
|
|
|
"from tqdm import tqdm\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"def build_model():\n",
|
|
|
|
" model = Sequential()\n",
|
|
|
|
" \n",
|
2021-06-23 10:12:11 +02:00
|
|
|
" model.add(BatchNormalization(input_shape=X_filter[0].shape))\n",
|
|
|
|
" model.add(Dropout(0.2))\n",
|
|
|
|
" \n",
|
|
|
|
" \n",
|
|
|
|
" model.add(Flatten( ))\n",
|
2021-06-10 19:18:36 +02:00
|
|
|
"\n",
|
|
|
|
" for i in range(DENSE_COUNT):\n",
|
|
|
|
" model.add(Dense(DENSE_NEURONS, activation='relu'))\n",
|
|
|
|
" \n",
|
|
|
|
" for i in range(DENSE2_COUNT):\n",
|
|
|
|
" model.add(Dense(DENSE2_NEURONS, activation='relu'))\n",
|
2021-06-23 10:12:11 +02:00
|
|
|
" model.add(Dropout(0.2))\n",
|
2021-06-10 19:18:36 +02:00
|
|
|
" \n",
|
2021-06-23 10:12:11 +02:00
|
|
|
" \n",
|
|
|
|
" model.add(Dense(52, activation='softmax'))\n",
|
2021-06-10 19:18:36 +02:00
|
|
|
"\n",
|
|
|
|
" model.compile(\n",
|
|
|
|
" optimizer=tf.keras.optimizers.Adam(0.001),\n",
|
|
|
|
" loss=\"categorical_crossentropy\", \n",
|
|
|
|
" metrics=[\"acc\"],\n",
|
|
|
|
" )\n",
|
|
|
|
"\n",
|
|
|
|
" return model\n",
|
|
|
|
"# model.summary()\n"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2021-07-05 15:01:40 +02:00
|
|
|
"execution_count": 22,
|
|
|
|
"id": "061a0bdb",
|
2021-06-10 19:18:36 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"name": "stderr",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
2021-06-23 10:12:11 +02:00
|
|
|
" 0%| | 0/1 [00:00<?, ?it/s]"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "stdout",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
|
|
|
"Epoch 1/20\n",
|
2021-07-05 15:01:40 +02:00
|
|
|
"81/81 [==============================] - 1s 6ms/step - loss: 3.1932 - acc: 0.1521 - val_loss: 2.4668 - val_acc: 0.3038\n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"Epoch 2/20\n",
|
2021-07-05 15:01:40 +02:00
|
|
|
"81/81 [==============================] - 0s 4ms/step - loss: 2.1157 - acc: 0.3769 - val_loss: 1.7419 - val_acc: 0.4670\n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"Epoch 3/20\n",
|
2021-07-05 15:01:40 +02:00
|
|
|
"81/81 [==============================] - 0s 4ms/step - loss: 1.6080 - acc: 0.4976 - val_loss: 1.4454 - val_acc: 0.5484\n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"Epoch 4/20\n",
|
2021-07-05 15:01:40 +02:00
|
|
|
"81/81 [==============================] - 0s 4ms/step - loss: 1.3078 - acc: 0.5800 - val_loss: 1.3221 - val_acc: 0.5799\n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"Epoch 5/20\n",
|
2021-07-05 15:01:40 +02:00
|
|
|
"81/81 [==============================] - 0s 4ms/step - loss: 1.1233 - acc: 0.6282 - val_loss: 1.2188 - val_acc: 0.6173\n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"Epoch 6/20\n",
|
2021-07-05 15:01:40 +02:00
|
|
|
"81/81 [==============================] - 0s 4ms/step - loss: 0.9627 - acc: 0.6661 - val_loss: 1.1781 - val_acc: 0.6296\n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"Epoch 7/20\n",
|
2021-07-05 15:01:40 +02:00
|
|
|
"81/81 [==============================] - 0s 4ms/step - loss: 0.8519 - acc: 0.7032 - val_loss: 1.1871 - val_acc: 0.6354\n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"Epoch 8/20\n",
|
2021-07-05 15:01:40 +02:00
|
|
|
"81/81 [==============================] - 0s 4ms/step - loss: 0.7557 - acc: 0.7320 - val_loss: 1.1691 - val_acc: 0.6433\n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"Epoch 9/20\n",
|
2021-07-05 15:01:40 +02:00
|
|
|
"81/81 [==============================] - 0s 4ms/step - loss: 0.6753 - acc: 0.7536 - val_loss: 1.1882 - val_acc: 0.6412\n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"Epoch 10/20\n",
|
2021-07-05 15:01:40 +02:00
|
|
|
"81/81 [==============================] - 0s 4ms/step - loss: 0.6153 - acc: 0.7766 - val_loss: 1.2020 - val_acc: 0.6508\n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"Epoch 11/20\n",
|
2021-07-05 15:01:40 +02:00
|
|
|
"81/81 [==============================] - 0s 4ms/step - loss: 0.5711 - acc: 0.7933 - val_loss: 1.2155 - val_acc: 0.6397\n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"Epoch 12/20\n",
|
2021-07-05 15:01:40 +02:00
|
|
|
"81/81 [==============================] - 0s 4ms/step - loss: 0.5196 - acc: 0.8081 - val_loss: 1.2665 - val_acc: 0.6512\n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"Epoch 13/20\n",
|
2021-07-05 15:01:40 +02:00
|
|
|
"81/81 [==============================] - 0s 4ms/step - loss: 0.4745 - acc: 0.8239 - val_loss: 1.2465 - val_acc: 0.6644\n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"Epoch 14/20\n",
|
2021-07-05 15:01:40 +02:00
|
|
|
"81/81 [==============================] - 0s 4ms/step - loss: 0.4222 - acc: 0.8450 - val_loss: 1.3260 - val_acc: 0.6568\n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"Epoch 15/20\n",
|
2021-07-05 15:01:40 +02:00
|
|
|
"81/81 [==============================] - 0s 4ms/step - loss: 0.4110 - acc: 0.8471 - val_loss: 1.3274 - val_acc: 0.6593\n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"Epoch 16/20\n",
|
2021-07-05 15:01:40 +02:00
|
|
|
"81/81 [==============================] - 0s 4ms/step - loss: 0.3950 - acc: 0.8558 - val_loss: 1.3014 - val_acc: 0.6707\n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"Epoch 17/20\n",
|
2021-07-05 15:01:40 +02:00
|
|
|
"81/81 [==============================] - 0s 4ms/step - loss: 0.3736 - acc: 0.8633 - val_loss: 1.3430 - val_acc: 0.6561\n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"Epoch 18/20\n",
|
2021-07-05 15:01:40 +02:00
|
|
|
"81/81 [==============================] - 0s 4ms/step - loss: 0.3454 - acc: 0.8739 - val_loss: 1.4568 - val_acc: 0.6433\n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"Epoch 19/20\n",
|
2021-07-05 15:01:40 +02:00
|
|
|
"81/81 [==============================] - 0s 4ms/step - loss: 0.3520 - acc: 0.8699 - val_loss: 1.4099 - val_acc: 0.6516\n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"Epoch 20/20\n",
|
2021-07-05 15:01:40 +02:00
|
|
|
"81/81 [==============================] - 0s 4ms/step - loss: 0.3378 - acc: 0.8832 - val_loss: 1.3834 - val_acc: 0.6609\n"
|
2021-06-23 10:12:11 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "stderr",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
2021-07-05 15:01:40 +02:00
|
|
|
"100%|██████████| 1/1 [00:08<00:00, 8.67s/it]"
|
2021-06-23 10:12:11 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "stdout",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
2021-07-05 15:01:40 +02:00
|
|
|
"test loss, test acc: [1.383405089378357, 0.6608796119689941]\n",
|
|
|
|
"Model: \"sequential\"\n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"_________________________________________________________________\n",
|
|
|
|
"Layer (type) Output Shape Param # \n",
|
|
|
|
"=================================================================\n",
|
2021-07-05 15:01:40 +02:00
|
|
|
"batch_normalization (BatchNo (None, 137, 14) 56 \n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"_________________________________________________________________\n",
|
2021-07-05 15:01:40 +02:00
|
|
|
"dropout (Dropout) (None, 137, 14) 0 \n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"_________________________________________________________________\n",
|
2021-07-05 15:01:40 +02:00
|
|
|
"flatten (Flatten) (None, 1918) 0 \n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"_________________________________________________________________\n",
|
2021-07-05 15:01:40 +02:00
|
|
|
"dense (Dense) (None, 1000) 1919000 \n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"_________________________________________________________________\n",
|
2021-07-05 15:01:40 +02:00
|
|
|
"dense_1 (Dense) (None, 1000) 1001000 \n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"_________________________________________________________________\n",
|
2021-07-05 15:01:40 +02:00
|
|
|
"dense_2 (Dense) (None, 600) 600600 \n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"_________________________________________________________________\n",
|
2021-07-05 15:01:40 +02:00
|
|
|
"dense_3 (Dense) (None, 600) 360600 \n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"_________________________________________________________________\n",
|
2021-07-05 15:01:40 +02:00
|
|
|
"dropout_1 (Dropout) (None, 600) 0 \n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"_________________________________________________________________\n",
|
2021-07-05 15:01:40 +02:00
|
|
|
"dense_4 (Dense) (None, 52) 31252 \n",
|
2021-06-23 10:12:11 +02:00
|
|
|
"=================================================================\n",
|
|
|
|
"Total params: 3,912,508\n",
|
|
|
|
"Trainable params: 3,912,480\n",
|
|
|
|
"Non-trainable params: 28\n",
|
|
|
|
"_________________________________________________________________\n"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "stderr",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
|
|
|
"\n"
|
2021-06-10 19:18:36 +02:00
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
2021-06-23 10:12:11 +02:00
|
|
|
"for i in tqdm(range(1)):\n",
|
2021-06-10 19:18:36 +02:00
|
|
|
" model = build_model()\n",
|
|
|
|
" \n",
|
|
|
|
" model.fit(X_train, y_train, \n",
|
|
|
|
" epochs=EPOCH,\n",
|
2021-06-23 10:12:11 +02:00
|
|
|
" batch_size=256,\n",
|
2021-06-10 19:18:36 +02:00
|
|
|
" shuffle=True,\n",
|
|
|
|
" validation_data=(X_test, y_test),\n",
|
2021-06-23 10:12:11 +02:00
|
|
|
" verbose=1,\n",
|
2021-06-10 19:18:36 +02:00
|
|
|
" )\n",
|
|
|
|
" # Evaluate the model on the test data using `evaluate`\n",
|
|
|
|
"# print(\"Evaluate on test data\")\n",
|
|
|
|
" results = model.evaluate(X_test, y_test, batch_size=128, verbose=0)\n",
|
2021-06-23 10:12:11 +02:00
|
|
|
" print(\"test loss, test acc:\", results)\n",
|
|
|
|
" accs.append((model,results[1]))\n",
|
|
|
|
" model.summary()"
|
2021-06-10 19:18:36 +02:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2021-07-05 15:01:40 +02:00
|
|
|
"execution_count": 23,
|
|
|
|
"id": "69673754",
|
2021-06-10 19:18:36 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
2021-07-05 15:01:40 +02:00
|
|
|
"0.6608796119689941"
|
2021-06-10 19:18:36 +02:00
|
|
|
]
|
|
|
|
},
|
2021-07-05 15:01:40 +02:00
|
|
|
"execution_count": 23,
|
2021-06-10 19:18:36 +02:00
|
|
|
"metadata": {},
|
|
|
|
"output_type": "execute_result"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"np.mean(np.delete(accs,0,1).astype('float64'))"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
2021-07-05 15:01:40 +02:00
|
|
|
"execution_count": 24,
|
|
|
|
"id": "389c41e3",
|
2021-06-10 19:18:36 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"exit()"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
2021-07-05 15:01:40 +02:00
|
|
|
"id": "478e3241",
|
2021-06-10 19:18:36 +02:00
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": []
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"metadata": {
|
|
|
|
"kernelspec": {
|
|
|
|
"display_name": "Python 3",
|
|
|
|
"language": "python",
|
|
|
|
"name": "python3"
|
|
|
|
},
|
|
|
|
"language_info": {
|
|
|
|
"codemirror_mode": {
|
|
|
|
"name": "ipython",
|
|
|
|
"version": 3
|
|
|
|
},
|
|
|
|
"file_extension": ".py",
|
|
|
|
"mimetype": "text/x-python",
|
|
|
|
"name": "python",
|
|
|
|
"nbconvert_exporter": "python",
|
|
|
|
"pygments_lexer": "ipython3",
|
|
|
|
"version": "3.8.5"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"nbformat": 4,
|
|
|
|
"nbformat_minor": 5
|
|
|
|
}
|