Fix incorrect shapes for accuracy computation.

This commit is contained in:
Ryan Curtin
2019-05-16 21:22:55 -04:00
parent c2399b78a7
commit 86e2c5aa61
+2 -1
View File
@@ -99,7 +99,8 @@ output = mlpack.random_forest(input_model=random_forest,
# Now print the accuracy. The 'probabilities' output could also be used
# to generate an ROC curve.
correct = np.sum(output['predictions'] == test_labels)
correct = np.sum(
output['predictions'] == np.reshape(test_labels, (test_labels.shape[0],)))
print(str(correct) + ' correct out of ' + str(len(test_labels)) + ' (' +
str(100 * float(correct) / float(len(test_labels))) + '%).')
@endcode