more pythonic
"if 'error' in response:\n",
" print (response['error'])\n",
"else:\n",
- " onlineResults = response['predictions']\n",
+ " online_results = response['predictions']\n",
" # convert floats to booleans\n",
- " convertedResponses = [x > 0.5 for x in onlineResults]\n",
+ " converted_responses = [x > 0.5 for x in online_results]\n",
" # Print the first 10 responses\n",
- " for i, response in enumerate(convertedResponses[:5]):\n",
+ " for i, response in enumerate(converted_responses[:5]):\n",
" print('Prediction: {}\\tLabel: {}'.format(response, test_labels[i]))"
]
},
],
"source": [
"actual = pd.Series(test_labels, name='actual')\n",
- "online = pd.Series(convertedResponses, name='online')\n",
+ "online = pd.Series(converted_responses, name='online')\n",
+ "\n",
"pd.crosstab(actual,online)"
]
},
}
],
"source": [
- "localResults = bst.predict(dtest)\n",
- "convertedLocal = [x > 0.5 for x in localResults]\n",
- "local = pd.Series(convertedLocal, name='local')\n",
+ "local_results = bst.predict(dtest)\n",
+ "converted_local = [x > 0.5 for x in local_results]\n",
+ "local = pd.Series(converted_local, name='local')\n",
+ "\n",
"pd.crosstab(actual,local)"
]
},
"identical = 0\n",
"different = 0\n",
"\n",
- "for i in xrange(len(onlineResults)):\n",
- " if onlineResults[i] == localResults[i]:\n",
+ "for i in xrange(len(online_results)):\n",
+ " if online_results[i] == local_results[i]:\n",
" identical += 1\n",
" else:\n",
" different += 1\n",
