Skip to content

Commit

Permalink
alt solution to one hot encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
cezannec committed Feb 26, 2019
1 parent 839cfae commit 9b6001a
Showing 1 changed file with 18 additions and 1 deletion.
Expand Up @@ -22,6 +22,7 @@
},
"outputs": [],
"source": [
"## One solution\n",
"# Make dummy variables for rank\n",
"one_hot_data = pd.concat([data, pd.get_dummies(data['rank'], prefix='rank')], axis=1)\n",
"\n",
Expand All @@ -32,6 +33,22 @@
"one_hot_data[:10]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"## Alternative solution ##\n",
"# if you're using an up-to-date version of pandas, \n",
"# you can also use selection by columns\n",
"\n",
"# an equally valid solution\n",
"one_hot_data = pd.get_dummies(data, columns=['rank'])"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -83,7 +100,7 @@
},
"outputs": [],
"source": [
"## alternative solution ##\n",
"## Alternative solution ##\n",
"# you could also *only* use y and the output \n",
"# and calculate sigmoid_prime directly from the activated output!\n",
"\n",
Expand Down

1 comment on commit 9b6001a

@CurtisBRO
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for this. Not being a numpy whiz this really helps! I don't understand why you don't include the offset when you normalize the gre and gpa. A gpa of 3 should be normalized to .66 ((3-1)/3) whereas without the offset, a gpa of 3 is .75. Same for gre score.

Please sign in to comment.