Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
校验: titanic.ipynb 中 模型, 预测和解决方案 中的内容
  • Loading branch information
wangyangting authored Dec 6, 2017
commit 915cb961cc69d77ffb3db994190a7f0e7c3f9e8c
130 changes: 102 additions & 28 deletions src/python/getting-started/titanic/titanic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4747,22 +4747,103 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 50,
"metadata": {
"_cell_guid": "1f3cebe0-31af-70b2-1ce4-0fd406bcdfc6",
"_uuid": "79536b2878fa12ceaf3648bfd5bb5de63b903709"
},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'pd' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-1-ae6668fd1576>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m models = pd.DataFrame({\n\u001b[0m\u001b[1;32m 2\u001b[0m 'Model': ['Support Vector Machines', 'KNN', 'Logistic Regression', \n\u001b[1;32m 3\u001b[0m \u001b[0;34m'Random Forest'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'Naive Bayes'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'Perceptron'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;34m'Stochastic Gradient Decent'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'Linear SVC'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m 'Decision Tree'],\n",
"\u001b[0;31mNameError\u001b[0m: name 'pd' is not defined"
]
"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>Model</th>\n",
" <th>Score</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>Random Forest</td>\n",
" <td>86.76</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>Decision Tree</td>\n",
" <td>86.76</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>KNN</td>\n",
" <td>84.74</td>\n",
" </tr>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Support Vector Machines</td>\n",
" <td>83.84</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Logistic Regression</td>\n",
" <td>80.36</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>Stochastic Gradient Decent</td>\n",
" <td>80.02</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>Linear SVC</td>\n",
" <td>79.12</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>Perceptron</td>\n",
" <td>78.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Naive Bayes</td>\n",
" <td>72.28</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Model Score\n",
"3 Random Forest 86.76\n",
"8 Decision Tree 86.76\n",
"1 KNN 84.74\n",
"0 Support Vector Machines 83.84\n",
"2 Logistic Regression 80.36\n",
"6 Stochastic Gradient Decent 80.02\n",
"7 Linear SVC 79.12\n",
"5 Perceptron 78.00\n",
"4 Naive Bayes 72.28"
]
},
"execution_count": 50,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
Expand All @@ -4779,24 +4860,13 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 51,
"metadata": {
"_cell_guid": "28854d36-051f-3ef0-5535-fa5ba6a9bef7",
"_uuid": "a2cda3bdd06c9b6a0cb2c02ca276c049865108fb"
"_uuid": "a2cda3bdd06c9b6a0cb2c02ca276c049865108fb",
"collapsed": true
},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'pd' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-2-02695265a4bb>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m submission = pd.DataFrame({\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0;34m\"PassengerId\"\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mtest_df\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"PassengerId\"\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;34m\"Survived\"\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mY_pred\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m })\n\u001b[1;32m 5\u001b[0m \u001b[0;31m# submission.to_csv('../output/submission.csv', index=False)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mNameError\u001b[0m: name 'pd' is not defined"
]
}
],
"outputs": [],
"source": [
"submission = pd.DataFrame({\n",
" \"PassengerId\": test_df[\"PassengerId\"],\n",
Expand All @@ -4812,7 +4882,11 @@
"_uuid": "b8e1264e98af00d119e07a776643e6ce08b59666"
},
"source": [
"我们提交给Kaggle的结果在6082个结果中获得第3883名。当竞赛正在进行时,这个结果是具有指导意义的。结果只占提交数据集的一部分。我们的第一次尝试是不错的。欢迎任何提高我们的分数的建议。"
"我们提交给竞赛网站 Kaggle 的比赛结果在 6,082 个参赛作品中获得 3883 名.\n",
"当竞赛正在进行时,这个结果是具有指导意义的.\n",
"这个结果只占提交数据集的一部分.\n",
"对我们的第一次尝试是不错的.\n",
"欢迎任何提高我们的分数的建议."
]
},
{
Expand All @@ -4833,7 +4907,7 @@
}
],
"metadata": {
"_change_revision": 0,
"_change_revision": 0.0,
"_is_fork": false,
"kernelspec": {
"display_name": "Python 3",
Expand All @@ -4850,7 +4924,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.2"
"version": "3.6.3"
}
},
"nbformat": 4,
Expand Down