From d84fc83f2df9dd0fcf5269dd41b35bf483732325 Mon Sep 17 00:00:00 2001 From: ShawnHymel Date: Sat, 16 May 2020 12:44:38 -0500 Subject: [PATCH] Updated sketches --- .../esp32_deploy_tflite.ino | 3 + .../esp32_test_tflite/esp32_test_tflite.ino | 1 + ...y-detection-md-conversion-checkpoint.ipynb | 213 ++++++++++++++---- .../anomaly-detection-md-conversion.ipynb | 50 ++-- .../http_server_anomaly_detection_md.py | 6 +- 5 files changed, 196 insertions(+), 77 deletions(-) diff --git a/autoencoder/esp32_deploy_tflite/esp32_deploy_tflite.ino b/autoencoder/esp32_deploy_tflite/esp32_deploy_tflite.ino index f6c6f35..aa1edcb 100644 --- a/autoencoder/esp32_deploy_tflite/esp32_deploy_tflite.ino +++ b/autoencoder/esp32_deploy_tflite/esp32_deploy_tflite.ino @@ -1,6 +1,9 @@ /** * Use TensorFlow Lite model on real accelerometer data to detect anomalies * + * NOTE: You will need to install the TensorFlow Lite library: + * https://www.tensorflow.org/lite/microcontrollers + * * Author: Shawn Hymel * Date: May 6, 2020 * diff --git a/autoencoder/esp32_test_tflite/esp32_test_tflite.ino b/autoencoder/esp32_test_tflite/esp32_test_tflite.ino index 2cc8368..ca2ef63 100644 --- a/autoencoder/esp32_test_tflite/esp32_test_tflite.ino +++ b/autoencoder/esp32_test_tflite/esp32_test_tflite.ino @@ -173,6 +173,7 @@ void setup() { Serial.print("Inference result: "); for (int axis = 0; axis < normal_sample_dim2; axis++) { Serial.print(y_val[axis], 7); + Serial.print(" "); } Serial.println(); Serial.print("MSE: "); diff --git a/mahalanobis_distance/.ipynb_checkpoints/anomaly-detection-md-conversion-checkpoint.ipynb b/mahalanobis_distance/.ipynb_checkpoints/anomaly-detection-md-conversion-checkpoint.ipynb index 354be58..a1d90a6 100644 --- a/mahalanobis_distance/.ipynb_checkpoints/anomaly-detection-md-conversion-checkpoint.ipynb +++ b/mahalanobis_distance/.ipynb_checkpoints/anomaly-detection-md-conversion-checkpoint.ipynb @@ -11,7 +11,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 23, "metadata": {}, "outputs": [], "source": [ @@ -25,7 +25,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 24, "metadata": {}, "outputs": [ { @@ -47,7 +47,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 25, "metadata": {}, "outputs": [], "source": [ @@ -62,7 +62,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 26, "metadata": {}, "outputs": [ { @@ -87,7 +87,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 27, "metadata": {}, "outputs": [ { @@ -176,7 +176,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ @@ -189,7 +189,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 9, "metadata": {}, "outputs": [ { @@ -202,7 +202,12 @@ " [0.063477 0.169434 0.988281]\n", " [0.073242 0.166992 0.989258]\n", " [0.07373 0.170898 0.987305]\n", - " [0.069336 0.166992 0.989746]]\n" + " [0.069336 0.166992 0.989746]]\n", + "[[-0.024414 0.187988 0.961914]\n", + " [-0.01416 0.195801 0.986816]\n", + " [-0.020996 0.193359 0.98877 ]\n", + " [-0.021973 0.191406 0.983398]\n", + " [-0.010742 0.199219 0.996582]]\n" ] } ], @@ -213,12 +218,13 @@ " anomaly_sample = data['anomaly_sample']\n", "print(normal_sample.shape)\n", "print(anomaly_sample.shape)\n", - "print(normal_sample[:5])" + "print(normal_sample[:5])\n", + "print(anomaly_sample[:5])" ] }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ @@ -230,7 +236,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 36, "metadata": {}, "outputs": [], "source": [ @@ -241,19 +247,124 @@ }, { "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [], + "execution_count": 37, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "#ifndef ANOMALY_SAMPLE_H\n", + "#define ANOMALY_SAMPLE_H\n", + "\n", + "const unsigned int anomaly_sample_dim1 = 200;\n", + "const unsigned int anomaly_sample_dim2 = 3;\n", + "\n", + "const float anomaly_sample[200][3] = {\n", + " -0.024414, 0.187988, 0.961914, -0.01416, 0.195801, 0.986816, -0.020996, \n", + " 0.193359, 0.98877, -0.021973, 0.191406, 0.983398, -0.010742, 0.199219, \n", + " 0.996582, -0.029297, 0.183594, 0.976074, -0.006348, 0.19873, 0.988281, \n", + " -0.022949, 0.18457, 0.978516, -0.015625, 0.161133, 0.975098, -0.020996, \n", + " 0.194824, 0.98584, -0.024902, 0.187988, 0.98291, -0.019531, 0.190918, \n", + " 0.979981, -0.021973, 0.20166, 0.982422, -0.029785, 0.188965, 0.966797, \n", + " -0.015625, 0.199707, 0.983887, -0.03125, 0.181152, 0.973145, -0.01709, \n", + " 0.193848, 0.973145, -0.022949, 0.194336, 0.985352, -0.024902, 0.193359, \n", + " 0.977051, -0.013672, 0.201172, 0.983398, -0.033203, 0.186035, 0.976074, \n", + " -0.011719, 0.197266, 0.982422, -0.027832, 0.189453, 0.979981, -0.014648, \n", + " 0.183105, 0.972656, -0.013672, 0.193848, 0.98584, -0.024902, 0.188965, \n", + " 0.973145, -0.02002, 0.192383, 0.975586, -0.014648, 0.200195, 0.990723, \n", + " -0.02832, 0.192383, 0.973145, -0.008789, 0.198242, 0.987793, -0.027344, \n", + " 0.18457, 0.975098, -0.01416, 0.193359, 0.982422, -0.023926, 0.193848, \n", + " 0.982422, -0.020996, 0.193359, 0.978027, -0.012695, 0.202148, 0.988281, \n", + " -0.025879, 0.185547, 0.974121, -0.009277, 0.197754, 0.977051, -0.021484, \n", + " 0.200195, 0.98584, -0.026855, 0.189941, 0.979492, -0.008301, 0.195313, \n", + " 0.987793, -0.02002, 0.18457, 0.979492, -0.01416, 0.193848, 0.979492, \n", + " -0.017578, 0.195313, 0.98584, -0.021973, 0.193359, 0.978516, -0.014648, \n", + " 0.197266, 0.998047, -0.026855, 0.188965, 0.976563, -0.016113, 0.193359, \n", + " 0.984863, -0.026367, 0.192383, 0.976074, -0.020508, 0.190918, 0.975586, \n", + " -0.02002, 0.197266, 0.979492, -0.028809, 0.189453, 0.977051, -0.011719, \n", + " 0.193848, 0.974609, -0.018066, 0.19873, 0.982422, -0.029297, 0.189941, \n", + " 0.973633, -0.015625, 0.194336, 0.991699, -0.027344, 0.185059, 0.979981, \n", + " -0.014648, 0.193848, 0.984375, -0.018555, 0.195313, 0.977539, -0.024902, \n", + " 0.191406, 0.98291, -0.016113, 0.196777, 0.983398, -0.023926, 0.195313, \n", + " 0.974121, -0.013672, 0.195313, 0.977539, -0.024902, 0.192871, 0.978516, \n", + " -0.015625, 0.195801, 0.97168, -0.02002, 0.200195, 0.979981, -0.023926, \n", + " 0.189941, 0.975586, -0.021484, 0.195313, 0.979492, -0.020996, 0.20166, \n", + " 0.980957, -0.022461, 0.198242, 0.978027, -0.015625, 0.194824, 0.983887, \n", + " -0.022461, 0.19043, 0.984375, -0.01416, 0.189453, 0.984863, -0.018066, \n", + " 0.193848, 0.980469, -0.019531, 0.190918, 0.991211, -0.015137, 0.194336, \n", + " 0.984863, -0.021484, 0.1875, 0.984375, -0.009277, 0.191406, 0.98584, \n", + " -0.021484, 0.189941, 0.98584, -0.016113, 0.189941, 0.981445, -0.018066, \n", + " 0.19873, 0.984375, -0.019531, 0.188477, 0.977051, -0.019531, 0.189453, \n", + " 0.978027, -0.019531, 0.199219, 0.987305, -0.020996, 0.194336, 0.985352, \n", + " -0.017578, 0.199219, 0.976074, -0.024414, 0.190918, 0.977051, -0.019043, \n", + " 0.189453, 0.974609, -0.023926, 0.192871, 0.976563, -0.023438, 0.188965, \n", + " 0.975098, -0.023438, 0.194824, 0.980469, -0.025879, 0.190918, 0.981445, \n", + " -0.015625, 0.194824, 0.972168, -0.022461, 0.188477, 0.983398, -0.021973, \n", + " 0.217773, 0.986328, -0.018066, 0.192871, 0.976563, -0.018066, 0.192383, \n", + " 0.98291, -0.017578, 0.188965, 0.980469, -0.014648, 0.199219, 0.983398, \n", + " -0.020508, 0.194824, 0.979492, -0.014648, 0.200684, 0.982422, -0.021973, \n", + " 0.19043, 0.981445, -0.01709, 0.196289, 0.976563, -0.016113, 0.196777, \n", + " 0.980957, -0.025879, 0.188965, 0.98291, -0.017578, 0.203613, 0.985352, \n", + " -0.023438, 0.191895, 0.978516, -0.016113, 0.193359, 0.976563, -0.01709, \n", + " 0.191406, 0.983887, -0.020996, 0.186035, 0.978516, -0.015625, 0.194336, \n", + " 0.980469, -0.015137, 0.186523, 0.981445, -0.019043, 0.184082, 0.979981, \n", + " -0.013184, 0.197266, 0.984375, -0.021973, 0.187988, 0.987305, -0.01123, \n", + " 0.197754, 0.983887, -0.019043, 0.1875, 0.98877, -0.014648, 0.191895, \n", + " 0.976563, -0.015137, 0.193848, 0.982422, -0.025879, 0.187012, 0.973633, \n", + " -0.011719, 0.20166, 0.977051, -0.024902, 0.191406, 0.975586, -0.012695, \n", + " 0.200195, 0.967773, -0.020996, 0.197754, 0.980957, -0.02832, 0.1875, \n", + " 0.979492, -0.017578, 0.196777, 0.978516, -0.020508, 0.19043, 0.973633, \n", + " -0.024902, 0.189941, 0.974609, -0.018555, 0.196289, 0.982422, -0.02832, \n", + " 0.189941, 0.977051, -0.01709, 0.194336, 0.984375, -0.025879, 0.182617, \n", + " 0.98291, -0.019531, 0.193848, 0.98584, -0.016113, 0.18457, 0.981934, \n", + " -0.023926, 0.193359, 0.978516, -0.012207, 0.194824, 0.983398, -0.025879, \n", + " 0.188477, 0.979004, -0.010742, 0.192871, 0.96875, -0.013672, 0.197754, \n", + " 0.982422, -0.024414, 0.191406, 0.977051, -0.015137, 0.195313, 0.978516, \n", + " -0.018555, 0.1875, 0.980469, -0.015625, 0.19873, 0.97168, -0.012207, \n", + " 0.194336, 0.980469, -0.02832, 0.191406, 0.979004, -0.010742, 0.197266, \n", + " 0.988281, -0.027832, 0.18457, 0.980957, -0.018066, 0.192871, 0.983398, \n", + " -0.019531, 0.18457, 0.987305, -0.021484, 0.19043, 0.983398, -0.015625, \n", + " 0.192871, 0.98291, -0.028809, 0.186035, 0.980957, -0.024414, 0.193848, \n", + " 0.979981, -0.010742, 0.194824, 0.984375, -0.026367, 0.188965, 0.979004, \n", + " -0.008789, 0.199707, 0.980469, -0.019043, 0.18457, 0.975586, -0.012695, \n", + " 0.199707, 0.971191, -0.01709, 0.19043, 0.979004, -0.019531, 0.197754, \n", + " 0.978516, -0.012207, 0.199707, 0.979004, -0.027832, 0.186035, 0.975586, \n", + " -0.012207, 0.19873, 0.978516, -0.024902, 0.185547, 0.971191, -0.023926, \n", + " 0.194824, 0.972656, -0.021484, 0.202637, 0.975586, -0.002441, 0.181641, \n", + " 0.966797, -0.025391, 0.193848, 0.967285, -0.021973, 0.195801, 0.979981, \n", + " -0.031738, 0.188965, 0.973633, -0.01416, 0.199707, 0.984863, -0.026855, \n", + " 0.18457, 0.975586, -0.010254, 0.202148, 0.979981, -0.021484, 0.189941, \n", + " 0.979492, -0.020996, 0.193359, 0.976074, -0.014648, 0.199707, 0.986816, \n", + " -0.022461, 0.185547, 0.972168, -0.00293, 0.200195, 0.989746, -0.021484, \n", + " 0.183105, 0.975586, -0.010742, 0.168457, 0.972656, -0.015625, 0.202148, \n", + " 0.981445, -0.026367, 0.18457, 0.970703, -0.018555, 0.193848, 0.976074, \n", + " -0.020508, 0.196777, 0.98291, -0.029297, 0.1875, 0.974609, -0.01416, \n", + " 0.198242, 0.987305, -0.026367, 0.182617, 0.977051, -0.015625, 0.197754, \n", + " 0.980469, -0.019043, 0.19043, 0.980469, -0.019531, 0.190918, 0.978516, \n", + " -0.013184, 0.197754, 0.992676, -0.026367, 0.183594, 0.981445, -0.007813, \n", + " 0.195313, 0.998047, -0.024902, 0.213867, 0.987305, -0.01416, 0.184082, \n", + " 0.973633, -0.006836, 0.200684, 0.986816, -0.021484, 0.183594, 0.98291, \n", + " -0.01416, 0.19043, 0.977051, -0.018555, 0.194824, 0.98291, -0.027344, \n", + " 0.191406, 0.975586, -0.01416, 0.202637, 0.986328\n", + "};\n", + "\n", + "#endif //ANOMALY_SAMPLE_H\n" + ] + } + ], "source": [ "# Create C array out of anomaly sample\n", "c_sample = c_writer.create_array(anomaly_sample, 'float', c_anomaly_sample_name)\n", "header_str = c_writer.create_header(c_sample, c_anomaly_sample_name)\n", - "#print(header_str)" + "print(header_str)" ] }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 38, "metadata": {}, "outputs": [], "source": [ @@ -273,7 +384,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [ @@ -285,14 +396,14 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "[0.01158355 0.00651454 0.00434402]\n" + "[0.00615279 0.00217201 0.00398226]\n" ] } ], @@ -305,7 +416,7 @@ }, { "cell_type": "code", - "execution_count": 46, + "execution_count": 13, "metadata": {}, "outputs": [], "source": [ @@ -323,7 +434,7 @@ }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ @@ -347,7 +458,7 @@ }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 15, "metadata": {}, "outputs": [], "source": [ @@ -365,14 +476,14 @@ }, { "cell_type": "code", - "execution_count": 51, + "execution_count": 16, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "[0.0115835538, 0.006514544399999972, 0.0043440179999999825]\n" + "[0.006152790000000001, 0.0021720089999999912, 0.00398226359999995]\n" ] } ], @@ -385,14 +496,14 @@ }, { "cell_type": "code", - "execution_count": 52, + "execution_count": 17, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "2.0900788347195736\n" + "0.4374791356307415\n" ] } ], @@ -406,7 +517,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 18, "metadata": {}, "outputs": [], "source": [ @@ -421,7 +532,7 @@ }, { "cell_type": "code", - "execution_count": 60, + "execution_count": 19, "metadata": {}, "outputs": [], "source": [ @@ -453,7 +564,7 @@ }, { "cell_type": "code", - "execution_count": 63, + "execution_count": 20, "metadata": {}, "outputs": [], "source": [ @@ -479,46 +590,48 @@ }, { "cell_type": "code", - "execution_count": 64, + "execution_count": 21, "metadata": {}, "outputs": [ { - "data": { - "text/plain": [ - "2.0900788347195736" - ] - }, - "execution_count": 64, - "metadata": {}, - "output_type": "execute_result" + "name": "stdout", + "output_type": "stream", + "text": [ + "Normal Sample\n", + "MAD: [0.006152790000000001, 0.0021720089999999912, 0.00398226359999995]\n", + "Mahalanobis distance: 0.4374791356307415\n" + ] } ], "source": [ "# Test Mahalanobis function with normal sample\n", - "mahalanobis(normal_x, model_mu.tolist(), inv_cov.tolist())" + "print('Normal Sample')\n", + "print('MAD:', normal_x)\n", + "print('Mahalanobis distance:', mahalanobis(normal_x, model_mu.tolist(), inv_cov.tolist()))" ] }, { "cell_type": "code", - "execution_count": 65, + "execution_count": 22, "metadata": {}, "outputs": [ { - "data": { - "text/plain": [ - "4844.40534566512" - ] - }, - "execution_count": 65, - "metadata": {}, - "output_type": "execute_result" + "name": "stdout", + "output_type": "stream", + "text": [ + "Anomaly Sample\n", + "MAD: [0.0057917769, 0.0050675268000000065, 0.00542928120000008]\n", + "Mahalanobis distance: 0.6499213735195706\n" + ] } ], "source": [ - "# Find MAD for anomaly sample\n", + "# Test Mahalanobis function with anomaly sample\n", + "print('Anomaly Sample')\n", "sample = anomaly_sample[0:max_measurements] # Truncate to 128 measurements\n", "anomaly_x = extract_mad_features(sample)\n", - "mahalanobis(anomaly_x, model_mu, inv_cov)" + "print('MAD:', anomaly_x)\n", + "print('Mahalanobis distance:', mahalanobis(anomaly_x, model_mu, inv_cov))" ] }, { diff --git a/mahalanobis_distance/anomaly-detection-md-conversion.ipynb b/mahalanobis_distance/anomaly-detection-md-conversion.ipynb index 98e7b3f..a1d90a6 100644 --- a/mahalanobis_distance/anomaly-detection-md-conversion.ipynb +++ b/mahalanobis_distance/anomaly-detection-md-conversion.ipynb @@ -11,7 +11,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 23, "metadata": {}, "outputs": [], "source": [ @@ -25,7 +25,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 24, "metadata": {}, "outputs": [ { @@ -47,7 +47,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 25, "metadata": {}, "outputs": [], "source": [ @@ -62,7 +62,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 26, "metadata": {}, "outputs": [ { @@ -87,7 +87,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 27, "metadata": {}, "outputs": [ { @@ -176,7 +176,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ @@ -189,7 +189,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 9, "metadata": {}, "outputs": [ { @@ -224,7 +224,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ @@ -248,7 +248,9 @@ { "cell_type": "code", "execution_count": 37, - "metadata": {}, + "metadata": { + "scrolled": true + }, "outputs": [ { "name": "stdout", @@ -382,7 +384,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [ @@ -394,7 +396,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -414,7 +416,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 13, "metadata": {}, "outputs": [], "source": [ @@ -432,7 +434,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ @@ -456,7 +458,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 15, "metadata": {}, "outputs": [], "source": [ @@ -474,7 +476,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 16, "metadata": {}, "outputs": [ { @@ -494,7 +496,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 17, "metadata": {}, "outputs": [ { @@ -515,7 +517,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 18, "metadata": {}, "outputs": [], "source": [ @@ -530,7 +532,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 19, "metadata": {}, "outputs": [], "source": [ @@ -562,7 +564,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 20, "metadata": {}, "outputs": [], "source": [ @@ -588,7 +590,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 21, "metadata": {}, "outputs": [ { @@ -610,22 +612,22 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 22, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Normal Sample\n", + "Anomaly Sample\n", "MAD: [0.0057917769, 0.0050675268000000065, 0.00542928120000008]\n", "Mahalanobis distance: 0.6499213735195706\n" ] } ], "source": [ - "# Find MAD for anomaly sample\n", - "print('Normal Sample')\n", + "# Test Mahalanobis function with anomaly sample\n", + "print('Anomaly Sample')\n", "sample = anomaly_sample[0:max_measurements] # Truncate to 128 measurements\n", "anomaly_x = extract_mad_features(sample)\n", "print('MAD:', anomaly_x)\n", diff --git a/mahalanobis_distance/http_server_anomaly_detection_md.py b/mahalanobis_distance/http_server_anomaly_detection_md.py index d505522..914ba53 100644 --- a/mahalanobis_distance/http_server_anomaly_detection_md.py +++ b/mahalanobis_distance/http_server_anomaly_detection_md.py @@ -109,7 +109,7 @@ def do_POST(self): self.end_headers() # Decode JSON and compute MSE - file_num = parseSamples(body.decode('ascii')) + parseSamples(body.decode('ascii')) # Server thread class ServerThread(threading.Thread): @@ -128,8 +128,8 @@ def is_stopped(self): # Main # Parse arguments -parser = argparse.ArgumentParser(description='Server that saves data from' + - 'IoT sensor node.') +parser = argparse.ArgumentParser(description='Server that receives data from' + + 'IoT sensor node and detects anomalies.') parser.add_argument('-p', action='store', dest='port', type=int, default=DEFUALT_PORT, help='Port number for server') args = parser.parse_args()