--- a
+++ b/Dependent Vs Independent.ipynb
@@ -0,0 +1,745 @@
+{
+ "cells": [
+  {
+   "cell_type": "code",
+   "execution_count": 2,
+   "metadata": {
+    "ExecuteTime": {
+     "end_time": "2019-07-21T03:28:20.614469Z",
+     "start_time": "2019-07-21T03:28:19.208340Z"
+    }
+   },
+   "outputs": [
+    {
+     "name": "stderr",
+     "output_type": "stream",
+     "text": [
+      "Using TensorFlow backend.\n"
+     ]
+    }
+   ],
+   "source": [
+    "#This code is for adaptive GPU usage\n",
+    "import keras.backend as K\n",
+    "cfg = K.tf.ConfigProto()\n",
+    "cfg.gpu_options.allow_growth = True\n",
+    "K.set_session(K.tf.Session(config=cfg))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 1,
+   "metadata": {
+    "ExecuteTime": {
+     "end_time": "2019-07-23T12:10:14.715612Z",
+     "start_time": "2019-07-23T12:10:14.196989Z"
+    }
+   },
+   "outputs": [],
+   "source": [
+    "import pandas as pd\n",
+    "import numpy as np\n",
+    "from sklearn.ensemble import ExtraTreesClassifier\n",
+    "from sklearn.metrics import classification_report\n",
+    "from sklearn.model_selection import train_test_split"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 2,
+   "metadata": {
+    "ExecuteTime": {
+     "end_time": "2019-07-23T13:09:10.760608Z",
+     "start_time": "2019-07-23T13:09:10.743179Z"
+    }
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "15"
+      ]
+     },
+     "execution_count": 2,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "subject=[2,3,4,5,6,7,8,9,10,11,13,14,15,16,17]\n",
+    "len(subject)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 3,
+   "metadata": {
+    "ExecuteTime": {
+     "end_time": "2019-07-23T12:10:50.414237Z",
+     "start_time": "2019-07-23T12:10:23.407112Z"
+    }
+   },
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "subject_2\n",
+      "subject_3\n"
+     ]
+    },
+    {
+     "ename": "KeyboardInterrupt",
+     "evalue": "",
+     "output_type": "error",
+     "traceback": [
+      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
+      "\u001b[0;31mKeyboardInterrupt\u001b[0m                         Traceback (most recent call last)",
+      "\u001b[0;32m<ipython-input-3-8c3302bbf9e7>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m      1\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[0;32min\u001b[0m \u001b[0msubject\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m     \u001b[0mglobals\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'subject_%s'\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mpd\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mread_csv\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Sub_\"\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0mstr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0;34m\".csv\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      3\u001b[0m     \u001b[0mglobals\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'subject_%s'\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mglobals\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'subject_%s'\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mglobals\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'subject_%s'\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'label'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m<=\u001b[0m \u001b[0;36m4\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      4\u001b[0m     \u001b[0msubject_2_train\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0msubject_2_test\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mtrain_test_split\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msubject_2\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtest_size\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m0.3\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      5\u001b[0m     \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'subject_'\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0mstr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
+      "\u001b[0;32m/opt/anaconda/lib/python3.6/site-packages/pandas/io/parsers.py\u001b[0m in \u001b[0;36mparser_f\u001b[0;34m(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, escapechar, comment, encoding, dialect, tupleize_cols, error_bad_lines, warn_bad_lines, skipfooter, doublequote, delim_whitespace, low_memory, memory_map, float_precision)\u001b[0m\n\u001b[1;32m    676\u001b[0m                     skip_blank_lines=skip_blank_lines)\n\u001b[1;32m    677\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 678\u001b[0;31m         \u001b[0;32mreturn\u001b[0m \u001b[0m_read\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfilepath_or_buffer\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkwds\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    679\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    680\u001b[0m     \u001b[0mparser_f\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__name__\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
+      "\u001b[0;32m/opt/anaconda/lib/python3.6/site-packages/pandas/io/parsers.py\u001b[0m in \u001b[0;36m_read\u001b[0;34m(filepath_or_buffer, kwds)\u001b[0m\n\u001b[1;32m    444\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    445\u001b[0m     \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 446\u001b[0;31m         \u001b[0mdata\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mparser\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mread\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnrows\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    447\u001b[0m     \u001b[0;32mfinally\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    448\u001b[0m         \u001b[0mparser\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mclose\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
+      "\u001b[0;32m/opt/anaconda/lib/python3.6/site-packages/pandas/io/parsers.py\u001b[0m in \u001b[0;36mread\u001b[0;34m(self, nrows)\u001b[0m\n\u001b[1;32m   1034\u001b[0m                 \u001b[0;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'skipfooter not supported for iteration'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1035\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1036\u001b[0;31m         \u001b[0mret\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mread\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnrows\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m   1037\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1038\u001b[0m         \u001b[0;31m# May alter columns / col_dict\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
+      "\u001b[0;32m/opt/anaconda/lib/python3.6/site-packages/pandas/io/parsers.py\u001b[0m in \u001b[0;36mread\u001b[0;34m(self, nrows)\u001b[0m\n\u001b[1;32m   1846\u001b[0m     \u001b[0;32mdef\u001b[0m \u001b[0mread\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnrows\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1847\u001b[0m         \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1848\u001b[0;31m             \u001b[0mdata\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_reader\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mread\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnrows\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m   1849\u001b[0m         \u001b[0;32mexcept\u001b[0m \u001b[0mStopIteration\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   1850\u001b[0m             \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_first_chunk\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
+      "\u001b[0;32mpandas/_libs/parsers.pyx\u001b[0m in \u001b[0;36mpandas._libs.parsers.TextReader.read\u001b[0;34m()\u001b[0m\n",
+      "\u001b[0;32mpandas/_libs/parsers.pyx\u001b[0m in \u001b[0;36mpandas._libs.parsers.TextReader._read_low_memory\u001b[0;34m()\u001b[0m\n",
+      "\u001b[0;32mpandas/_libs/parsers.pyx\u001b[0m in \u001b[0;36mpandas._libs.parsers._concatenate_chunks\u001b[0;34m()\u001b[0m\n",
+      "\u001b[0;32m/opt/anaconda/lib/python3.6/site-packages/pandas/core/dtypes/common.py\u001b[0m in \u001b[0;36mis_categorical_dtype\u001b[0;34m(arr_or_dtype)\u001b[0m\n\u001b[1;32m    511\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    512\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 513\u001b[0;31m \u001b[0;32mdef\u001b[0m \u001b[0mis_categorical_dtype\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0marr_or_dtype\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    514\u001b[0m     \"\"\"\n\u001b[1;32m    515\u001b[0m     \u001b[0mCheck\u001b[0m \u001b[0mwhether\u001b[0m \u001b[0man\u001b[0m \u001b[0marray\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0mlike\u001b[0m \u001b[0;32mor\u001b[0m \u001b[0mdtype\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0mof\u001b[0m \u001b[0mthe\u001b[0m \u001b[0mCategorical\u001b[0m \u001b[0mdtype\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
+      "\u001b[0;31mKeyboardInterrupt\u001b[0m: "
+     ]
+    }
+   ],
+   "source": [
+    "for i in subject:\n",
+    "    globals()['subject_%s' % i] = pd.read_csv(\"Sub_\"+str(i)+\".csv\")\n",
+    "    globals()['subject_%s' % i]=globals()['subject_%s' % i][globals()['subject_%s' % i]['label'] <= 4]\n",
+    "    #subject_2_train,subject_2_test=train_test_split(subject_2, test_size=0.3)\n",
+    "    print('subject_'+str(i))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "%%time\n",
+    "df = pd.read_csv(\"master_data.csv\")\n"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "df=df[df['target']!=0]\n",
+    "df"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 4,
+   "metadata": {
+    "ExecuteTime": {
+     "end_time": "2019-07-21T03:48:13.626469Z",
+     "start_time": "2019-07-21T03:48:11.630785Z"
+    }
+   },
+   "outputs": [],
+   "source": [
+    "train=pd.concat([subject_2,subject_3,subject_4,subject_5,subject_6,subject_7,subject_8,subject_9,subject_10,subject_11])"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 5,
+   "metadata": {
+    "ExecuteTime": {
+     "end_time": "2019-07-21T03:48:14.534888Z",
+     "start_time": "2019-07-21T03:48:13.628414Z"
+    }
+   },
+   "outputs": [],
+   "source": [
+    "test=pd.concat([subject_13,subject_14,subject_15,subject_16,subject_17])"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 6,
+   "metadata": {
+    "ExecuteTime": {
+     "end_time": "2019-07-21T03:48:14.544552Z",
+     "start_time": "2019-07-21T03:48:14.536781Z"
+    }
+   },
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "Index      321148792\n",
+      "subject    321148792\n",
+      "ACC_x      321148792\n",
+      "ACC_y      321148792\n",
+      "ACC_z      321148792\n",
+      "ECG        321148792\n",
+      "EMG        321148792\n",
+      "EDA        321148792\n",
+      "Temp       321148792\n",
+      "Resp       321148792\n",
+      "label      321148792\n",
+      "dtype: int64\n",
+      "Index      151855208\n",
+      "subject    151855208\n",
+      "ACC_x      151855208\n",
+      "ACC_y      151855208\n",
+      "ACC_z      151855208\n",
+      "ECG        151855208\n",
+      "EMG        151855208\n",
+      "EDA        151855208\n",
+      "Temp       151855208\n",
+      "Resp       151855208\n",
+      "label      151855208\n",
+      "dtype: int64\n"
+     ]
+    }
+   ],
+   "source": [
+    "print(train.memory_usage(index=True, deep=False))\n",
+    "print(test.memory_usage(index=True, deep=False))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 7,
+   "metadata": {
+    "ExecuteTime": {
+     "end_time": "2019-07-21T03:48:15.689593Z",
+     "start_time": "2019-07-21T03:48:14.546129Z"
+    }
+   },
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "<class 'pandas.core.frame.DataFrame'>\n",
+      "Int64Index: 40143599 entries, 0 to 3663099\n",
+      "Data columns (total 10 columns):\n",
+      "subject    int64\n",
+      "ACC_x      float64\n",
+      "ACC_y      float64\n",
+      "ACC_z      float64\n",
+      "ECG        float64\n",
+      "EMG        float64\n",
+      "EDA        float64\n",
+      "Temp       float64\n",
+      "Resp       float64\n",
+      "label      int64\n",
+      "dtypes: float64(8), int64(2)\n",
+      "memory usage: 3.3 GB\n",
+      "None\n",
+      "<class 'pandas.core.frame.DataFrame'>\n",
+      "Int64Index: 18981901 entries, 0 to 4143999\n",
+      "Data columns (total 10 columns):\n",
+      "subject    int64\n",
+      "ACC_x      float64\n",
+      "ACC_y      float64\n",
+      "ACC_z      float64\n",
+      "ECG        float64\n",
+      "EMG        float64\n",
+      "EDA        float64\n",
+      "Temp       float64\n",
+      "Resp       float64\n",
+      "label      int64\n",
+      "dtypes: float64(8), int64(2)\n",
+      "memory usage: 1.6 GB\n",
+      "None\n"
+     ]
+    }
+   ],
+   "source": [
+    "print(train.info(memory_usage='deep'))\n",
+    "print(test.info(memory_usage='deep'))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 2,
+   "metadata": {
+    "ExecuteTime": {
+     "end_time": "2019-07-23T13:09:21.798204Z",
+     "start_time": "2019-07-23T13:09:21.793394Z"
+    }
+   },
+   "outputs": [],
+   "source": [
+    "features=['subject','ACC_x','ACC_y','ACC_z','ECG','EMG','EDA','Temp','Resp']\n",
+    "target=['label']"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 12,
+   "metadata": {
+    "ExecuteTime": {
+     "end_time": "2019-07-21T03:57:26.901617Z",
+     "start_time": "2019-07-21T03:50:57.031138Z"
+    }
+   },
+   "outputs": [
+    {
+     "name": "stderr",
+     "output_type": "stream",
+     "text": [
+      "/opt/anaconda/lib/python3.6/site-packages/ipykernel_launcher.py:2: 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",
+      "  \n"
+     ]
+    },
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "building tree 1 of 50\n",
+      "building tree 2 of 50\n",
+      "building tree 3 of 50\n",
+      "building tree 4 of 50\n",
+      "building tree 5 of 50\n",
+      "building tree 6 of 50\n",
+      "building tree 7 of 50\n",
+      "building tree 8 of 50\n",
+      "building tree 9 of 50\n",
+      "building tree 10 of 50\n",
+      "building tree 11 of 50\n",
+      "building tree 12 of 50\n",
+      "building tree 13 of 50\n",
+      "building tree 14 of 50\n",
+      "building tree 15 of 50\n",
+      "building tree 16 of 50\n",
+      "building tree 17 of 50\n",
+      "building tree 18 of 50\n",
+      "building tree 19 of 50\n",
+      "building tree 20 of 50\n",
+      "building tree 21 of 50\n",
+      "building tree 22 of 50\n",
+      "building tree 23 of 50\n",
+      "building tree 24 of 50\n",
+      "building tree 25 of 50\n",
+      "building tree 26 of 50\n",
+      "building tree 27 of 50\n",
+      "building tree 28 of 50\n",
+      "building tree 29 of 50\n",
+      "building tree 30 of 50\n",
+      "building tree 31 of 50\n"
+     ]
+    },
+    {
+     "name": "stderr",
+     "output_type": "stream",
+     "text": [
+      "[Parallel(n_jobs=10)]: Done  21 tasks      | elapsed:  3.0min\n"
+     ]
+    },
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "building tree 32 of 50\n",
+      "building tree 33 of 50\n",
+      "building tree 34 of 50\n",
+      "building tree 35 of 50\n",
+      "building tree 36 of 50\n",
+      "building tree 37 of 50building tree 38 of 50\n",
+      "\n",
+      "building tree 39 of 50\n",
+      "building tree 40 of 50\n",
+      "building tree 41 of 50\n",
+      "building tree 42 of 50\n",
+      "building tree 43 of 50\n",
+      "building tree 44 of 50\n",
+      "building tree 45 of 50\n",
+      "building tree 46 of 50\n",
+      "building tree 47 of 50\n",
+      "building tree 48 of 50\n",
+      "building tree 49 of 50\n",
+      "building tree 50 of 50\n"
+     ]
+    },
+    {
+     "name": "stderr",
+     "output_type": "stream",
+     "text": [
+      "[Parallel(n_jobs=10)]: Done  50 out of  50 | elapsed:  5.9min finished\n",
+      "[Parallel(n_jobs=10)]: Done  21 tasks      | elapsed:   12.6s\n",
+      "[Parallel(n_jobs=10)]: Done  50 out of  50 | elapsed:   24.5s finished\n"
+     ]
+    }
+   ],
+   "source": [
+    "et = ExtraTreesClassifier(n_estimators=50, n_jobs=10, verbose=2)\n",
+    "et.fit(train[features],train[target])\n",
+    "y_pred=et.predict(test[features])"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 15,
+   "metadata": {
+    "ExecuteTime": {
+     "end_time": "2019-07-21T03:57:45.807406Z",
+     "start_time": "2019-07-21T03:57:40.672071Z"
+    }
+   },
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "             precision    recall  f1-score   support\n",
+      "\n",
+      "          0       0.43      0.75      0.55   8419601\n",
+      "          1       0.04      0.04      0.04   4127201\n",
+      "          2       0.15      0.01      0.03   2394701\n",
+      "          3       0.00      0.00      0.00   1306201\n",
+      "          4       0.00      0.00      0.00   2734197\n",
+      "\n",
+      "avg / total       0.22      0.34      0.25  18981901\n",
+      "\n"
+     ]
+    },
+    {
+     "name": "stderr",
+     "output_type": "stream",
+     "text": [
+      "/opt/anaconda/lib/python3.6/site-packages/sklearn/metrics/classification.py:1135: UndefinedMetricWarning: Precision and F-score are ill-defined and being set to 0.0 in labels with no predicted samples.\n",
+      "  'precision', 'predicted', average, warn_for)\n"
+     ]
+    }
+   ],
+   "source": [
+    "print(classification_report(test[target],y_pred ))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 16,
+   "metadata": {
+    "ExecuteTime": {
+     "end_time": "2019-07-21T03:57:54.022571Z",
+     "start_time": "2019-07-21T03:57:53.711601Z"
+    }
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "array([0.08156137, 0.10834554, 0.12135855, 0.19428681, 0.0057354 ,\n",
+       "       0.00575368, 0.24000214, 0.21983822, 0.02311827])"
+      ]
+     },
+     "execution_count": 16,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "et.feature_importances_"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 3,
+   "metadata": {
+    "ExecuteTime": {
+     "end_time": "2019-07-23T13:09:31.720954Z",
+     "start_time": "2019-07-23T13:09:31.713668Z"
+    }
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "['subject', 'ACC_x', 'ACC_y', 'ACC_z', 'ECG', 'EMG', 'EDA', 'Temp', 'Resp']"
+      ]
+     },
+     "execution_count": 3,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "features"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# 70-30 all subject"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 21,
+   "metadata": {
+    "ExecuteTime": {
+     "end_time": "2019-07-21T04:03:43.043681Z",
+     "start_time": "2019-07-21T04:01:34.361732Z"
+    }
+   },
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "subject_2\n",
+      "subject_3\n",
+      "subject_4\n",
+      "subject_5\n",
+      "subject_6\n",
+      "subject_7\n",
+      "subject_8\n",
+      "subject_9\n",
+      "subject_10\n",
+      "subject_11\n",
+      "subject_13\n",
+      "subject_14\n",
+      "subject_15\n",
+      "subject_16\n",
+      "subject_17\n"
+     ]
+    }
+   ],
+   "source": [
+    "for i in subject:\n",
+    "    globals()['subject_%s' % i] = pd.read_csv(\"Sub_\"+str(i)+\".csv\")\n",
+    "    globals()['subject_%s' % i]=globals()['subject_%s' % i][globals()['subject_%s' % i]['label'] <= 4]\n",
+    "    globals()['subject_%s_train' % i],globals()['subject_%s_test' % i]=train_test_split(globals()['subject_%s' % i], test_size=0.3)\n",
+    "    print('subject_'+str(i))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 20,
+   "metadata": {
+    "ExecuteTime": {
+     "end_time": "2019-07-21T04:01:07.867253Z",
+     "start_time": "2019-07-21T04:01:07.861501Z"
+    }
+   },
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "ExtraTreesClassifier\t autopep8\t classification_report\t features\t i\t json\t np\t pd\t subject\t \n",
+      "subject_10\t subject_11\t subject_13\t subject_14\t subject_15\t subject_16\t subject_17\t subject_2\t subject_2_test\t \n",
+      "subject_2_train\t subject_3\t subject_4\t subject_5\t subject_6\t subject_7\t subject_8\t subject_9\t target\t \n",
+      "test\t train\t train_test_split\t y_pred\t \n"
+     ]
+    }
+   ],
+   "source": [
+    "who"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 22,
+   "metadata": {
+    "ExecuteTime": {
+     "end_time": "2019-07-21T04:03:53.417465Z",
+     "start_time": "2019-07-21T04:03:50.257592Z"
+    }
+   },
+   "outputs": [],
+   "source": [
+    "train=pd.concat([subject_2_train,subject_3_train,subject_4_train,subject_5_train,subject_6_train,subject_7_train,subject_8_train,subject_9_train,subject_10_train,subject_11_train,subject_13_train,subject_14_train,subject_15_train,subject_16_train,subject_17_train])\n",
+    "test=pd.concat([subject_2_test,subject_3_test,subject_4_test,subject_5_test,subject_6_test,subject_7_test,subject_8_test,subject_9_test,subject_10_test,subject_11_test,subject_13_test,subject_14_test,subject_15_test,subject_16_test,subject_17_test])"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 23,
+   "metadata": {
+    "ExecuteTime": {
+     "end_time": "2019-07-21T04:04:12.276243Z",
+     "start_time": "2019-07-21T04:04:12.271442Z"
+    }
+   },
+   "outputs": [],
+   "source": [
+    "features=['subject','ACC_x','ACC_y','ACC_z','ECG','EMG','EDA','Temp','Resp']\n",
+    "target=['label']"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": []
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {
+    "ExecuteTime": {
+     "start_time": "2019-07-21T04:04:25.485Z"
+    }
+   },
+   "outputs": [
+    {
+     "name": "stderr",
+     "output_type": "stream",
+     "text": [
+      "/opt/anaconda/lib/python3.6/site-packages/ipykernel_launcher.py:2: 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",
+      "  \n"
+     ]
+    },
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "building tree 1 of 50\n",
+      "building tree 2 of 50\n",
+      "building tree 3 of 50\n",
+      "building tree 4 of 50\n",
+      "building tree 5 of 50\n",
+      "building tree 6 of 50\n",
+      "building tree 7 of 50\n",
+      "building tree 8 of 50\n",
+      "building tree 9 of 50\n",
+      "building tree 10 of 50\n",
+      "building tree 11 of 50\n",
+      "building tree 12 of 50\n",
+      "building tree 13 of 50\n",
+      "building tree 14 of 50\n",
+      "building tree 15 of 50\n",
+      "building tree 16 of 50\n",
+      "building tree 17 of 50\n",
+      "building tree 18 of 50\n",
+      "building tree 19 of 50\n",
+      "building tree 20 of 50\n",
+      "building tree 21 of 50\n",
+      "building tree 22 of 50\n",
+      "building tree 23 of 50\n",
+      "building tree 24 of 50\n",
+      "building tree 25 of 50\n",
+      "building tree 26 of 50\n",
+      "building tree 27 of 50\n",
+      "building tree 28 of 50\n",
+      "building tree 29 of 50\n",
+      "building tree 30 of 50\n",
+      "building tree 31 of 50\n"
+     ]
+    },
+    {
+     "name": "stderr",
+     "output_type": "stream",
+     "text": [
+      "[Parallel(n_jobs=10)]: Done  21 tasks      | elapsed: 10.6min\n"
+     ]
+    },
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "building tree 32 of 50\n",
+      "building tree 33 of 50\n",
+      "building tree 34 of 50\n",
+      "building tree 35 of 50\n",
+      "building tree 36 of 50\n",
+      "building tree 37 of 50\n",
+      "building tree 38 of 50\n",
+      "building tree 39 of 50\n",
+      "building tree 40 of 50\n",
+      "building tree 41 of 50\n",
+      "building tree 42 of 50\n",
+      "building tree 43 of 50\n",
+      "building tree 44 of 50\n",
+      "building tree 45 of 50\n",
+      "building tree 46 of 50\n",
+      "building tree 47 of 50\n",
+      "building tree 48 of 50\n",
+      "building tree 49 of 50\n",
+      "building tree 50 of 50\n"
+     ]
+    },
+    {
+     "name": "stderr",
+     "output_type": "stream",
+     "text": [
+      "[Parallel(n_jobs=10)]: Done  50 out of  50 | elapsed: 18.3min finished\n",
+      "[Parallel(n_jobs=10)]: Done  21 tasks      | elapsed:   26.6s\n"
+     ]
+    }
+   ],
+   "source": [
+    "et = ExtraTreesClassifier(n_estimators=50, n_jobs=10, verbose=2)\n",
+    "et.fit(train[features],train[target])\n",
+    "y_pred=et.predict(test[features])"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 27,
+   "metadata": {
+    "ExecuteTime": {
+     "end_time": "2019-07-21T04:40:10.287166Z",
+     "start_time": "2019-07-21T04:40:03.793730Z"
+    }
+   },
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "             precision    recall  f1-score   support\n",
+      "\n",
+      "          0       1.00      0.99      1.00   8296151\n",
+      "          1       1.00      1.00      1.00   3699449\n",
+      "          2       1.00      1.00      1.00   2093592\n",
+      "          3       0.98      0.99      0.99   1169776\n",
+      "          4       0.99      1.00      0.99   2478684\n",
+      "\n",
+      "avg / total       1.00      1.00      1.00  17737652\n",
+      "\n"
+     ]
+    }
+   ],
+   "source": [
+    "print(classification_report(test[target],y_pred ))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "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.6.8"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}