Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert boolean features to float in training data #417

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
"metadata": {},
"source": [
"## Splitting the data into features and targets (labels)\n",
"Now, as a final step before the training, we'll split the data into features (X) and targets (y)."
"Now, as a final step before the training, we'll split the data into features (X) and targets (y). We must also convert the values in the one hot encoded ranks from a boolean (true or false) to a float (1 or 0)."
]
},
{
Expand All @@ -201,6 +201,7 @@
"targets = train_data['admit']\n",
"features_test = test_data.drop('admit', axis=1)\n",
"targets_test = test_data['admit']\n",
"features = features.astype(float)\n",
"\n",
"print(features[:10])\n",
"print(targets[:10])"
Expand Down Expand Up @@ -324,7 +325,7 @@
"outputs": [],
"source": [
"# Calculate accuracy on test data\n",
"test_out = sigmoid(np.dot(features_test, weights))\n",
"test_out = sigmoid(np.dot(features_test.astype(float), weights))\n",
"predictions = test_out > 0.5\n",
"accuracy = np.mean(predictions == targets_test)\n",
"print(\"Prediction accuracy: {:.3f}\".format(accuracy))"
Expand Down