-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dae0239
commit 8534028
Showing
41 changed files
with
519 additions
and
1,083 deletions.
There are no files selected for viewing
330 changes: 0 additions & 330 deletions
330
Data_Analysis_Python/.ipynb_checkpoints/Data Acquisition-checkpoint.ipynb
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 0 additions & 6 deletions
6
Data_Analysis_Python/.ipynb_checkpoints/Offline Predictions-checkpoint.ipynb
This file was deleted.
Oops, something went wrong.
139 changes: 137 additions & 2 deletions
139
Data_Analysis_Python/.ipynb_checkpoints/Online Prediction-checkpoint.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,141 @@ | ||
{ | ||
"cells": [], | ||
"metadata": {}, | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Notebook for Heroku hosted ML API" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Importing libraries" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import csv\n", | ||
"import scipy.signal\n", | ||
"import serial\n", | ||
"import numpy as np\n", | ||
"import urllib.request " | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Loading the serial port" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"try:\n", | ||
" arduino = serial.Serial(\"/COM9\",timeout=1)\n", | ||
" print(\"The port has been successfully loaded.\")\n", | ||
"except:\n", | ||
" print(\"Please check the port.\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Acquiring the data and extracting the parameters" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"dataset = []\n", | ||
"data_count = 0\n", | ||
"\n", | ||
"while data_count<11:\n", | ||
" rawdata = []\n", | ||
" count = 0\n", | ||
" while count<100:\n", | ||
" rawdata.append(int(arduino.readline()))\n", | ||
" count+=1\n", | ||
" dataset.append(rawdata)\n", | ||
" data_count+=1\n", | ||
"\n", | ||
"# Filtering of the input values\n", | ||
"filtered_values = []\n", | ||
"\n", | ||
"mean_value = np.mean(dataset[10])\n", | ||
"value_25 = np.percentile(dataset[10], 25)\n", | ||
"value_75 = np.percentile(dataset[10], 75)\n", | ||
"\n", | ||
"for value in dataset[0]:\n", | ||
" filtered_values.append(value_75 if value > mean_value else value_25)\n", | ||
" \n", | ||
"url_parameter = \"\"\n", | ||
"for i in range(0,len(filtered_values)):\n", | ||
" if(i<len(filtered_values)-1):\n", | ||
" url_parameter += str(filtered_values[i])\n", | ||
" url_parameter += \",\"\n", | ||
" else:\n", | ||
" url_parameter += str(filtered_values[i])\n", | ||
"\n", | ||
"# Extraction of the signal parameters\n", | ||
"extracted_parameters = [np.amin(filtered_values), np.amax(filtered_values),\n", | ||
" np.ptp(filtered_values), np.percentile(filtered_values, 75),\n", | ||
" np.percentile(filtered_values, 25), np.median(filtered_values),\n", | ||
" np.mean(filtered_values), round(np.std(filtered_values),2),\n", | ||
" round(np.var(filtered_values),2), round(scipy.stats.kurtosis(filtered_values),2),\n", | ||
" round(scipy.stats.skew(filtered_values),2)]\n", | ||
"\n", | ||
"print('\\nThe parameters of this signal are: ', extracted_parameters)\n", | ||
"\n", | ||
"# Calling the web API\n", | ||
"web_api_url = \"https://pacific-harbor-19774.herokuapp.com/predict?myvar=\" + str(url_parameter)\n", | ||
"print('\\nThe web API URL is: ', web_api_url)\n", | ||
"\n", | ||
"urllib.request.urlopen(web_api_url)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"arduino.close()" | ||
] | ||
} | ||
], | ||
"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.7.2" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
6 changes: 0 additions & 6 deletions
6
Data_Analysis_Python/.ipynb_checkpoints/Untitled-checkpoint.ipynb
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
Data_Analysis_Python/.ipynb_checkpoints/Untitled1-checkpoint.ipynb
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.