mirror of
https://github.com/donnemartin/data-science-ipython-notebooks.git
synced 2024-03-22 13:30:56 +08:00
Tweaked slicing indices to use single : instead of ::, which I find more readable. Tweaked Feature: Sex headers.
This commit is contained in:
parent
5bc4d9bef4
commit
a6153e5020
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"metadata": {
|
||||
"name": "",
|
||||
"signature": "sha256:708d730926b0a00b95815375c1e8d7f632ca75b748195364102868ffc231fc0c"
|
||||
"signature": "sha256:46dbdb2807e4db85f0d0d4ed570394551bba3d8cbcdb541f8dd2115388981545"
|
||||
},
|
||||
"nbformat": 3,
|
||||
"nbformat_minor": 0,
|
||||
|
@ -26,7 +26,7 @@
|
|||
"* Setup Imports and Variables\n",
|
||||
"* Explore the Data\n",
|
||||
"* Feature: Passenger Classes\n",
|
||||
"* Feature: Sex (Gender)\n",
|
||||
"* Feature: Sex\n",
|
||||
"* Feature: Embarked\n",
|
||||
"* Feature: Age\n",
|
||||
"* Feature: Family Size\n",
|
||||
|
@ -854,7 +854,7 @@
|
|||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Feature: Sex (Gender)"
|
||||
"## Feature: Sex"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -2403,10 +2403,10 @@
|
|||
"collapsed": false,
|
||||
"input": [
|
||||
"# Training data (features), skip the first column 'Survived'\n",
|
||||
"training_input = train_data[0::, 1::]\n",
|
||||
"training_input = train_data[:, 1:]\n",
|
||||
"\n",
|
||||
"# 'Survived' column values\n",
|
||||
"target_values = train_data[0::, 0]\n",
|
||||
"target_values = train_data[:, 0]\n",
|
||||
"\n",
|
||||
"# Fit the model to our training data\n",
|
||||
"forest = forest.fit(training_input, target_values)"
|
||||
|
@ -2556,7 +2556,7 @@
|
|||
"collapsed": false,
|
||||
"input": [
|
||||
"# Test data (features), skip the first column 'PassengerId'\n",
|
||||
"test_input = test_data[0::, 1::]\n",
|
||||
"test_input = test_data[:, 1:]\n",
|
||||
"\n",
|
||||
"# Predict the Survival values for the test data\n",
|
||||
"output = forest.predict(test_input)"
|
||||
|
@ -2584,8 +2584,9 @@
|
|||
"cell_type": "code",
|
||||
"collapsed": false,
|
||||
"input": [
|
||||
"# Concatenate PassengerId and Survived predictions\n",
|
||||
"result = np.c_[test_data[:, 0].astype(int), output.astype(int)]\n",
|
||||
"df_result = pd.DataFrame(result[:, 0:2], columns=['PassengerId', 'Survived'])\n",
|
||||
"df_result = pd.DataFrame(result[:, :], columns=['PassengerId', 'Survived'])\n",
|
||||
"df_result.head(10)"
|
||||
],
|
||||
"language": "python",
|
||||
|
@ -2659,7 +2660,7 @@
|
|||
],
|
||||
"metadata": {},
|
||||
"output_type": "pyout",
|
||||
"prompt_number": 43,
|
||||
"prompt_number": 61,
|
||||
"text": [
|
||||
" PassengerId Survived\n",
|
||||
"0 892 0\n",
|
||||
|
@ -2675,7 +2676,7 @@
|
|||
]
|
||||
}
|
||||
],
|
||||
"prompt_number": 43
|
||||
"prompt_number": 61
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
|
|
Loading…
Reference in New Issue
Block a user