Created calibration for all MQ-2 data

This commit is contained in:
miguel5612 2019-07-01 20:45:55 -05:00
parent 87f3e4efe5
commit 312097f3f8
5 changed files with 9624 additions and 2729 deletions

2138
Experiments/.ipynb Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,795 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 72,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: pandas in c:\\programdata\\anaconda3\\lib\\site-packages (0.24.2)\n",
"Requirement already satisfied: numpy>=1.12.0 in c:\\programdata\\anaconda3\\lib\\site-packages (from pandas) (1.16.2)\n",
"Requirement already satisfied: pytz>=2011k in c:\\programdata\\anaconda3\\lib\\site-packages (from pandas) (2018.9)\n",
"Requirement already satisfied: python-dateutil>=2.5.0 in c:\\programdata\\anaconda3\\lib\\site-packages (from pandas) (2.8.0)\n",
"Requirement already satisfied: six>=1.5 in c:\\programdata\\anaconda3\\lib\\site-packages (from python-dateutil>=2.5.0->pandas) (1.12.0)\n",
"Requirement already satisfied: xlrd in c:\\programdata\\anaconda3\\lib\\site-packages (1.2.0)\n",
"Requirement already satisfied: sklearn in c:\\programdata\\anaconda3\\lib\\site-packages (0.0)\n",
"Requirement already satisfied: scikit-learn in c:\\programdata\\anaconda3\\lib\\site-packages (from sklearn) (0.20.3)\n",
"Requirement already satisfied: numpy>=1.8.2 in c:\\programdata\\anaconda3\\lib\\site-packages (from scikit-learn->sklearn) (1.16.2)\n",
"Requirement already satisfied: scipy>=0.13.3 in c:\\programdata\\anaconda3\\lib\\site-packages (from scikit-learn->sklearn) (1.2.1)\n",
"Collecting imbalanced-learn\n",
" Using cached https://files.pythonhosted.org/packages/e6/62/08c14224a7e242df2cef7b312d2ef821c3931ec9b015ff93bb52ec8a10a3/imbalanced_learn-0.5.0-py3-none-any.whl\n",
"Requirement already satisfied: numpy>=1.11 in c:\\programdata\\anaconda3\\lib\\site-packages (from imbalanced-learn) (1.16.2)\n",
"Requirement already satisfied: joblib>=0.11 in c:\\programdata\\anaconda3\\lib\\site-packages (from imbalanced-learn) (0.13.2)\n",
"Requirement already satisfied: scipy>=0.17 in c:\\programdata\\anaconda3\\lib\\site-packages (from imbalanced-learn) (1.2.1)\n",
"Collecting scikit-learn>=0.21 (from imbalanced-learn)\n",
" Using cached https://files.pythonhosted.org/packages/75/14/fde90de4fc6722303ddbc183ec253c288dae8c7e4eb5a069ac49f14c9a0f/scikit_learn-0.21.2-cp37-cp37m-win_amd64.whl\n",
"Installing collected packages: scikit-learn, imbalanced-learn\n",
" Found existing installation: scikit-learn 0.20.3\n",
" Uninstalling scikit-learn-0.20.3:\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"Could not install packages due to an EnvironmentError: [WinError 5] Acceso denegado: 'c:\\\\programdata\\\\anaconda3\\\\lib\\\\site-packages\\\\scikit_learn-0.20.3.dist-info\\\\COPYING'\n",
"Consider using the `--user` option or check the permissions.\n",
"\n"
]
}
],
"source": [
"!pip install pandas\n",
"!pip install xlrd\n",
"!pip install sklearn\n",
"!pip install imbalanced-learn"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"import xlrd\n",
"book = xlrd.open_workbook(\"Datasheets info.xlsx\")\n",
"sheetMQ2 = book.sheet_by_name(\"MQ2 - Pololulu\")\n",
"sheetMQ3 = book.sheet_by_name(\"MQ3 - Sparkfun\")\n",
"sheetMQ4 = book.sheet_by_name(\"MQ4 - Sparkfun\")\n",
"sheetMQ5 = book.sheet_by_name(\"MQ5 - Sparkfun\")\n",
"sheetMQ6 = book.sheet_by_name(\"MQ6 - Sparkfun\")\n",
"sheetMQ7 = book.sheet_by_name(\"MQ7 - Sparkfun\")\n",
"sheetMQ8 = book.sheet_by_name(\"MQ8 - Sparkfun\")\n",
"sheetMQ9 = book.sheet_by_name(\"MQ9 - Haoyuelectronics\")\n",
"sheetMQ131 = book.sheet_by_name(\"MQ131- Sensorsportal\")\n",
"sheetMQ135 = book.sheet_by_name(\"MQ135 - HANWEI\")\n",
"sheetMQ303A = book.sheet_by_name(\"MQ303A - HANWEI\")\n",
"sheetMQ309A = book.sheet_by_name(\"MQ309A - HANWEI\")"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"RS/R0 \t H2 \t LPG \t CH4 \t CO \t Alcohol \t Propane\n",
"0.1 \t \t \t \t \t \t \n",
"0.2 \t \t \t \t \t \t \n",
"0.3 \t \t \t \t \t \t \n",
"0.4 \t \t \t \t \t \t \n",
"0.5 \t \t \t \t \t \t \n",
"0.6 \t \t 2000.0 \t \t \t \t 2000.0\n",
"0.7 \t 2100.0 \t \t \t \t \t \n",
"0.8 \t \t 1000.0 \t \t \t \t 1000.0\n",
"0.9 \t \t 800.0 \t 5000.0 \t \t 5000.0 \t 800.0\n",
"1.0 \t 1000.0 \t \t \t \t \t \n",
"2.0 \t 201.0 \t \t 800.0 \t \t 500.0 \t \n",
"3.0 \t \t \t 200.0 \t 1000.0 \t 200.0 \t \n",
"4.0 \t \t \t \t 500.0 \t \t \n",
"5.0 \t \t \t \t 200.0 \t \t \n",
"6.0 \t \t \t \t \t \t \n",
"7.0 \t \t \t \t \t \t \n",
"8.0 \t \t \t \t \t \t \n",
"9.0 \t \t \t \t \t \t \n"
]
}
],
"source": [
"for row_index in range(1,20): #reading first columns\n",
" RsR0, H2, LPG, CH4, CO, Alcohol, propane = sheetMQ2.row_values(row_index, start_colx=0, end_colx=7)\n",
" print(RsR0, \"\t\", H2, \"\t\", LPG, \"\t\", CH4, \"\t\", CO, \"\t\", Alcohol, \"\t\", propane)\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"x_MQ2 = sheetMQ2.col_values(0)[2:]\n",
"MQ2_H2 = sheetMQ2.col_values(1)[2:]\n",
"MQ2_LPG = sheetMQ2.col_values(2)[2:]\n",
"MQ2_CH4 = sheetMQ2.col_values(3)[2:]\n",
"MQ2_CO = sheetMQ2.col_values(4)[2:]\n",
"MQ2_Alcohol = sheetMQ2.col_values(5)[2:]\n",
"MQ2_propane = sheetMQ2.col_values(6)[2:]"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"def zero_to_nan(values):\n",
" \"\"\"Replace every 0 with 'nan' and return a copy.\"\"\"\n",
" return [float('nan') if x==0 else x for x in values]"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"MQ2_H2 =zero_to_nan(MQ2_H2)\n",
"MQ2_LPG =zero_to_nan(MQ2_LPG)\n",
"MQ2_CH4 =zero_to_nan(MQ2_CH4)\n",
"MQ2_CO =zero_to_nan(MQ2_CO)\n",
"MQ2_Alcohol =zero_to_nan(MQ2_Alcohol)\n",
"MQ2_propane =zero_to_nan(MQ2_propane)"
]
},
{
"cell_type": "code",
"execution_count": 71,
"metadata": {},
"outputs": [
{
"ename": "ModuleNotFoundError",
"evalue": "No module named 'imblearn'",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-71-55daac296e90>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m 5\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[0msklearn\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtree\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mDecisionTreeClassifier\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 6\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[0msklearn\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mdatasets\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 7\u001b[1;33m \u001b[1;32mfrom\u001b[0m \u001b[0mimblearn\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mover_sampling\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mSMOTE\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 8\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 9\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'imblearn'"
]
}
],
"source": [
"import pandas as pd\n",
"import numpy as np\n",
"from sklearn.datasets import load_iris\n",
"#from sklearn.cross_validation import train_test_split\n",
"from sklearn.tree import DecisionTreeClassifier\n",
"from sklearn import datasets\n",
"from imblearn.over_sampling import SMOTE\n",
"\n",
"\n",
"dataH2 = {'RsRo': x_MQ2, 'H2': MQ2_H2}\n",
"#, 'LPG': MQ2_LPG, 'CH4': MQ2_CH4, 'CO': MQ2_CO, 'Alcohol': MQ2_Alcohol, 'Propane': MQ2_propane\n",
"dfMQ2_H2 = pd.DataFrame(dataH2)\n",
"\n",
"dfMQ2_H2['H2'] = pd.to_numeric(dfMQ2_H2['H2'])\n",
"#dfMQ2_H2['LPG'] = pd.to_numeric(dfMQ2_H2['LPG'])\n",
"#dfMQ2_H2['CH4'] = pd.to_numeric(dfMQ2_H2['CH4'])\n",
"#dfMQ2_H2['CO'] = pd.to_numeric(dfMQ2_H2['CO'])\n",
"#dfMQ2_H2['Alcohol'] = pd.to_numeric(dfMQ2_H2['Alcohol'])\n",
"#dfMQ2_H2['Propane'] = pd.to_numeric(dfMQ2_H2['Propane'])\n",
"\n",
"\n",
"dfMQ2_H2['H2'] = dfMQ2_H2['H2'].replace('',None, regex=True)\n",
"#dfMQ2_H2['LPG'] = dfMQ2_H2['LPG'].replace('',None, regex=True)\n",
"#dfMQ2_H2['CH4'] = dfMQ2_H2['CH4'].replace('',None, regex=True)\n",
"#dfMQ2_H2['CO'] = dfMQ2_H2['CO'].replace('',None, regex=True)\n",
"#dfMQ2_H2['Alcohol'] = dfMQ2_H2['Alcohol'].replace('',None, regex=True)\n",
"#dfMQ2_H2['Propane'] = dfMQ2_H2['Propane'].replace('',None, regex=True)\n",
"\n",
"dataset2Train = dfMQ2_H2.copy()\n",
"dataset2Train.dropna(inplace=True)\n",
"\n",
"#dfMQ2_H2 = dfMQ2_H2.interpolate(method='polynomial', order=2, axis=0).ffill().bfill()\n",
"#print(dfMQ2_H2)\n",
"#print(dataset2Train)\n",
"\n",
"X_train = dataset2Train.RsRo.apply(lambda x: [x]).tolist()\n",
"y_train = dataset2Train['H2'].tolist()\n",
"\n",
"print(X_train)\n",
"print(y_train)\n",
"\n",
"#model = DecisionTreeClassifier()\n",
"model = SMOTE(random_state=0)\n",
"model.fit(X_train, y_train)\n",
"\n",
"X_Predict = dfMQ2_H2.RsRo.apply(lambda x: [x]).tolist()\n",
"\n",
"print(X_Predict)\n",
"y_Predicted = model.predict(X_Predict)\n",
"print(y_Predicted)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%config InlineBackend.figure_formats = ['svg']\n",
"%matplotlib inline\n",
"import matplotlib.pyplot as plt\n",
"import matplotlib.lines as mlines\n",
"import matplotlib.transforms as mtransforms\n",
"\n",
"fig, ax = plt.subplots()\n",
"\n",
"fig.set_size_inches(9, 5.5, forward=True)\n",
"fig.set_dpi(200)\n",
"\n",
"# only these two lines are calibration curves\n",
"plt.plot(MQ2_H2, x_MQ2, marker='o', linewidth=1, label='H2')\n",
"#plt.plot(MQ2_LPG, x_MQ2, marker='o', linewidth=1, label='LPG')\n",
"#plt.plot(MQ2_CH4, x_MQ2, marker='o', linewidth=1, label='CH4')\n",
"#plt.plot(MQ2_CO, x_MQ2, marker='o', linewidth=1, label='CO')\n",
"#plt.plot(MQ2_Alcohol, x_MQ2, marker='o', linewidth=1, label='Alcohol')\n",
"#plt.plot(MQ2_propane, x_MQ2, marker='o', linewidth=1, label='Propane')\n",
"\n",
"# reference line, legends, and axis labels\n",
"#line = mlines.Line2D([0, 1], [0, 1], color='black')\n",
"#transform = ax.transAxes\n",
"#line.set_transform(transform)\n",
"#ax.add_line(line)\n",
"plt.yscale('log')\n",
"plt.xscale('log')\n",
"\n",
"fig.suptitle('Calibration plot for MQ data')\n",
"ax.set_xlabel('PPM Concentration')\n",
"ax.set_ylabel('Rs/Ro')\n",
"plt.legend()\n",
"plt.savefig('demo1.svg')\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 49,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[ 0.06169621]\n",
" [-0.05147406]\n",
" [ 0.04445121]\n",
" [-0.01159501]\n",
" [-0.03638469]\n",
" [-0.04069594]\n",
" [-0.04716281]\n",
" [-0.00189471]\n",
" [ 0.06169621]\n",
" [ 0.03906215]\n",
" [-0.08380842]\n",
" [ 0.01750591]\n",
" [-0.02884001]\n",
" [-0.00189471]\n",
" [-0.02560657]\n",
" [-0.01806189]\n",
" [ 0.04229559]\n",
" [ 0.01211685]\n",
" [-0.0105172 ]\n",
" [-0.01806189]\n",
" [-0.05686312]\n",
" [-0.02237314]\n",
" [-0.00405033]\n",
" [ 0.06061839]\n",
" [ 0.03582872]\n",
" [-0.01267283]\n",
" [-0.07734155]\n",
" [ 0.05954058]\n",
" [-0.02129532]\n",
" [-0.00620595]\n",
" [ 0.04445121]\n",
" [-0.06548562]\n",
" [ 0.12528712]\n",
" [-0.05039625]\n",
" [-0.06332999]\n",
" [-0.03099563]\n",
" [ 0.02289497]\n",
" [ 0.01103904]\n",
" [ 0.07139652]\n",
" [ 0.01427248]\n",
" [-0.00836158]\n",
" [-0.06764124]\n",
" [-0.0105172 ]\n",
" [-0.02345095]\n",
" [ 0.06816308]\n",
" [-0.03530688]\n",
" [-0.01159501]\n",
" [-0.0730303 ]\n",
" [-0.04177375]\n",
" [ 0.01427248]\n",
" [-0.00728377]\n",
" [ 0.0164281 ]\n",
" [-0.00943939]\n",
" [-0.01590626]\n",
" [ 0.0250506 ]\n",
" [-0.04931844]\n",
" [ 0.04121778]\n",
" [-0.06332999]\n",
" [-0.06440781]\n",
" [-0.02560657]\n",
" [-0.00405033]\n",
" [ 0.00457217]\n",
" [-0.00728377]\n",
" [-0.0374625 ]\n",
" [-0.02560657]\n",
" [-0.02452876]\n",
" [-0.01806189]\n",
" [-0.01482845]\n",
" [-0.02991782]\n",
" [-0.046085 ]\n",
" [-0.06979687]\n",
" [ 0.03367309]\n",
" [-0.00405033]\n",
" [-0.02021751]\n",
" [ 0.00241654]\n",
" [-0.03099563]\n",
" [ 0.02828403]\n",
" [-0.03638469]\n",
" [-0.05794093]\n",
" [-0.0374625 ]\n",
" [ 0.01211685]\n",
" [-0.02237314]\n",
" [-0.03530688]\n",
" [ 0.00996123]\n",
" [-0.03961813]\n",
" [ 0.07139652]\n",
" [-0.07518593]\n",
" [-0.00620595]\n",
" [-0.04069594]\n",
" [-0.04824063]\n",
" [-0.02560657]\n",
" [ 0.0519959 ]\n",
" [ 0.00457217]\n",
" [-0.06440781]\n",
" [-0.01698407]\n",
" [-0.05794093]\n",
" [ 0.00996123]\n",
" [ 0.08864151]\n",
" [-0.00512814]\n",
" [-0.06440781]\n",
" [ 0.01750591]\n",
" [-0.04500719]\n",
" [ 0.02828403]\n",
" [ 0.04121778]\n",
" [ 0.06492964]\n",
" [-0.03207344]\n",
" [-0.07626374]\n",
" [ 0.04984027]\n",
" [ 0.04552903]\n",
" [-0.00943939]\n",
" [-0.03207344]\n",
" [ 0.00457217]\n",
" [ 0.02073935]\n",
" [ 0.01427248]\n",
" [ 0.11019775]\n",
" [ 0.00133873]\n",
" [ 0.05846277]\n",
" [-0.02129532]\n",
" [-0.0105172 ]\n",
" [-0.04716281]\n",
" [ 0.00457217]\n",
" [ 0.01750591]\n",
" [ 0.08109682]\n",
" [ 0.0347509 ]\n",
" [ 0.02397278]\n",
" [-0.00836158]\n",
" [-0.06117437]\n",
" [-0.00189471]\n",
" [-0.06225218]\n",
" [ 0.0164281 ]\n",
" [ 0.09618619]\n",
" [-0.06979687]\n",
" [-0.02129532]\n",
" [-0.05362969]\n",
" [ 0.0433734 ]\n",
" [ 0.05630715]\n",
" [-0.0816528 ]\n",
" [ 0.04984027]\n",
" [ 0.11127556]\n",
" [ 0.06169621]\n",
" [ 0.01427248]\n",
" [ 0.04768465]\n",
" [ 0.01211685]\n",
" [ 0.00564998]\n",
" [ 0.04660684]\n",
" [ 0.12852056]\n",
" [ 0.05954058]\n",
" [ 0.09295276]\n",
" [ 0.01535029]\n",
" [-0.00512814]\n",
" [ 0.0703187 ]\n",
" [-0.00405033]\n",
" [-0.00081689]\n",
" [-0.04392938]\n",
" [ 0.02073935]\n",
" [ 0.06061839]\n",
" [-0.0105172 ]\n",
" [-0.03315126]\n",
" [-0.06548562]\n",
" [ 0.0433734 ]\n",
" [-0.06225218]\n",
" [ 0.06385183]\n",
" [ 0.03043966]\n",
" [ 0.07247433]\n",
" [-0.0191397 ]\n",
" [-0.06656343]\n",
" [-0.06009656]\n",
" [ 0.06924089]\n",
" [ 0.05954058]\n",
" [-0.02668438]\n",
" [-0.02021751]\n",
" [-0.046085 ]\n",
" [ 0.07139652]\n",
" [-0.07949718]\n",
" [ 0.00996123]\n",
" [-0.03854032]\n",
" [ 0.01966154]\n",
" [ 0.02720622]\n",
" [-0.00836158]\n",
" [-0.01590626]\n",
" [ 0.00457217]\n",
" [-0.04285156]\n",
" [ 0.00564998]\n",
" [-0.03530688]\n",
" [ 0.02397278]\n",
" [-0.01806189]\n",
" [ 0.04229559]\n",
" [-0.0547075 ]\n",
" [-0.00297252]\n",
" [-0.06656343]\n",
" [-0.01267283]\n",
" [-0.04177375]\n",
" [-0.03099563]\n",
" [-0.00512814]\n",
" [-0.05901875]\n",
" [ 0.0250506 ]\n",
" [-0.046085 ]\n",
" [ 0.00349435]\n",
" [ 0.05415152]\n",
" [-0.04500719]\n",
" [-0.05794093]\n",
" [-0.05578531]\n",
" [ 0.00133873]\n",
" [ 0.03043966]\n",
" [ 0.00672779]\n",
" [ 0.04660684]\n",
" [ 0.02612841]\n",
" [ 0.04552903]\n",
" [ 0.04013997]\n",
" [-0.01806189]\n",
" [ 0.01427248]\n",
" [ 0.03690653]\n",
" [ 0.00349435]\n",
" [-0.07087468]\n",
" [-0.03315126]\n",
" [ 0.09403057]\n",
" [ 0.03582872]\n",
" [ 0.03151747]\n",
" [-0.06548562]\n",
" [-0.04177375]\n",
" [-0.03961813]\n",
" [-0.03854032]\n",
" [-0.02560657]\n",
" [-0.02345095]\n",
" [-0.06656343]\n",
" [ 0.03259528]\n",
" [-0.046085 ]\n",
" [-0.02991782]\n",
" [-0.01267283]\n",
" [-0.01590626]\n",
" [ 0.07139652]\n",
" [-0.03099563]\n",
" [ 0.00026092]\n",
" [ 0.03690653]\n",
" [ 0.03906215]\n",
" [-0.01482845]\n",
" [ 0.00672779]\n",
" [-0.06871905]\n",
" [-0.00943939]\n",
" [ 0.01966154]\n",
" [ 0.07462995]\n",
" [-0.00836158]\n",
" [-0.02345095]\n",
" [-0.046085 ]\n",
" [ 0.05415152]\n",
" [-0.03530688]\n",
" [-0.03207344]\n",
" [-0.0816528 ]\n",
" [ 0.04768465]\n",
" [ 0.06061839]\n",
" [ 0.05630715]\n",
" [ 0.09834182]\n",
" [ 0.05954058]\n",
" [ 0.03367309]\n",
" [ 0.05630715]\n",
" [-0.06548562]\n",
" [ 0.16085492]\n",
" [-0.05578531]\n",
" [-0.02452876]\n",
" [-0.03638469]\n",
" [-0.00836158]\n",
" [-0.04177375]\n",
" [ 0.12744274]\n",
" [-0.07734155]\n",
" [ 0.02828403]\n",
" [-0.02560657]\n",
" [-0.06225218]\n",
" [-0.00081689]\n",
" [ 0.08864151]\n",
" [-0.03207344]\n",
" [ 0.03043966]\n",
" [ 0.00888341]\n",
" [ 0.00672779]\n",
" [-0.02021751]\n",
" [-0.02452876]\n",
" [-0.01159501]\n",
" [ 0.02612841]\n",
" [-0.05901875]\n",
" [-0.03638469]\n",
" [-0.02452876]\n",
" [ 0.01858372]\n",
" [-0.0902753 ]\n",
" [-0.00512814]\n",
" [-0.05255187]\n",
" [-0.02237314]\n",
" [-0.02021751]\n",
" [-0.0547075 ]\n",
" [-0.00620595]\n",
" [-0.01698407]\n",
" [ 0.05522933]\n",
" [ 0.07678558]\n",
" [ 0.01858372]\n",
" [-0.02237314]\n",
" [ 0.09295276]\n",
" [-0.03099563]\n",
" [ 0.03906215]\n",
" [-0.06117437]\n",
" [-0.00836158]\n",
" [-0.0374625 ]\n",
" [-0.01375064]\n",
" [ 0.07355214]\n",
" [-0.02452876]\n",
" [ 0.03367309]\n",
" [ 0.0347509 ]\n",
" [-0.03854032]\n",
" [-0.03961813]\n",
" [-0.00189471]\n",
" [-0.03099563]\n",
" [-0.046085 ]\n",
" [ 0.00133873]\n",
" [ 0.06492964]\n",
" [ 0.04013997]\n",
" [-0.02345095]\n",
" [ 0.05307371]\n",
" [ 0.04013997]\n",
" [-0.02021751]\n",
" [ 0.01427248]\n",
" [-0.03422907]\n",
" [ 0.00672779]\n",
" [ 0.00457217]\n",
" [ 0.03043966]\n",
" [ 0.0519959 ]\n",
" [ 0.06169621]\n",
" [-0.00728377]\n",
" [ 0.00564998]\n",
" [ 0.05415152]\n",
" [-0.00836158]\n",
" [ 0.114509 ]\n",
" [ 0.06708527]\n",
" [-0.05578531]\n",
" [ 0.03043966]\n",
" [-0.02560657]\n",
" [ 0.10480869]\n",
" [-0.00620595]\n",
" [-0.04716281]\n",
" [-0.04824063]\n",
" [ 0.08540807]\n",
" [-0.01267283]\n",
" [-0.03315126]\n",
" [-0.00728377]\n",
" [-0.01375064]\n",
" [ 0.05954058]\n",
" [ 0.02181716]\n",
" [ 0.01858372]\n",
" [-0.01159501]\n",
" [-0.00297252]\n",
" [ 0.01750591]\n",
" [-0.02991782]\n",
" [-0.02021751]\n",
" [-0.05794093]\n",
" [ 0.06061839]\n",
" [-0.04069594]\n",
" [-0.07195249]\n",
" [-0.05578531]\n",
" [ 0.04552903]\n",
" [-0.00943939]\n",
" [-0.03315126]\n",
" [ 0.04984027]\n",
" [-0.08488624]\n",
" [ 0.00564998]\n",
" [ 0.02073935]\n",
" [-0.00728377]\n",
" [ 0.10480869]\n",
" [-0.02452876]\n",
" [-0.00620595]\n",
" [-0.03854032]\n",
" [ 0.13714305]\n",
" [ 0.17055523]\n",
" [ 0.00241654]\n",
" [ 0.03798434]\n",
" [-0.05794093]\n",
" [-0.00943939]\n",
" [-0.02345095]\n",
" [-0.0105172 ]\n",
" [-0.03422907]\n",
" [-0.00297252]\n",
" [ 0.06816308]\n",
" [ 0.00996123]\n",
" [ 0.00241654]\n",
" [-0.03854032]\n",
" [ 0.02612841]\n",
" [-0.08919748]\n",
" [ 0.06061839]\n",
" [-0.02884001]\n",
" [-0.02991782]\n",
" [-0.0191397 ]\n",
" [-0.04069594]\n",
" [ 0.01535029]\n",
" [-0.02452876]\n",
" [ 0.00133873]\n",
" [ 0.06924089]\n",
" [-0.06979687]\n",
" [-0.02991782]\n",
" [-0.046085 ]\n",
" [ 0.01858372]\n",
" [ 0.00133873]\n",
" [-0.03099563]\n",
" [-0.00405033]\n",
" [ 0.01535029]\n",
" [ 0.02289497]\n",
" [ 0.04552903]\n",
" [-0.04500719]\n",
" [-0.03315126]\n",
" [ 0.097264 ]\n",
" [ 0.05415152]\n",
" [ 0.12313149]\n",
" [-0.08057499]\n",
" [ 0.09295276]\n",
" [-0.05039625]\n",
" [-0.01159501]\n",
" [-0.0277622 ]\n",
" [ 0.05846277]\n",
" [ 0.08540807]\n",
" [-0.00081689]\n",
" [ 0.00672779]\n",
" [ 0.00888341]\n",
" [ 0.08001901]\n",
" [ 0.07139652]\n",
" [-0.02452876]\n",
" [-0.0547075 ]\n",
" [-0.03638469]\n",
" [ 0.0164281 ]\n",
" [ 0.07786339]\n",
" [-0.03961813]\n",
" [ 0.01103904]\n",
" [-0.04069594]\n",
" [-0.03422907]\n",
" [ 0.00564998]\n",
" [ 0.08864151]\n",
" [-0.03315126]\n",
" [-0.05686312]\n",
" [-0.03099563]\n",
" [ 0.05522933]\n",
" [-0.06009656]\n",
" [ 0.00133873]\n",
" [-0.02345095]\n",
" [-0.07410811]]\n",
"[151. 75. 141. 206. 135. 97. 138. 63. 110. 310. 101. 69. 179. 185.\n",
" 118. 171. 166. 144. 97. 168. 68. 49. 68. 245. 184. 202. 137. 85.\n",
" 131. 283. 129. 59. 341. 87. 65. 102. 265. 276. 252. 90. 100. 55.\n",
" 61. 92. 259. 53. 190. 142. 75. 142. 155. 225. 59. 104. 182. 128.\n",
" 52. 37. 170. 170. 61. 144. 52. 128. 71. 163. 150. 97. 160. 178.\n",
" 48. 270. 202. 111. 85. 42. 170. 200. 252. 113. 143. 51. 52. 210.\n",
" 65. 141. 55. 134. 42. 111. 98. 164. 48. 96. 90. 162. 150. 279.\n",
" 92. 83. 128. 102. 302. 198. 95. 53. 134. 144. 232. 81. 104. 59.\n",
" 246. 297. 258. 229. 275. 281. 179. 200. 200. 173. 180. 84. 121. 161.\n",
" 99. 109. 115. 268. 274. 158. 107. 83. 103. 272. 85. 280. 336. 281.\n",
" 118. 317. 235. 60. 174. 259. 178. 128. 96. 126. 288. 88. 292. 71.\n",
" 197. 186. 25. 84. 96. 195. 53. 217. 172. 131. 214. 59. 70. 220.\n",
" 268. 152. 47. 74. 295. 101. 151. 127. 237. 225. 81. 151. 107. 64.\n",
" 138. 185. 265. 101. 137. 143. 141. 79. 292. 178. 91. 116. 86. 122.\n",
" 72. 129. 142. 90. 158. 39. 196. 222. 277. 99. 196. 202. 155. 77.\n",
" 191. 70. 73. 49. 65. 263. 248. 296. 214. 185. 78. 93. 252. 150.\n",
" 77. 208. 77. 108. 160. 53. 220. 154. 259. 90. 246. 124. 67. 72.\n",
" 257. 262. 275. 177. 71. 47. 187. 125. 78. 51. 258. 215. 303. 243.\n",
" 91. 150. 310. 153. 346. 63. 89. 50. 39. 103. 308. 116. 145. 74.\n",
" 45. 115. 264. 87. 202. 127. 182. 241. 66. 94. 283. 64. 102. 200.\n",
" 265. 94. 230. 181. 156. 233. 60. 219. 80. 68. 332. 248. 84. 200.\n",
" 55. 85. 89. 31. 129. 83. 275. 65. 198. 236. 253. 124. 44. 172.\n",
" 114. 142. 109. 180. 144. 163. 147. 97. 220. 190. 109. 191. 122. 230.\n",
" 242. 248. 249. 192. 131. 237. 78. 135. 244. 199. 270. 164. 72. 96.\n",
" 306. 91. 214. 95. 216. 263. 178. 113. 200. 139. 139. 88. 148. 88.\n",
" 243. 71. 77. 109. 272. 60. 54. 221. 90. 311. 281. 182. 321. 58.\n",
" 262. 206. 233. 242. 123. 167. 63. 197. 71. 168. 140. 217. 121. 235.\n",
" 245. 40. 52. 104. 132. 88. 69. 219. 72. 201. 110. 51. 277. 63.\n",
" 118. 69. 273. 258. 43. 198. 242. 232. 175. 93. 168. 275. 293. 281.\n",
" 72. 140. 189. 181. 209. 136. 261. 113. 131. 174. 257. 55. 84. 42.\n",
" 146. 212. 233. 91. 111. 152. 120. 67. 310. 94. 183. 66. 173. 72.\n",
" 49. 64. 48.]\n"
]
}
],
"source": [
"# Use only one feature\n",
"diabetes_X = diabetes.data[:, np.newaxis, 2]\n",
"\n",
"# Split the data into training/testing sets\n",
"diabetes_X_train = diabetes_X[:-5]\n",
"diabetes_X_test = diabetes_X[-5:]\n",
"\n",
"# Split the targets into training/testing sets\n",
"diabetes_y_train = diabetes.target[:-5]\n",
"diabetes_y_test = diabetes.target[-5:]\n",
"\n",
"print(diabetes_X_train)\n",
"print(diabetes_y_train)\n"
]
},
{
"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.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1486
Experiments/demo1.svg Normal file

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 49 KiB