利用matlab/simulink搭建电力系统微网故障检测模型,输出故障数据集,输入到ann模型中用于分类检测。
下载地址: 电力系统微网故障检测数据集、代码及仿真模型
current | load | result | Time_1.0 | Time_2.0 | Time_3.0 | Time_4.0 | Time_5.0 | Time_6.0 | Time_7.0 | Time_8.0 | Time_9.0 | Time_10.0 | Time_11.0 | Time_12.0 | Time_13.0 | Time_14.0 | Time_15.0 | Time_16.0 | |
0 | 8.858 | 492 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
1 | 4.429 | 246 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
2 | 4.429 | 246 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
3 | 4.429 | 246 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
4 | 4.429 | 246 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
5 | 7.382 | 410 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
6 | 14.76 | 819.9 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
7 | 26.57 | 1476 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
8 | 29.53 | 1640 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
9 | 14.76 | 819.9 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
10 | 8.858 | 492 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 |
11 | 22.12 | 983.9 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |
12 | 25.17 | 656 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
13 | 27.72 | 410 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
14 | 28.71 | 246 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |
15 | 26.06 | 328 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
16 | 18.79 | 819.9 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
17 | 7.311 | 1476 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
18 | 33.96 | 1886 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
19 | 32.48 | 1804 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
20 | 32.48 | 1804 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
21 | 33.96 | 1886 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
22 | 26.57 | 1476 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
23 | 5.249 | 1093 | 2 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
24 | 2.625 | 546.7 | 2 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
25 | 2.625 | 546.7 | 2 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
26 | 2.625 | 546.7 | 2 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
27 | 2.625 | 546.7 | 2 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
检测代码实例
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "ANN Model Code.ipynb",
"provenance": [],
"collapsed_sections": [],
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"accelerator": "GPU"
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
""
]
},
{
"cell_type": "code",
"metadata": {
"id": "vh_2PFdoc83n",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "3c535a50-5853-468d-b9f9-5a1d148a13ea"
},
"source": [
"import numpy as np\n",
"import pandas as pd\n",
"from keras.models import Sequential\n",
"from keras.layers import Dense\n",
"from keras.layers import Dropout\n",
"from keras.wrappers.scikit_learn import KerasClassifier\n",
"from sklearn.model_selection import cross_val_score\n",
"from sklearn.preprocessing import LabelEncoder\n",
"from sklearn.model_selection import StratifiedKFold\n",
"from sklearn.preprocessing import StandardScaler\n",
"from sklearn.pipeline import Pipeline"
],
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"text": [
"Using TensorFlow backend.\n"
],
"name": "stderr"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "p4mPCB1wwZQC",
"colab_type": "code",
"colab": {}
},
"source": [
"seed=7\n",
"np.random.seed(seed)"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "dOR-kUC5dPB7",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 360
},
"outputId": "eb51bf24-927c-49ee-851f-91541dde974c"
},
"source": [
"df=pd.read_excel('Data.xlsx')\n",
"df1=df.values\n",
"df"
],
"execution_count": null,
"outputs": [
{
"output_type": "error",
"ename": "FileNotFoundError",
"evalue": "ignored",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mdf\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mpd\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mread_excel\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'Data.xlsx'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mdf1\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mdf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvalues\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mdf\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/usr/local/lib/python3.6/dist-packages/pandas/io/excel/_base.py\u001b[0m in \u001b[0;36mread_excel\u001b[0;34m(io, sheet_name, header, names, index_col, usecols, squeeze, dtype, engine, converters, true_values, false_values, skiprows, nrows, na_values, keep_default_na, verbose, parse_dates, date_parser, thousands, comment, skipfooter, convert_float, mangle_dupe_cols, **kwds)\u001b[0m\n\u001b[1;32m 302\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 303\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0misinstance\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mio\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mExcelFile\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 304\u001b[0;31m \u001b[0mio\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mExcelFile\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mio\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mengine\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mengine\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 305\u001b[0m \u001b[0;32melif\u001b[0m \u001b[0mengine\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0mengine\u001b[0m \u001b[0;34m!=\u001b[0m \u001b[0mio\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mengine\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 306\u001b[0m raise ValueError(\n",
"\u001b[0;32m/usr/local/lib/python3.6/dist-packages/pandas/io/excel/_base.py\u001b[0m in \u001b[0;36m__init__\u001b[0;34m(self, io, engine)\u001b[0m\n\u001b[1;32m 822\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_io\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mstringify_path\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mio\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 823\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 824\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_reader\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_engines\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mengine\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_io\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 825\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 826\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__fspath__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/usr/local/lib/python3.6/dist-packages/pandas/io/excel/_xlrd.py\u001b[0m in \u001b[0;36m__init__\u001b[0;34m(self, filepath_or_buffer)\u001b[0m\n\u001b[1;32m 19\u001b[0m \u001b[0merr_msg\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m\"Install xlrd >= 1.0.0 for Excel support\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 20\u001b[0m \u001b[0mimport_optional_dependency\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"xlrd\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mextra\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0merr_msg\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 21\u001b[0;31m \u001b[0msuper\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__init__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfilepath_or_buffer\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 22\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 23\u001b[0m \u001b[0;34m@\u001b[0m\u001b[0mproperty\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/usr/local/lib/python3.6/dist-packages/pandas/io/excel/_base.py\u001b[0m in \u001b[0;36m__init__\u001b[0;34m(self, filepath_or_buffer)\u001b[0m\n\u001b[1;32m 351\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbook\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mload_workbook\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfilepath_or_buffer\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 352\u001b[0m \u001b[0;32melif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfilepath_or_buffer\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstr\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 353\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbook\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mload_workbook\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfilepath_or_buffer\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 354\u001b[0m \u001b[0;32melif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfilepath_or_buffer\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mbytes\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 355\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbook\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mload_workbook\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mBytesIO\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfilepath_or_buffer\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/usr/local/lib/python3.6/dist-packages/pandas/io/excel/_xlrd.py\u001b[0m in \u001b[0;36mload_workbook\u001b[0;34m(self, filepath_or_buffer)\u001b[0m\n\u001b[1;32m 34\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mopen_workbook\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfile_contents\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 35\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 36\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mopen_workbook\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfilepath_or_buffer\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 37\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 38\u001b[0m \u001b[0;34m@\u001b[0m\u001b[0mproperty\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/usr/local/lib/python3.6/dist-packages/xlrd/__init__.py\u001b[0m in \u001b[0;36mopen_workbook\u001b[0;34m(filename, logfile, verbosity, use_mmap, file_contents, encoding_override, formatting_info, on_demand, ragged_rows)\u001b[0m\n\u001b[1;32m 114\u001b[0m \u001b[0mpeek\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfile_contents\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0mpeeksz\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 115\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 116\u001b[0;31m \u001b[0;32mwith\u001b[0m \u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfilename\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"rb\"\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 117\u001b[0m \u001b[0mpeek\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mread\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpeeksz\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 118\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mpeek\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;34mb\"PK\\x03\\x04\"\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;31m# a ZIP file\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: 'Data.xlsx'"
]
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "rOOARm0VdcBp",
"colab_type": "code",
"colab": {}
},
"source": [
"po=pd.DataFrame(columns=['current','load','result','Time'])"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "fbVDvAuRdjpn",
"colab_type": "code",
"colab": {}
},
"source": [
"for i in range(23):\n",
" po=po.append({'current':df.at[i,\"Current 1\"],'load':df.at[i,\"P_L 1\"],'result':1,'Time':df.at[i,\"Time\"]},ignore_index=True)"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "oGNxLOtXdlhY",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 470
},
"outputId": "13485257-89c0-4378-e9c9-c63977b1cff6"
},
"source": [
"po"
],
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"\n",
"\n",
"\n",
" \n",
" \n",
" \n",
" 0 \n",
" 1 \n",
" 2 \n",
" 3 \n",
" 4 \n",
" 5 \n",
" 6 \n",
" 7 \n",
" 8 \n",
" 9 \n",
" 10 \n",
" 11 \n",
" 12 \n",
" 13 \n",
" 14 \n",
" 15 \n",
" 16 \n",
" 17 \n",
" 18 \n",
" 19 \n",
" 20 \n",
" 21 \n",
" 22 \n",
" 23 \n",
" 24 \n",
" 25 \n",
" 26 \n",
" 27 \n",
" 28 \n",
" 29 \n",
" 30 \n",
" 31 \n",
" 32 \n",
" 33 \n",
" 34 \n",
" 35 \n",
" 36 \n",
" 37 \n",
" 38 \n",
" 39 \n",
" ... \n",
" 3097 \n",
" 3098 \n",
" 3099 \n",
" 3100 \n",
" 3101 \n",
" 3102 \n",
" 3103 \n",
" 3104 \n",
" 3105 \n",
" 3106 \n",
" 3107 \n",
" 3108 \n",
" 3109 \n",
" 3110 \n",
" 3111 \n",
" 3112 \n",
" 3113 \n",
" 3114 \n",
" 3115 \n",
" 3116 \n",
" 3117 \n",
" 3118 \n",
" 3119 \n",
" 3120 \n",
" 3121 \n",
" 3122 \n",
" 3123 \n",
" 3124 \n",
" 3125 \n",
" 3126 \n",
" 3127 \n",
" 3128 \n",
" 3129 \n",
" 3130 \n",
" 3131 \n",
" 3132 \n",
" 3133 \n",
" 3134 \n",
" 3135 \n",
" label \n",
" \n",
" \n",
" image \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" train0.jpg \n",
" 165 \n",
" 166 \n",
" 174 \n",
" 174 \n",
" 175 \n",
" 193 \n",
" 196 \n",
" 194 \n",
" 200 \n",
" 193 \n",
" 197 \n",
" 194 \n",
" 190 \n",
" 198 \n",
" 194 \n",
" 200 \n",
" 190 \n",
" 201 \n",
" 197 \n",
" 201 \n",
" 208 \n",
" 209 \n",
" 201 \n",
" 203 \n",
" 203 \n",
" 199 \n",
" 192 \n",
" 193 \n",
" 182 \n",
" 192 \n",
" 180 \n",
" 181 \n",
" 173 \n",
" 160 \n",
" 182 \n",
" 186 \n",
" 188 \n",
" 189 \n",
" 192 \n",
" 184 \n",
" ... \n",
" 203 \n",
" 194 \n",
" 197 \n",
" 192 \n",
" 184 \n",
" 201 \n",
" 200 \n",
" 192 \n",
" 188 \n",
" 191 \n",
" 196 \n",
" 201 \n",
" 192 \n",
" 186 \n",
" 194 \n",
" 185 \n",
" 149 \n",
" 181 \n",
" 181 \n",
" 160 \n",
" 161 \n",
" 151 \n",
" 166 \n",
" 166 \n",
" 144 \n",
" 162 \n",
" 145 \n",
" 145 \n",
" 140 \n",
" 103 \n",
" 100 \n",
" 97 \n",
" 95 \n",
" 114 \n",
" 119 \n",
" 69 \n",
" 79 \n",
" 90 \n",
" 78 \n",
" 0 \n",
" \n",
" \n",
" train1.jpg \n",
" 27 \n",
" 44 \n",
" 61 \n",
" 78 \n",
" 96 \n",
" 109 \n",
" 120 \n",
" 123 \n",
" 130 \n",
" 136 \n",
" 144 \n",
" 150 \n",
" 163 \n",
" 169 \n",
" 172 \n",
" 165 \n",
" 157 \n",
" 163 \n",
" 169 \n",
" 170 \n",
" 173 \n",
" 173 \n",
" 166 \n",
" 170 \n",
" 173 \n",
" 175 \n",
" 179 \n",
" 185 \n",
" 186 \n",
" 184 \n",
" 183 \n",
" 177 \n",
" 178 \n",
" 180 \n",
" 178 \n",
" 176 \n",
" 181 \n",
" 177 \n",
" 169 \n",
" 169 \n",
" ... \n",
" 150 \n",
" 147 \n",
" 149 \n",
" 145 \n",
" 140 \n",
" 141 \n",
" 143 \n",
" 140 \n",
" 146 \n",
" 144 \n",
" 141 \n",
" 147 \n",
" 152 \n",
" 149 \n",
" 143 \n",
" 141 \n",
" 147 \n",
" 147 \n",
" 155 \n",
" 160 \n",
" 166 \n",
" 165 \n",
" 166 \n",
" 168 \n",
" 162 \n",
" 158 \n",
" 151 \n",
" 140 \n",
" 134 \n",
" 125 \n",
" 116 \n",
" 108 \n",
" 90 \n",
" 72 \n",
" 54 \n",
" 33 \n",
" 13 \n",
" 2 \n",
" 1 \n",
" 1 \n",
" \n",
" \n",
" train2.jpg \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 1 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" ... \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 1 \n",
" \n",
" \n",
" train3.jpg \n",
" 197 \n",
" 210 \n",
" 204 \n",
" 199 \n",
" 206 \n",
" 210 \n",
" 208 \n",
" 207 \n",
" 207 \n",
" 205 \n",
" 203 \n",
" 204 \n",
" 198 \n",
" 189 \n",
" 176 \n",
" 175 \n",
" 175 \n",
" 172 \n",
" 162 \n",
" 157 \n",
" 134 \n",
" 134 \n",
" 135 \n",
" 136 \n",
" 138 \n",
" 149 \n",
" 145 \n",
" 140 \n",
" 141 \n",
" 146 \n",
" 158 \n",
" 159 \n",
" 170 \n",
" 171 \n",
" 170 \n",
" 162 \n",
" 174 \n",
" 164 \n",
" 152 \n",
" 161 \n",
" ... \n",
" 165 \n",
" 166 \n",
" 153 \n",
" 146 \n",
" 161 \n",
" 168 \n",
" 174 \n",
" 176 \n",
" 179 \n",
" 178 \n",
" 174 \n",
" 173 \n",
" 174 \n",
" 175 \n",
" 164 \n",
" 160 \n",
" 157 \n",
" 162 \n",
" 176 \n",
" 181 \n",
" 184 \n",
" 197 \n",
" 193 \n",
" 193 \n",
" 197 \n",
" 192 \n",
" 197 \n",
" 203 \n",
" 200 \n",
" 201 \n",
" 198 \n",
" 201 \n",
" 203 \n",
" 198 \n",
" 211 \n",
" 199 \n",
" 196 \n",
" 196 \n",
" 197 \n",
" 2 \n",
" \n",
" \n",
" train4.jpg \n",
" 128 \n",
" 119 \n",
" 133 \n",
" 115 \n",
" 109 \n",
" 123 \n",
" 138 \n",
" 131 \n",
" 143 \n",
" 133 \n",
" 133 \n",
" 130 \n",
" 140 \n",
" 138 \n",
" 137 \n",
" 135 \n",
" 138 \n",
" 141 \n",
" 134 \n",
" 128 \n",
" 125 \n",
" 128 \n",
" 98 \n",
" 118 \n",
" 112 \n",
" 116 \n",
" 116 \n",
" 115 \n",
" 121 \n",
" 117 \n",
" 112 \n",
" 118 \n",
" 142 \n",
" 122 \n",
" 118 \n",
" 111 \n",
" 92 \n",
" 94 \n",
" 103 \n",
" 110 \n",
" ... \n",
" 169 \n",
" 167 \n",
" 163 \n",
" 164 \n",
" 173 \n",
" 168 \n",
" 167 \n",
" 156 \n",
" 146 \n",
" 156 \n",
" 154 \n",
" 135 \n",
" 129 \n",
" 149 \n",
" 146 \n",
" 150 \n",
" 152 \n",
" 142 \n",
" 138 \n",
" 141 \n",
" 141 \n",
" 130 \n",
" 130 \n",
" 120 \n",
" 130 \n",
" 110 \n",
" 117 \n",
" 117 \n",
" 129 \n",
" 121 \n",
" 116 \n",
" 120 \n",
" 126 \n",
" 119 \n",
" 129 \n",
" 132 \n",
" 134 \n",
" 131 \n",
" 123 \n",
" 1 \n",
" \n",
" \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" ... \n",
" \n",
" \n",
" train7691.jpg \n",
" 192 \n",
" 189 \n",
" 187 \n",
" 188 \n",
" 193 \n",
" 193 \n",
" 192 \n",
" 193 \n",
" 193 \n",
" 192 \n",
" 191 \n",
" 193 \n",
" 196 \n",
" 196 \n",
" 190 \n",
" 188 \n",
" 187 \n",
" 183 \n",
" 176 \n",
" 174 \n",
" 178 \n",
" 179 \n",
" 180 \n",
" 179 \n",
" 182 \n",
" 183 \n",
" 178 \n",
" 180 \n",
" 180 \n",
" 184 \n",
" 183 \n",
" 180 \n",
" 183 \n",
" 183 \n",
" 181 \n",
" 184 \n",
" 180 \n",
" 180 \n",
" 182 \n",
" 181 \n",
" ... \n",
" 167 \n",
" 162 \n",
" 161 \n",
" 154 \n",
" 155 \n",
" 157 \n",
" 159 \n",
" 159 \n",
" 155 \n",
" 161 \n",
" 157 \n",
" 153 \n",
" 149 \n",
" 148 \n",
" 144 \n",
" 146 \n",
" 146 \n",
" 147 \n",
" 156 \n",
" 165 \n",
" 168 \n",
" 175 \n",
" 173 \n",
" 174 \n",
" 174 \n",
" 176 \n",
" 175 \n",
" 180 \n",
" 179 \n",
" 178 \n",
" 179 \n",
" 181 \n",
" 179 \n",
" 176 \n",
" 177 \n",
" 177 \n",
" 180 \n",
" 181 \n",
" 181 \n",
" 4 \n",
" \n",
" \n",
" train7692.jpg \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 1 \n",
" 1 \n",
" 2 \n",
" 1 \n",
" 2 \n",
" 2 \n",
" 2 \n",
" 2 \n",
" 2 \n",
" 2 \n",
" 3 \n",
" 4 \n",
" 7 \n",
" 10 \n",
" 13 \n",
" 15 \n",
" 16 \n",
" 17 \n",
" 17 \n",
" 17 \n",
" 16 \n",
" 14 \n",
" 11 \n",
" 8 \n",
" 5 \n",
" 2 \n",
" 2 \n",
" 2 \n",
" 2 \n",
" 2 \n",
" 2 \n",
" ... \n",
" 8 \n",
" 16 \n",
" 23 \n",
" 29 \n",
" 36 \n",
" 42 \n",
" 48 \n",
" 52 \n",
" 55 \n",
" 57 \n",
" 60 \n",
" 59 \n",
" 54 \n",
" 47 \n",
" 40 \n",
" 34 \n",
" 27 \n",
" 20 \n",
" 11 \n",
" 6 \n",
" 1 \n",
" 1 \n",
" 0 \n",
" 0 \n",
" 1 \n",
" 0 \n",
" 1 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 3 \n",
" \n",
" \n",
" train7693.jpg \n",
" 96 \n",
" 97 \n",
" 100 \n",
" 105 \n",
" 110 \n",
" 114 \n",
" 114 \n",
" 112 \n",
" 113 \n",
" 119 \n",
" 124 \n",
" 118 \n",
" 118 \n",
" 120 \n",
" 121 \n",
" 122 \n",
" 120 \n",
" 116 \n",
" 116 \n",
" 121 \n",
" 123 \n",
" 125 \n",
" 130 \n",
" 124 \n",
" 133 \n",
" 124 \n",
" 109 \n",
" 123 \n",
" 130 \n",
" 133 \n",
" 136 \n",
" 131 \n",
" 134 \n",
" 137 \n",
" 138 \n",
" 146 \n",
" 139 \n",
" 145 \n",
" 142 \n",
" 139 \n",
" ... \n",
" 141 \n",
" 140 \n",
" 146 \n",
" 147 \n",
" 150 \n",
" 159 \n",
" 151 \n",
" 146 \n",
" 126 \n",
" 106 \n",
" 139 \n",
" 143 \n",
" 161 \n",
" 156 \n",
" 164 \n",
" 159 \n",
" 173 \n",
" 176 \n",
" 172 \n",
" 167 \n",
" 173 \n",
" 170 \n",
" 182 \n",
" 165 \n",
" 185 \n",
" 169 \n",
" 168 \n",
" 170 \n",
" 164 \n",
" 165 \n",
" 166 \n",
" 187 \n",
" 185 \n",
" 193 \n",
" 163 \n",
" 188 \n",
" 189 \n",
" 188 \n",
" 170 \n",
" 4 \n",
" \n",
" \n",
" train7694.jpg \n",
" 116 \n",
" 98 \n",
" 142 \n",
" 158 \n",
" 168 \n",
" 162 \n",
" 156 \n",
" 155 \n",
" 157 \n",
" 160 \n",
" 153 \n",
" 147 \n",
" 142 \n",
" 143 \n",
" 142 \n",
" 150 \n",
" 151 \n",
" 161 \n",
" 167 \n",
" 201 \n",
" 172 \n",
" 169 \n",
" 167 \n",
" 172 \n",
" 173 \n",
" 173 \n",
" 170 \n",
" 168 \n",
" 171 \n",
" 146 \n",
" 171 \n",
" 169 \n",
" 164 \n",
" 144 \n",
" 133 \n",
" 137 \n",
" 162 \n",
" 163 \n",
" 155 \n",
" 144 \n",
" ... \n",
" 153 \n",
" 149 \n",
" 151 \n",
" 144 \n",
" 167 \n",
" 168 \n",
" 171 \n",
" 175 \n",
" 169 \n",
" 163 \n",
" 169 \n",
" 188 \n",
" 159 \n",
" 152 \n",
" 152 \n",
" 153 \n",
" 156 \n",
" 154 \n",
" 148 \n",
" 147 \n",
" 157 \n",
" 168 \n",
" 175 \n",
" 175 \n",
" 163 \n",
" 149 \n",
" 166 \n",
" 179 \n",
" 188 \n",
" 177 \n",
" 179 \n",
" 172 \n",
" 160 \n",
" 175 \n",
" 161 \n",
" 151 \n",
" 161 \n",
" 170 \n",
" 154 \n",
" 5 \n",
" \n",
" \n",
" train7695.jpg \n",
" 0 \n",
" 0 \n",
" 0 \n",
" 1 \n",
" 2 \n",
" 2 \n",
" 2 \n",
" 2 \n",
" 2 \n",
" 3 \n",
" 4 \n",
" 19 \n",
" 38 \n",
" 56 \n",
" 70 \n",
" 85 \n",
" 96 \n",
" 107 \n",
" 115 \n",
" 123 \n",
" 125 \n",
" 130 \n",
" 132 \n",
" 135 \n",
" 135 \n",
" 135 \n",
" 139 \n",
" 140 \n",
" 138 \n",
" 137 \n",
" 135 \n",
" 133 \n",
" 130 \n",
" 127 \n",
" 125 \n",
" 120 \n",
" 114 \n",
" 104 \n",
" 93 \n",
" 80 \n",
" ... \n",
" 151 \n",
" 154 \n",
" 158 \n",
" 159 \n",
" 161 \n",
" 161 \n",
" 160 \n",
" 161 \n",
" 163 \n",
" 163 \n",
" 162 \n",
" 162 \n",
" 162 \n",
" 162 \n",
" 160 \n",
" 158 \n",
" 156 \n",
" 153 \n",
" 151 \n",
" 147 \n",
" 143 \n",
" 138 \n",
" 133 \n",
" 127 \n",
" 119 \n",
" 107 \n",
" 93 \n",
" 74 \n",
" 55 \n",
" 30 \n",
" 9 \n",
" 2 \n",
" 2 \n",
" 2 \n",
" 1 \n",
" 1 \n",
" 1 \n",
" 0 \n",
" 0 \n",
" 1 \n",
" \n",
" \n",
"
\n",
"7696 rows × 3137 columns
\n",
""
],
"text/plain": [
" 0 1 2 3 4 ... 3132 3133 3134 3135 label\n",
"image ... \n",
"train0.jpg 165 166 174 174 175 ... 69 79 90 78 0\n",
"train1.jpg 27 44 61 78 96 ... 33 13 2 1 1\n",
"train2.jpg 0 0 0 0 0 ... 0 0 0 0 1\n",
"train3.jpg 197 210 204 199 206 ... 199 196 196 197 2\n",
"train4.jpg 128 119 133 115 109 ... 132 134 131 123 1\n",
"... ... ... ... ... ... ... ... ... ... ... ...\n",
"train7691.jpg 192 189 187 188 193 ... 177 180 181 181 4\n",
"train7692.jpg 0 0 0 0 0 ... 0 0 0 0 3\n",
"train7693.jpg 96 97 100 105 110 ... 188 189 188 170 4\n",
"train7694.jpg 116 98 142 158 168 ... 151 161 170 154 5\n",
"train7695.jpg 0 0 0 1 2 ... 1 1 0 0 1\n",
"\n",
"[7696 rows x 3137 columns]"
]
},
"metadata": {
"tags": []
},
"execution_count": 6
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "mI2aTsIydoJ7",
"colab_type": "code",
"colab": {}
},
"source": [
"for i in range(23):\n",
" po=po.append({'current':df.at[i,\"Current 2\"],'load':df.at[i,\"P_L 2\"],'result':2,'Time':df.at[i,\"Time\"]},ignore_index=True)"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "6UzQk6EOdq3Q",
"colab_type": "code",
"colab": {}
},
"source": [
"for i in range(23):\n",
" po=po.append({'current':df.at[i,\"Current 3\"],'load':df.at[i,\"P_L 3\"],'result':3,'Time':df.at[i,\"Time\"]},ignore_index=True)"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "DjyG5rm2dz2m",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "4ba00cec-1721-4da0-e0f4-09f6e2a0878a"
},
"source": [
"for i in range(23):\n",
" po=po.append({'current':df.at[i,\"Current Ideal\"],'load':df.at[i,\"P_L Ideal\"],'result':0,'Time':df.at[i,\"Time\"]},ignore_index=True)"
],
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"text": [
"Found 8490 images belonging to 7 classes.\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "r-5cNtPCd2YG",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 122
},
"outputId": "8ad1e5ba-02c1-4bb2-b69e-93516aaabf3a"
},
"source": [
"po"
],
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow_core/python/ops/resource_variable_ops.py:1630: calling BaseResourceVariable.__init__ (from tensorflow.python.ops.resource_variable_ops) with constraint is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"If using Keras pass *_constraint arguments to layers.\n",
"Downloading data from https://github.com/fchollet/deep-learning-models/releases/download/v0.6/mobilenet_1_0_224_tf.h5\n",
"17227776/17225924 [==============================] - 3s 0us/step\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "t00qelT1d6lX",
"colab_type": "code",
"colab": {}
},
"source": [
"po = pd.concat([po,pd.get_dummies(po['Time'], prefix='Time',dummy_na=True)],axis=1).drop(['Time'],axis=1)\n"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "GtP2JRm5eBDI",
"colab_type": "code",
"colab": {}
},
"source": [
"po"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "JU9SttS7eC1y",
"colab_type": "code",
"colab": {}
},
"source": [
"poo=po.values"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "6YoYMY0heEkG",
"colab_type": "code",
"colab": {}
},
"source": [
"yy=poo[:,2]\n",
"po.drop(['result'],axis=\"columns\",inplace=True)"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "xQnkBOb_eGou",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 360
},
"outputId": "788eb09f-38c6-4068-e3a0-bcf76239f1ea"
},
"source": [
"XX=poo[:,:]\n"
],
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"text": [
"Epoch 1/30\n",
"119/770 [===>..........................] - ETA: 42:32 - loss: 2.5548 - acc: 0.3437"
],
"name": "stdout"
},
{
"output_type": "error",
"ename": "KeyboardInterrupt",
"evalue": "ignored",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mhistory\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmodel\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfit_generator\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtrain_batches\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msteps_per_epoch\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mtrain_steps\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mclass_weight\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mclass_weight\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mepochs\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m30\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mverbose\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;32m/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/keras/engine/training.py\u001b[0m in \u001b[0;36mfit_generator\u001b[0;34m(self, generator, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, validation_freq, class_weight, max_queue_size, workers, use_multiprocessing, shuffle, initial_epoch)\u001b[0m\n\u001b[1;32m 1294\u001b[0m \u001b[0mshuffle\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mshuffle\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1295\u001b[0m \u001b[0minitial_epoch\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0minitial_epoch\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1296\u001b[0;31m steps_name='steps_per_epoch')\n\u001b[0m\u001b[1;32m 1297\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1298\u001b[0m def evaluate_generator(self,\n",
"\u001b[0;32m/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/keras/engine/training_generator.py\u001b[0m in \u001b[0;36mmodel_iteration\u001b[0;34m(model, data, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, validation_freq, class_weight, max_queue_size, workers, use_multiprocessing, shuffle, initial_epoch, mode, batch_size, steps_name, **kwargs)\u001b[0m\n\u001b[1;32m 219\u001b[0m \u001b[0mstep\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 220\u001b[0m \u001b[0;32mwhile\u001b[0m \u001b[0mstep\u001b[0m \u001b[0;34m<\u001b[0m \u001b[0mtarget_steps\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 221\u001b[0;31m \u001b[0mbatch_data\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0m_get_next_batch\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mgenerator\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 222\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mbatch_data\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 223\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mis_dataset\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/keras/engine/training_generator.py\u001b[0m in \u001b[0;36m_get_next_batch\u001b[0;34m(generator)\u001b[0m\n\u001b[1;32m 361\u001b[0m \u001b[0;34m\"\"\"Retrieves the next batch of input data.\"\"\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 362\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 363\u001b[0;31m \u001b[0mgenerator_output\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnext\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mgenerator\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 364\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mStopIteration\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0merrors\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mOutOfRangeError\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 365\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/usr/local/lib/python3.6/dist-packages/tensorflow_core/python/keras/utils/data_utils.py\u001b[0m in \u001b[0;36mget\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 781\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 782\u001b[0m \u001b[0;32mwhile\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mis_running\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 783\u001b[0;31m \u001b[0minputs\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mqueue\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mblock\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 784\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mqueue\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtask_done\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 785\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0minputs\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/usr/lib/python3.6/multiprocessing/pool.py\u001b[0m in \u001b[0;36mget\u001b[0;34m(self, timeout)\u001b[0m\n\u001b[1;32m 636\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 637\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mget\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtimeout\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 638\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mwait\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtimeout\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 639\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mready\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 640\u001b[0m \u001b[0;32mraise\u001b[0m \u001b[0mTimeoutError\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/usr/lib/python3.6/multiprocessing/pool.py\u001b[0m in \u001b[0;36mwait\u001b[0;34m(self, timeout)\u001b[0m\n\u001b[1;32m 633\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 634\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mwait\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtimeout\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 635\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_event\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mwait\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtimeout\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 636\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 637\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mget\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtimeout\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/usr/lib/python3.6/threading.py\u001b[0m in \u001b[0;36mwait\u001b[0;34m(self, timeout)\u001b[0m\n\u001b[1;32m 549\u001b[0m \u001b[0msignaled\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_flag\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 550\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0msignaled\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 551\u001b[0;31m \u001b[0msignaled\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_cond\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mwait\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtimeout\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 552\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0msignaled\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 553\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/usr/lib/python3.6/threading.py\u001b[0m in \u001b[0;36mwait\u001b[0;34m(self, timeout)\u001b[0m\n\u001b[1;32m 293\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;31m# restore state no matter what (e.g., KeyboardInterrupt)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 294\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mtimeout\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 295\u001b[0;31m \u001b[0mwaiter\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0macquire\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 296\u001b[0m \u001b[0mgotit\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mTrue\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 297\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mKeyboardInterrupt\u001b[0m: "
]
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "LP99lYcEeIhq",
"colab_type": "code",
"colab": {}
},
"source": [
"def neural_net():\n",
" model = Sequential()\n",
" model.add(Dense(16, input_dim=27, kernel_initializer='normal', activation='relu'))\n",
" model.add(Dropout(0.2))\n",
" model.add(Dense(8, kernel_initializer='normal', activation='relu'))\n",
" model.add(Dense(4, kernel_initializer='normal',activation='softmax'))\n",
" model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])\n",
" return model"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "hZb562n-yJzJ",
"colab_type": "code",
"colab": {}
},
"source": [
"from keras.utils import np_utils"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "aVL4rZZDyeuy",
"colab_type": "code",
"colab": {}
},
"source": [
"encoder = LabelEncoder()\n",
"encoder.fit(yy)\n",
"encoded_Y = encoder.transform(yy)\n",
"dummy_y = np_utils.to_categorical(encoded_Y)"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "S9LaHICzygN1",
"colab_type": "code",
"colab": {}
},
"source": [
"dummy_y"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "i0oRbw7uyh8N",
"colab_type": "code",
"colab": {}
},
"source": [
"dummy_XX=XX"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "tLdxBr17ylks",
"colab_type": "code",
"colab": {}
},
"source": [
"scaler=StandardScaler()"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "XLkUP8O-ypti",
"colab_type": "code",
"colab": {}
},
"source": [
"dummy_XX=scaler.fit_transform(dummy_XX)"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "EQCCA6QkyrvO",
"colab_type": "code",
"colab": {}
},
"source": [
"dummy_XX"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "w-snfrWbytzP",
"colab_type": "code",
"colab": {}
},
"source": [
"mm=neural_net()\n",
"history=mm.fit(XX,dummy_y,epochs=500)"
],
"execution_count": null,
"outputs": []
}
]
}