Commit 69a9f663 authored by Danniene Wete's avatar Danniene Wete

implement SW creation by considering codewords in each time window as individual SW.

parent 261b73e4
......@@ -2,11 +2,12 @@
"cells": [
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"import itertools\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"from sklearn.ensemble import RandomForestRegressor, RandomForestClassifier\n",
"from sklearn.metrics import classification_report, confusion_matrix, precision_recall_fscore_support\n",
......@@ -14,7 +15,7 @@
"\n",
"plt.style.use('bmh')\n",
"%matplotlib inline\n",
"%run CodebookApproach.ipynb\n",
"%run codebook.ipynb\n",
"\n",
"def select_rfc_params(X_train, y_train, folds):\n",
" \"\"\"Hyperparameter optimization\n",
......@@ -52,7 +53,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
......@@ -69,7 +70,7 @@
"outputs": [],
"source": [
"#codebook approach\n",
"X_train, X_test = codebook_approach(20, 10)\n",
"X_train, X_test = codebook_approach(30, 26)\n",
"#hyperparameter optimization\n",
"best_params = select_rfc_params(X_train, y_train, 10)"
]
......@@ -114,7 +115,8 @@
" if normalize:\n",
" plt.text(j, i, \"{:0.2f}\".format(conf_mat[i, j]), horizontalalignment=\"center\", color=\"black\")\n",
" else:\n",
" plt.text(j, i, \"{:}\".format(conf_mat[i, j]), horizontalalignment=\"center\", color=\"black\")"
" plt.text(j, i, \"{:}\".format(conf_mat[i, j]), horizontalalignment=\"center\", color=\"black\")\n",
"plt.savefig('cm_codebook+RFC.png')"
]
}
],
......
This diff is collapsed.
This diff is collapsed.
......@@ -173,7 +173,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.8"
"version": "3.7.4"
}
},
"nbformat": 4,
......
\begin{tabular}{lrr}
\begin{tabular}{lrrr}
\toprule
{} & Precision & Recall \\
{} & Precision & Recall & F1 score \\
\midrule
WALKING & 0.949 & 0.942 \\
WALKING\_UPSTAIRS & 0.960 & 0.975 \\
WALKING\_DOWNSTAIRS & 0.936 & 0.936 \\
SITTING & 0.798 & 0.807 \\
STANDING & 0.827 & 0.806 \\
LAYING & 0.991 & 1.000 \\
WALKING & 0.949 & 0.942 & 0.945 \\
WALKING\_UPSTAIRS & 0.960 & 0.975 & 0.967 \\
WALKING\_DOWNSTAIRS & 0.936 & 0.936 & 0.936 \\
SITTING & 0.798 & 0.807 & 0.802 \\
STANDING & 0.827 & 0.806 & 0.816 \\
LAYING & 0.991 & 1.000 & 0.995 \\
\bottomrule
\end{tabular}
\begin{tabular}{lrr}
\begin{tabular}{lrrr}
\toprule
{} & Precision & Recall \\
{} & Precision & Recall & F1 score \\
\midrule
WALKING & 0.997 & 0.941 \\
WALKING\_UPSTAIRS & 0.938 & 0.993 \\
WALKING\_DOWNSTAIRS & 0.987 & 0.993 \\
SITTING & 0.852 & 0.852 \\
STANDING & 0.897 & 0.860 \\
LAYING & 0.963 & 1.000 \\
WALKING & 0.997 & 0.941 & 0.968 \\
WALKING\_UPSTAIRS & 0.938 & 0.993 & 0.965 \\
WALKING\_DOWNSTAIRS & 0.987 & 0.993 & 0.990 \\
SITTING & 0.852 & 0.852 & 0.852 \\
STANDING & 0.897 & 0.860 & 0.878 \\
LAYING & 0.963 & 1.000 & 0.981 \\
\bottomrule
\end{tabular}
......@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
......@@ -23,7 +23,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
......@@ -32,7 +32,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
......@@ -46,7 +46,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 4,
"metadata": {},
"outputs": [
{
......@@ -55,7 +55,7 @@
"(7352, 36)"
]
},
"execution_count": 18,
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
......@@ -66,7 +66,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
......@@ -75,7 +75,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
......@@ -84,7 +84,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
......@@ -109,7 +109,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
......@@ -167,7 +167,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 9,
"metadata": {},
"outputs": [
{
......@@ -176,7 +176,7 @@
"array([0, 1, 2, 3, 4, 5])"
]
},
"execution_count": 23,
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
......@@ -195,7 +195,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 10,
"metadata": {},
"outputs": [
{
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment