Last active
October 16, 2017 23:31
-
-
Save lucaspg96/f25b52c694e6df75b0819dbd0680649d to your computer and use it in GitHub Desktop.
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
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 33, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"%matplotlib inline\n", | |
"import matplotlib.pyplot as plt\n", | |
"import pandas as pd\n", | |
"import numpy as np\n", | |
"from sklearn.neighbors import KNeighborsClassifier as Knn " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 15, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"train = pd.read_csv(\"train.csv\",index_col=0)\n", | |
"test = pd.read_csv(\"test.csv\",index_col=0)\n", | |
"\n", | |
"train_size = len(train)\n", | |
"test_size = len(test)\n", | |
"\n", | |
"data = pd.concat([train,test])\n", | |
"data = data.where((pd.notnull(data)), 0)\n", | |
"\n", | |
"for f in [\"Sex\",\"Embarked\"]:\n", | |
" data[f] = data[f].astype('category')\n", | |
" data[f] = data[f].cat.codes\n", | |
" \n", | |
"train = data[:train_size]\n", | |
"test = data[train_size:]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 22, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"Y_train = train[\"Survived\"]\n", | |
"Y_test = test[\"Survived\"]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 21, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style>\n", | |
" .dataframe thead tr:only-child th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: left;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>Pclass</th>\n", | |
" <th>Sex</th>\n", | |
" <th>Age</th>\n", | |
" <th>SibSp</th>\n", | |
" <th>Parch</th>\n", | |
" <th>Fare</th>\n", | |
" <th>Embarked</th>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>PassengerId</th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" <th></th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>1</th>\n", | |
" <td>3</td>\n", | |
" <td>1</td>\n", | |
" <td>22.0</td>\n", | |
" <td>1</td>\n", | |
" <td>0</td>\n", | |
" <td>7.2500</td>\n", | |
" <td>3</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>2</th>\n", | |
" <td>1</td>\n", | |
" <td>0</td>\n", | |
" <td>38.0</td>\n", | |
" <td>1</td>\n", | |
" <td>0</td>\n", | |
" <td>71.2833</td>\n", | |
" <td>1</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>3</td>\n", | |
" <td>0</td>\n", | |
" <td>26.0</td>\n", | |
" <td>0</td>\n", | |
" <td>0</td>\n", | |
" <td>7.9250</td>\n", | |
" <td>3</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>4</th>\n", | |
" <td>1</td>\n", | |
" <td>0</td>\n", | |
" <td>35.0</td>\n", | |
" <td>1</td>\n", | |
" <td>0</td>\n", | |
" <td>53.1000</td>\n", | |
" <td>3</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>5</th>\n", | |
" <td>3</td>\n", | |
" <td>1</td>\n", | |
" <td>35.0</td>\n", | |
" <td>0</td>\n", | |
" <td>0</td>\n", | |
" <td>8.0500</td>\n", | |
" <td>3</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" Pclass Sex Age SibSp Parch Fare Embarked\n", | |
"PassengerId \n", | |
"1 3 1 22.0 1 0 7.2500 3\n", | |
"2 1 0 38.0 1 0 71.2833 1\n", | |
"3 3 0 26.0 0 0 7.9250 3\n", | |
"4 1 0 35.0 1 0 53.1000 3\n", | |
"5 3 1 35.0 0 0 8.0500 3" | |
] | |
}, | |
"execution_count": 21, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"features = [\"Pclass\",\"Sex\",\"Age\",\"SibSp\",\"Parch\",\"Fare\",\"Embarked\"]\n", | |
"X_train = train.get(features)\n", | |
"X_test = test.get(features)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 60, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"scores = []\n", | |
"ks = range(1,len(X_train))\n", | |
"n_ks = len(ks)\n", | |
"\n", | |
"for k in ks:\n", | |
"# print(k,end=\",\")\n", | |
" knn = Knn(n_neighbors=k)\n", | |
" knn.fit(X_train,Y_train)\n", | |
" scores.append(knn.score(X_test,Y_test))" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 61, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEKCAYAAAD9xUlFAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAH2RJREFUeJzt3XmUVOWd//H3B1xQcUFEZFNIghpcENOijhmjooIrCXEB\n4xbNeNw1Jm6JmV8mMVExyUQHRoMKrmjUoJKJS9S4GyMNEiIukWBUcANXwKAC398ft6iu7q7qrm76\n1tL1eZ3Th3uf+9Str/dIf7jb8ygiMDMzA+hS7gLMzKxyOBTMzCzLoWBmZlkOBTMzy3IomJlZlkPB\nzMyyHApmZpblUDAzsyyHgpmZZa1V7gLaar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TqrWSVyKFinJmkEcCVwQES8lqfLAuCHbdlnRHwnIl7oiPraqtpH4LTK51CwTkvSnsA1\nwMER8Y8C3f4P2C7njd7cz+8v6c+SZkm6IzOGFJIelVSXWT4xcxbyrKRrJE3I2cWekp6WNL/JWcNG\nkv6QGX//akldMvsaJ+lvmbOVy3LqWCrpl5L+Cuwu6VIlc2TMkfSLNTpIZk04FKyzWhe4G/h6RLzU\nQr9VwHiSN72zJG0GXATsGxE7A/XAOU369AV+RDJXxR7Atk323Qf4KnAwyVvTqw0neYt4CPBFYExm\nX5cB+wA7AbtIWj088wbAXyJi9VwH3wC2i4gdgYtbPgxmbeNQsM7qc+Bp4MQi+k4lGe9mUE7bbiS/\ntJ/KDBFyHLBVk88NBx6LiPczg6fd0WT73RGxKnOpqXdO+7OZuT1WAreSBMcuwKOZgdhWALeQzHMA\nsJJkUEOAj4DlwHWSxgCfFPHfZ1Y0h4J1VqtIxqcZLukHLXXM/BL+JXB+TrOAByNip8zPkIgoJmBy\nfdpkf9mvbFpCK/tZvno8nUytw0lGMz0YuL+NNZm1yKFgnVZEfEIyy9q3MgOZteR6kmGTe2XWnwH2\nkPQlAEkbSNq6yWdmAF+T1CMzS9c3iyxteGbE3i7AkcCTJCNrfk3SZpmbyeOAx5p+MHNfY+OIuBf4\nLsn0mWYdpiZGSbXaFRHvSxoFPC5pUUTkHTI9Ij6TdCXJfMVExCJJxwO3Slo30+0i4O85n1ko6eck\nv9DfB14iubzTmhnABOBLwCPAXRGxStIFmXUBf4iIe/J8dkPgHkndMv3OydPHrN08SqrZGpDUPSKW\nZs4U7iIZlv2uctdl1l6+fGS2Zn6cuRH9PPAqyRNPZlXLZwpmZpblMwUzM8tyKJiZWZZDwczMshwK\nZmaW5VAwM7Msh4KZmWX9f+EGCk8p+SQPAAAAAElFTkSuQmCC\n", | |
"text/plain": [ | |
"<matplotlib.figure.Figure at 0x7f0e37bd1208>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"fig,ax = plt.subplots()\n", | |
"ax.plot(ks,scores,'b',linewidth=3)\n", | |
"ax.set_ylabel('Accuracy')\n", | |
"ax.set_xlabel('K Neighbors')\n", | |
"# fig.set_figwidth(100)\n", | |
"# fig.set_figheight(30)\n", | |
"plt.show()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": true | |
}, | |
"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.5.3" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment