{ "cells": [ { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.8705440900562852\n", "[[47 0 0 0 0 0 0 0 0 0 0 0 0]\n", " [ 0 39 0 0 0 0 0 0 0 0 0 0 0]\n", " [ 0 1 48 0 0 0 0 0 0 0 0 0 0]\n", " [ 0 0 0 27 1 6 0 0 0 0 0 0 0]\n", " [ 0 0 0 0 37 4 0 0 0 0 0 0 0]\n", " [ 0 0 0 0 0 33 0 0 0 0 0 0 0]\n", " [ 0 0 0 0 0 1 34 0 0 3 0 0 0]\n", " [ 0 0 0 0 0 2 1 26 0 3 0 2 0]\n", " [ 0 0 0 0 0 8 0 0 43 1 0 0 0]\n", " [ 0 0 0 0 1 2 9 0 0 31 0 1 0]\n", " [ 0 0 0 0 1 9 0 0 1 9 12 6 0]\n", " [ 0 0 0 0 0 3 0 0 0 0 0 39 0]\n", " [ 0 0 0 0 0 0 0 1 0 16 0 3 23]]\n", " precision recall f1-score support\n", "\n", " 0 1.00 1.00 1.00 47\n", " 1 0.97 1.00 0.99 39\n", " 2 1.00 0.98 0.99 49\n", " 3 1.00 0.79 0.89 34\n", " 4 0.93 0.90 0.91 41\n", " 5 0.49 1.00 0.65 33\n", " 6 0.77 0.89 0.83 38\n", " 7 0.96 0.76 0.85 34\n", " 8 0.98 0.83 0.90 52\n", " 9 0.49 0.70 0.58 44\n", " 10 1.00 0.32 0.48 38\n", " 11 0.76 0.93 0.84 42\n", " 12 1.00 0.53 0.70 43\n", "\n", " accuracy 0.82 534\n", " macro avg 0.87 0.82 0.82 534\n", "weighted avg 0.88 0.82 0.82 534\n", "\n" ] } ], "source": [ "import sklearn\n", "import time\n", "from sklearn import metrics\n", "from sklearn.neural_network import MLPClassifier\n", "from sklearn.utils import shuffle\n", "from sklearn.externals import joblib\n", "from sklearn.model_selection import train_test_split\n", "import pandas as pd\n", "import sys, os\n", "import numpy as np \n", "from sklearn.metrics import classification_report, confusion_matrix \n", "#df = pd.read_excel (r'C:\\Users\\pc\\Documents\\IGfeatures\\full\\ig13.xlsx')\n", "#dfn=shuffle(df)#shuffle\n", "#dfn.to_excel(r'C:\\Users\\pc\\Documents\\IGfeatures\\full\\shuffle13.xlsx')\n", "dfs=pd.read_excel(r'C:\\Users\\pc\\Documents\\IGfeatures\\full\\shuffle13.xlsx')\n", "X=dfs.iloc[:,:-1]\n", "Y=dfs.iloc[:,-1]\n", "X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.2,shuffle=False)\n", "mlp = MLPClassifier(hidden_layer_sizes=(373), max_iter=10000) \n", "mlp.fit(X_train,Y_train) \n", "result=mlp.score(X_train,Y_train)\n", "print(result)\n", "predictions = mlp.predict(X_test) \n", "print(confusion_matrix(Y_test,predictions)) \n", "print(classification_report(Y_test,predictions)) " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "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.6" } }, "nbformat": 4, "nbformat_minor": 4 }