diff --git a/1-first-project/jw/T_DataNormaization.ipynb b/1-first-project/jw/T_DataNormaization.ipynb new file mode 100644 index 0000000..adb2081 --- /dev/null +++ b/1-first-project/jw/T_DataNormaization.ipynb @@ -0,0 +1,421 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 2, + "id": "53f57e68", + "metadata": {}, + "outputs": [], + "source": [ + "import pandas as pd\n", + "import numpy as np\n", + "import os\n", + "import pickle\n" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "b240abfb", + "metadata": {}, + "outputs": [], + "source": [ + "delim = ';'\n", + "\n", + "user_count = 100\n", + "\n", + "base_path = '/opt/iui-datarelease1-sose2021/'\n", + "\n", + "Xpickle_file = './X.pickle'\n", + "\n", + "ypickle_file = './y.pickle'" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "f5464e9e", + "metadata": {}, + "outputs": [], + "source": [ + "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": 5, + "id": "3c51ef28", + "metadata": {}, + "outputs": [], + "source": [ + "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))" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "03ce941d", + "metadata": {}, + "outputs": [], + "source": [ + "X, y = load_data()" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "7ea0c433", + "metadata": {}, + "outputs": [], + "source": [ + "def save_pickle():\n", + "# _p = open(np.asarray(data, dtype=pd.DataFrame), 'wb')\n", + " _p = open(Xpickle_file, 'wb')\n", + " pickle.dump(X, _p)\n", + " _p.close()\n", + "\n", + "# _p = open(np.asarray(label, dtype=str), 'wb')\n", + " _p = open(ypickle_file, 'wb')\n", + " pickle.dump(y, _p)\n", + " _p.close()" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "210a3d37", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(13102, 13102)" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "len(X), len(y)" + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "id": "eadec7ee", + "metadata": {}, + "outputs": [], + "source": [ + "def plot_data(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": 11, + "id": "ade23f06", + "metadata": {}, + "outputs": [], + "source": [ + "# FIRST CELL: set these variables to limit GPU usage.\n", + "import os\n", + "os.environ['TF_FORCE_GPU_ALLOW_GROWTH'] = 'true' # this is required\n", + "os.environ['CUDA_VISIBLE_DEVICES'] = '2' # set to '0' for GPU0, '1' for GPU1 or '2' for GPU2. Check \"gpustat\" in a terminal." + ] + }, + { + "cell_type": "code", + "execution_count": 57, + "id": "d5db75fc", + "metadata": {}, + "outputs": [], + "source": [ + "from sklearn.model_selection import train_test_split\n", + "from sklearn.preprocessing import LabelEncoder\n", + "\n", + "le = LabelEncoder()\n", + "yyt_filtered = le.fit_transform(yy_filtered) # Lables in Zahlenwerte transformiert\n", + "XX_filtered = np.asarray(XX_filtered).astype('float64')\n", + "XXX_filtered = np.delete(np.delete(XX_filtered, 0, 2), 13,2) # Drops time col and Millis col" + ] + }, + { + "cell_type": "code", + "execution_count": 59, + "id": "290be797", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(10271, 456, 13)\n", + "(2568, 456, 13)\n", + "(10271,)\n", + "(2568,)\n" + ] + } + ], + "source": [ + "X_train, X_test, y_train, y_test = train_test_split(XXX_filtered, yyt_filtered, 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": 77, + "id": "cf763407", + "metadata": {}, + "outputs": [], + "source": [ + "import tensorflow as tf\n", + "from tensorflow.keras.models import Sequential\n", + "from tensorflow.keras.layers import Dense, Dropout, Activation, Flatten, Conv1D, MaxPooling1D\n", + "\n", + "model = Sequential()\n", + "\n", + "# model.add(Conv1D(32, 3, input_shape = X_train.shape[1:]))\n", + "# model.add(Activation('relu'))\n", + "# model.add(MaxPooling1D(pool_size=3))\n", + "\n", + "# model.add(Conv1D(32, 3))\n", + "# model.add(Activation('relu'))\n", + "# model.add(MaxPooling1D(pool_size=3))\n", + "\n", + "model.add(Flatten(input_shape = (456,13)))\n", + "model.add(Dense(456, activation = 'relu'))\n", + "\n", + "model.add(Dense(104))\n", + "\n", + "model.add(Dense(26))\n", + "model.add(Activation('sigmoid'))\n", + "\n", + "model.compile(\n", + " optimizer = tf.keras.optimizers.Adam(0.001),\n", + " loss = tf.keras.losses.SparseCategoricalCrossentropy(from_logits = True),\n", + " metrics = [tf.keras.metrics.SparseCategoricalAccuracy()],\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 78, + "id": "ed97582c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "array(['K', 'T', 'U', ..., 'F', 'H', 'G'], dtype='" + ] + }, + "execution_count": 80, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "model.fit(X_train, y_train, \n", + " epochs=10,\n", + " batch_size=32,\n", + " verbose=1\n", + " )" + ] + }, + { + "cell_type": "code", + "execution_count": 81, + "id": "8f8fedfd", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Evaluate on test data\n", + "81/81 [==============================] - 0s 1ms/step - loss: 11.4346 - sparse_categorical_accuracy: 0.0312\n", + "test loss, test acc: [11.434555053710938, 0.031152648851275444]\n", + "Generate predictions for 3 samples\n", + "predictions shape: (3, 26)\n" + ] + }, + { + "data": { + "text/plain": [ + "(array(['K', 'T', 'U'], dtype='= thresh:\n", + " data_above_thresh.append(values)\n", + " \n", + " return data_above_thresh" + ] + }, + { + "cell_type": "code", + "execution_count": 75, + "id": "d2bcca2e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[]" + ] + }, + "execution_count": 75, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAD4CAYAAAAAczaOAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Z1A+gAAAACXBIWXMAAAsTAAALEwEAmpwYAAApV0lEQVR4nO2de6xlV33fP7/zuI+587RnGA/2GNvJpNRIwbgjQ5oUkZACdqSaSBSZP8BCVK4aaBOpreokUqCJoqZRk0pIhIgICxNRwCUP3MgNOC4tTV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kas+6gyDEIIUSHKaO8IIYRYA4m+EEJUCIm+EEJUCIm+EEJUCIm+EEJUCIm+EEJUCIm+EEJUiP8Pfi+YagfylukAAAAASUVORK5CYII=\n", + "text/plain": [ + "
" + ] + }, + "metadata": { + "needs_background": "light" + }, + "output_type": "display_data" + } + ], + "source": [ + "input_data = X[5]['Force']\n", + "window_sz = 10\n", + "sum_windows_passed = 0\n", + " \n", + " \n", + "win_above_thresh = []\n", + "thresh = 70\n", + " \n", + " \n", + "for i in range(0, len(input_data), window_sz):\n", + " values_sum = 0\n", + " for j in range(i, min(i + window_sz, len(input_data))): # evtl i + win_sz -1 \n", + " values_sum += input_data[j]\n", + "\n", + " win_above_thresh.append(values_sum / window_sz)\n", + " \n", + "plt.plot(win_above_thresh)\n", + "plt.plot(X[5]['Force'])" + ] + }, + { + "cell_type": "code", + "execution_count": 76, + "id": "79e01286", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(array([14, 15, 16, 17, 19, 20, 21]),)\n" + ] + } + ], + "source": [ + "_blep = np.where(np.asarray(win_above_thresh) > thresh)\n", + "print(_blep)" + ] + }, + { + "cell_type": "code", + "execution_count": 82, + "id": "1503bb77", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "150\n" + ] + } + ], + "source": [ + "print(_blep[0][1]*10)" + ] + }, + { + "cell_type": "code", + "execution_count": 78, + "id": "eb6d91d5", + "metadata": {}, + "outputs": [], + "source": [ + "X_new = X[_blep]" + ] + }, + { + "cell_type": "code", + "execution_count": 79, + "id": "6cea3dbc", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(13102,)\n", + "(7,)\n" + ] + } + ], + "source": [ + "print(X.shape)\n", + "print(X_new.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": 80, + "id": "35f783ed", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0 0.0\n", + "1 0.0\n", + "2 0.0\n", + "3 0.0\n", + "4 0.0\n", + " ... \n", + "307 0.0\n", + "308 0.0\n", + "309 0.0\n", + "310 0.0\n", + "311 0.0\n", + "Name: Force, Length: 312, dtype: float64\n" + ] + } + ], + "source": [ + "print(X[5]['Force'])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a3a05a73", + "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 +} diff --git a/1-first-project/jw/untitled.txt b/1-first-project/jw/untitled.txt deleted file mode 100644 index e69de29..0000000 diff --git a/1-first-project/jw/y.pickle b/1-first-project/jw/y.pickle new file mode 100644 index 0000000..455f102 Binary files /dev/null and b/1-first-project/jw/y.pickle differ