Commit 3f987622 authored by Danniene Wete's avatar Danniene Wete

param tuning and random seed agg. approach 1

parent 9ccc444b
......@@ -232,7 +232,7 @@
" #2. Clustering\n",
" trainAcc_centroids = calc_centroids_array(trainAcc_window, n_cluster)\n",
" trainGyr_centroids = calc_centroids_array(trainGyr_window, n_cluster)\n",
" # Save centroids on disk for using later\n",
" Save centroids on disk for using later\n",
" with open('trainTestCorpus_m1/trainAcc.centroids', 'wb') as fp:\n",
" pickle.dump(trainAcc_centroids, fp)\n",
" with open('trainTestCorpus_m1/trainGyr.centroids', 'wb') as fp: \n",
......
......@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 4,
"metadata": {},
"outputs": [
{
......@@ -11,7 +11,7 @@
"(7352, 3, 128)"
]
},
"execution_count": 1,
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
......@@ -63,7 +63,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
......@@ -206,7 +206,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
......@@ -226,17 +226,17 @@
" trainAcc_window = sliding_window_approach(trainAcc,window_length,overlap_length)\n",
" trainGyr_window = sliding_window_approach(trainGyr,window_length,overlap_length) \n",
" \n",
" # testAcc_window = sliding_window_approach(testAcc,window_length,overlap_length)\n",
" #testGyr_window = sliding_window_approach(testGyr,window_length,overlap_length)\n",
" testAcc_window = sliding_window_approach(testAcc,window_length,overlap_length)\n",
" testGyr_window = sliding_window_approach(testGyr,window_length,overlap_length)\n",
" \n",
" #2. Clustering\n",
" trainAcc_centroids = calc_centroids_array(trainAcc_window, n_cluster)\n",
" trainGyr_centroids = calc_centroids_array(trainGyr_window, n_cluster)\n",
" # Save centroids on disk for using later\n",
" #with open('trainTestCorpus_m1/trainAcc.centroids', 'wb') as fp:\n",
" # pickle.dump(trainAcc_centroids, fp)\n",
" #with open('trainTestCorpus_m1/trainGyr.centroids', 'wb') as fp: \n",
" #pickle.dump(trainGyr_centroids, fp)\n",
" #Save centroids on disk for using later\n",
" with open('trainTestCorpus_m1/trainAcc.centroids', 'wb') as fp:\n",
" pickle.dump(trainAcc_centroids, fp)\n",
" with open('trainTestCorpus_m1/trainGyr.centroids', 'wb') as fp: \n",
" pickle.dump(trainGyr_centroids, fp)\n",
" \n",
" \n",
" \n",
......@@ -248,25 +248,25 @@
" \n",
" trainAcc_count = trainAcc.shape[0]\n",
" trainGyr_count = trainGyr.shape[0]\n",
" #testAcc_count = testAcc.shape[0]\n",
" #testGyr_count = testGyr.shape[0] \n",
" testAcc_count = testAcc.shape[0]\n",
" testGyr_count = testGyr.shape[0] \n",
" \n",
" \n",
" #4 Assign subsequences to cluster centre and replace subsequence with alphabet of cluster centre\n",
" trainAcc_charsSeq = mapCodewordsToChars(trainAcc_window, trainAcc_centroids,trainAcc_count)\n",
" trainGyr_charsSeq = mapCodewordsToChars(trainGyr_window, trainGyr_centroids,trainGyr_count) \n",
" #testAcc_charsSeq = mapCodewordsToChars(testAcc_window, trainAcc_centroids, testAcc_count)\n",
" #testGyr_charsSeq = mapCodewordsToChars(testGyr_window, trainGyr_centroids, testGyr_count)\n",
" testAcc_charsSeq = mapCodewordsToChars(testAcc_window, trainAcc_centroids, testAcc_count)\n",
" testGyr_charsSeq = mapCodewordsToChars(testGyr_window, trainGyr_centroids, testGyr_count)\n",
" \n",
" \n",
" \n",
" #5. Create train and test bag of words\n",
" trainBow = create_words(trainAcc_charsSeq, trainGyr_charsSeq)\n",
" #testBow = create_words(testAcc_charsSeq, testGyr_charsSeq) \n",
" testBow = create_words(testAcc_charsSeq, testGyr_charsSeq) \n",
" \n",
" \n",
" \n",
" return trainBow# testBow"
" return trainBow, testBow"
]
}
],
......
......@@ -141,9 +141,17 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"FINISH!\n"
]
}
],
"source": [
"for window_length in range(10, 40, 5):\n",
" for n_clusters in range(32, 65, 3): \n",
......@@ -175,9 +183,20 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"(7352, 36)"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"train_docs.shape"
]
......
......@@ -29,7 +29,7 @@ z
<g id="matplotlib.axis_1">
<g id="xtick_1">
<g id="line2d_1">
<path clip-path="url(#pe04f5b89f8)" d="M 53.414319 333.36
<path clip-path="url(#pbda5ae153d)" d="M 53.414319 333.36
L 53.414319 7.2
" style="fill:none;stroke:#ffffff;stroke-linecap:round;"/>
</g>
......@@ -115,7 +115,7 @@ z
</g>
<g id="xtick_2">
<g id="line2d_2">
<path clip-path="url(#pe04f5b89f8)" d="M 104.537953 333.36
<path clip-path="url(#pbda5ae153d)" d="M 104.537953 333.36
L 104.537953 7.2
" style="fill:none;stroke:#ffffff;stroke-linecap:round;"/>
</g>
......@@ -131,7 +131,7 @@ L 104.537953 7.2
</g>
<g id="xtick_3">
<g id="line2d_3">
<path clip-path="url(#pe04f5b89f8)" d="M 155.661586 333.36
<path clip-path="url(#pbda5ae153d)" d="M 155.661586 333.36
L 155.661586 7.2
" style="fill:none;stroke:#ffffff;stroke-linecap:round;"/>
</g>
......@@ -147,7 +147,7 @@ L 155.661586 7.2
</g>
<g id="xtick_4">
<g id="line2d_4">
<path clip-path="url(#pe04f5b89f8)" d="M 206.78522 333.36
<path clip-path="url(#pbda5ae153d)" d="M 206.78522 333.36
L 206.78522 7.2
" style="fill:none;stroke:#ffffff;stroke-linecap:round;"/>
</g>
......@@ -195,7 +195,7 @@ z
</g>
<g id="xtick_5">
<g id="line2d_5">
<path clip-path="url(#pe04f5b89f8)" d="M 257.908854 333.36
<path clip-path="url(#pbda5ae153d)" d="M 257.908854 333.36
L 257.908854 7.2
" style="fill:none;stroke:#ffffff;stroke-linecap:round;"/>
</g>
......@@ -211,7 +211,7 @@ L 257.908854 7.2
</g>
<g id="xtick_6">
<g id="line2d_6">
<path clip-path="url(#pe04f5b89f8)" d="M 309.032488 333.36
<path clip-path="url(#pbda5ae153d)" d="M 309.032488 333.36
L 309.032488 7.2
" style="fill:none;stroke:#ffffff;stroke-linecap:round;"/>
</g>
......@@ -238,7 +238,7 @@ z
</g>
<g id="xtick_7">
<g id="line2d_7">
<path clip-path="url(#pe04f5b89f8)" d="M 360.156122 333.36
<path clip-path="url(#pbda5ae153d)" d="M 360.156122 333.36
L 360.156122 7.2
" style="fill:none;stroke:#ffffff;stroke-linecap:round;"/>
</g>
......@@ -254,7 +254,7 @@ L 360.156122 7.2
</g>
<g id="xtick_8">
<g id="line2d_8">
<path clip-path="url(#pe04f5b89f8)" d="M 411.279756 333.36
<path clip-path="url(#pbda5ae153d)" d="M 411.279756 333.36
L 411.279756 7.2
" style="fill:none;stroke:#ffffff;stroke-linecap:round;"/>
</g>
......@@ -449,7 +449,7 @@ z
<g id="ytick_1"/>
</g>
<g id="patch_3">
<path clip-path="url(#pe04f5b89f8)" d="M 168.303421 39.816
<path clip-path="url(#pbda5ae153d)" d="M 168.303421 39.816
L 168.303421 300.744
L 258.492965 300.744
L 258.492965 39.816
......@@ -458,22 +458,22 @@ z
" style="fill:#5875a4;stroke:#4c4c4c;stroke-linejoin:miter;stroke-width:1.5;"/>
</g>
<g id="line2d_9">
<path clip-path="url(#pe04f5b89f8)" d="M 168.303421 170.28
<path clip-path="url(#pbda5ae153d)" d="M 168.303421 170.28
L 47.239429 170.28
" style="fill:none;stroke:#4c4c4c;stroke-linecap:round;stroke-width:1.5;"/>
</g>
<g id="line2d_10">
<path clip-path="url(#pe04f5b89f8)" d="M 258.492965 170.28
<path clip-path="url(#pbda5ae153d)" d="M 258.492965 170.28
L 392.42131 170.28
" style="fill:none;stroke:#4c4c4c;stroke-linecap:round;stroke-width:1.5;"/>
</g>
<g id="line2d_11">
<path clip-path="url(#pe04f5b89f8)" d="M 47.239429 105.048
<path clip-path="url(#pbda5ae153d)" d="M 47.239429 105.048
L 47.239429 235.512
" style="fill:none;stroke:#4c4c4c;stroke-linecap:round;stroke-width:1.5;"/>
</g>
<g id="line2d_12">
<path clip-path="url(#pe04f5b89f8)" d="M 392.42131 105.048
<path clip-path="url(#pbda5ae153d)" d="M 392.42131 105.048
L 392.42131 235.512
" style="fill:none;stroke:#4c4c4c;stroke-linecap:round;stroke-width:1.5;"/>
</g>
......@@ -484,22 +484,22 @@ L 2.12132 0
L -0 -3.535534
L -2.12132 -0
z
" id="m060b421f41" style="stroke:#4c4c4c;stroke-linejoin:miter;"/>
" id="mb031c7d105" style="stroke:#4c4c4c;stroke-linejoin:miter;"/>
</defs>
<g clip-path="url(#pe04f5b89f8)">
<use style="fill:#4c4c4c;stroke:#4c4c4c;stroke-linejoin:miter;" x="27.490909" xlink:href="#m060b421f41" y="170.28"/>
<use style="fill:#4c4c4c;stroke:#4c4c4c;stroke-linejoin:miter;" x="397.010755" xlink:href="#m060b421f41" y="170.28"/>
<use style="fill:#4c4c4c;stroke:#4c4c4c;stroke-linejoin:miter;" x="400.626681" xlink:href="#m060b421f41" y="170.28"/>
<use style="fill:#4c4c4c;stroke:#4c4c4c;stroke-linejoin:miter;" x="416.063904" xlink:href="#m060b421f41" y="170.28"/>
<use style="fill:#4c4c4c;stroke:#4c4c4c;stroke-linejoin:miter;" x="405.911496" xlink:href="#m060b421f41" y="170.28"/>
<use style="fill:#4c4c4c;stroke:#4c4c4c;stroke-linejoin:miter;" x="396.732606" xlink:href="#m060b421f41" y="170.28"/>
<use style="fill:#4c4c4c;stroke:#4c4c4c;stroke-linejoin:miter;" x="433.309091" xlink:href="#m060b421f41" y="170.28"/>
<use style="fill:#4c4c4c;stroke:#4c4c4c;stroke-linejoin:miter;" x="394.507421" xlink:href="#m060b421f41" y="170.28"/>
<use style="fill:#4c4c4c;stroke:#4c4c4c;stroke-linejoin:miter;" x="398.679644" xlink:href="#m060b421f41" y="170.28"/>
<g clip-path="url(#pbda5ae153d)">
<use style="fill:#4c4c4c;stroke:#4c4c4c;stroke-linejoin:miter;" x="27.490909" xlink:href="#mb031c7d105" y="170.28"/>
<use style="fill:#4c4c4c;stroke:#4c4c4c;stroke-linejoin:miter;" x="397.010755" xlink:href="#mb031c7d105" y="170.28"/>
<use style="fill:#4c4c4c;stroke:#4c4c4c;stroke-linejoin:miter;" x="400.626681" xlink:href="#mb031c7d105" y="170.28"/>
<use style="fill:#4c4c4c;stroke:#4c4c4c;stroke-linejoin:miter;" x="416.063904" xlink:href="#mb031c7d105" y="170.28"/>
<use style="fill:#4c4c4c;stroke:#4c4c4c;stroke-linejoin:miter;" x="405.911496" xlink:href="#mb031c7d105" y="170.28"/>
<use style="fill:#4c4c4c;stroke:#4c4c4c;stroke-linejoin:miter;" x="396.732606" xlink:href="#mb031c7d105" y="170.28"/>
<use style="fill:#4c4c4c;stroke:#4c4c4c;stroke-linejoin:miter;" x="433.309091" xlink:href="#mb031c7d105" y="170.28"/>
<use style="fill:#4c4c4c;stroke:#4c4c4c;stroke-linejoin:miter;" x="394.507421" xlink:href="#mb031c7d105" y="170.28"/>
<use style="fill:#4c4c4c;stroke:#4c4c4c;stroke-linejoin:miter;" x="398.679644" xlink:href="#mb031c7d105" y="170.28"/>
</g>
</g>
<g id="line2d_14">
<path clip-path="url(#pe04f5b89f8)" d="M 211.555461 39.816
<path clip-path="url(#pbda5ae153d)" d="M 211.555461 39.816
L 211.555461 300.744
" style="fill:none;stroke:#4c4c4c;stroke-linecap:round;stroke-width:1.5;"/>
</g>
......@@ -526,7 +526,7 @@ L 453.6 7.2
</g>
</g>
<defs>
<clipPath id="pe04f5b89f8">
<clipPath id="pbda5ae153d">
<rect height="326.16" width="446.4" x="7.2" y="7.2"/>
</clipPath>
</defs>
......
......@@ -27,7 +27,7 @@
"metadata": {},
"outputs": [],
"source": [
"train_docs, test_docs = codebook_approach(30, 29) # best params: 30, 29"
"train_docs, test_docs = codebook_approach(25, 62) # best params: 25, 62"
]
},
{
......@@ -52,7 +52,7 @@
{
"data": {
"text/plain": [
"(7352, 42)"
"(7352, 54)"
]
},
"execution_count": 4,
......@@ -195,17 +195,9 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"DONE\n"
]
}
],
"outputs": [],
"source": [
"for rdst in range(0, 1500):\n",
" \n",
......@@ -220,7 +212,7 @@
" acc = accuracy_score(y_train, pred_labels)\n",
" p = [rdst, acc]\n",
" \n",
" with open('randomSeed_scors_m1.txt', 'a') as file: # save output in file \n",
" with open('randomSeed_scors_m1_2.txt', 'a') as file: # save output in file \n",
" s = ['[', ']', ',']\n",
" p = str(list(p))\n",
" for e in s:\n",
......
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