shallow-training/nncw.ipynb

1 line
904 KiB
Plaintext
Raw Normal View History

{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"nncw.ipynb","provenance":[],"collapsed_sections":[],"authorship_tag":"ABX9TyNPFjqFKQvhfmqoF4DC5qfM"},"kernelspec":{"name":"python3","display_name":"Python 3"},"accelerator":"GPU"},"cells":[{"cell_type":"code","metadata":{"id":"TGIxH9Tmt5zp","executionInfo":{"status":"ok","timestamp":1615299519974,"user_tz":0,"elapsed":2898,"user":{"displayName":"Andy Pack","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GjA4K4ZhdArHXAFbAGr4n0aCv2HmyUpx4cy6zcUq34=s64","userId":"16615063155528027547"}}},"source":["import numpy as np\r\n","import pandas as pd\r\n","import tensorflow as tf\r\n","tf.get_logger().setLevel('ERROR')\r\n","\r\n","import matplotlib.pyplot as plt\r\n","import matplotlib as mpl\r\n","import seaborn as sns\r\n","\r\n","from sklearn.model_selection import train_test_split\r\n","\r\n","fig_dpi = 200\r\n","\r\n","%load_ext tensorboard"],"execution_count":1,"outputs":[]},{"cell_type":"markdown","metadata":{"id":"fksHv5rXACEX"},"source":["# Neural Network Training\r\n"]},{"cell_type":"markdown","metadata":{"id":"l4zqVWyRAM0Z"},"source":["## Load Dataset"]},{"cell_type":"code","metadata":{"colab":{"base_uri":"https://localhost:8080/","height":297},"id":"Hj5l_tdZuYh7","executionInfo":{"status":"ok","timestamp":1615299519985,"user_tz":0,"elapsed":2882,"user":{"displayName":"Andy Pack","photoUrl":"https://lh3.googleusercontent.com/a-/AOh14GjA4K4ZhdArHXAFbAGr4n0aCv2HmyUpx4cy6zcUq34=s64","userId":"16615063155528027547"}},"outputId":"da87c6c3-4d35-4306-e563-51b568afd623"},"source":["data = pd.read_csv('features.csv', header=None).T\r\n","data.columns = ['Clump thickness', 'Uniformity of cell size', 'Uniformity of cell shape', 'Marginal adhesion', 'Single epithelial cell size', 'Bare nuclei', 'Bland chomatin', 'Normal nucleoli', 'Mitoses']\r\n","labels = pd.read_csv('targets.csv', header=None).T\r\n","labels.columns = ['Benign', 'Malignant']\r\n","data.describe()"],"execution_count":2,"outputs":[{"output_type":"execute_result","data":{"text/html":["<div>\n","<style scoped>\n"," .dataframe tbody tr th:only-of-type {\n"," vertical-align: middle;\n"," }\n","\n"," .dataframe tbody tr th {\n"," vertical-align: top;\n"," }\n","\n"," .dataframe thead th {\n"," text-align: right;\n"," }\n","</style>\n","<table border=\"1\" class=\"dataframe\">\n"," <thead>\n"," <tr style=\"text-align: right;\">\n"," <th></th>\n"," <th>Clump thickness</th>\n"," <th>Uniformity of cell size</th>\n"," <th>Uniformity of cell shape</th>\n"," <th>Marginal adhesion</th>\n"," <th>Single epithelial cell size</th>\n"," <th>Bare nuclei</th>\n"," <th>Bland chomatin</th>\n"," <th>Normal nucleoli</th>\n"," <th>Mitoses</th>\n"," </tr>\n"," </thead>\n"," <tbody>\n"," <tr>\n"," <th>count</th>\n"," <td>699.000000</td>\n"," <td>699.000000</td>\n"," <td>699.000000</td>\n"," <td>699.000000</td>\n"," <td>699.000000</td>\n"," <td>699.000000</td>\n"," <td>699.000000</td>\n"," <td>699.000000</td>\n"," <td>699.000000</td>\n"," </tr>\n"," <tr>\n"," <th>mean</th>\n"," <td>0.441774</td>\n"," <td>0.313448</td>\n"," <td>0.320744</td>\n"," <td>0.280687</td>\n"," <td>0.321602</td>\n"," <td>0.354363</td>\n"," <td>0.343777</td>\n"," <td>0.286695</td>\n"," <td>0.158941</td>\n"," </tr>\n"," <tr>\n"," <th>std</th>\n"," <td>0.281574</td>\n"," <td>0.305146</td>\n"," <td>0.297191</td>\n"," <td>0.285538</td>\n"," <td>0.221430</td>\n"," <td>0.360186</td>\n"," <td>0.243836</td>\n"," <td>0.305363</td>\n"," <td>0.171508</td>\n"," </tr>\n"," <tr>\n"," <th>min</th>\n"," <td>0.100000</td>\n"," <td>0.100000</td>\n"," <td>0.100000</td>\n"," <td>0.100000</td>\n"," <td>0.100000</td>\n"," <td>0.100000</td>\n"," <td>0.100000</td>\n"," <td>0.100000</td>\n"," <td>0.100000</td>\n"," </tr>\n"," <tr>\n"," <th>25%</th>\n","