I'm getting a warning, see below, on upon running the code. However, the result will print the accuracy1, precision1, and recall1. How to avoid the warning? I'm using python 2.7.
warning : UndefinedMetricWarning: Precision is ill-defined and being set to 0.0 due to no predicted samples. 'precision', 'predicted', average, warn_for)
acc = []
pre = []
recall = []
for i in range(iters):
features_train, features_test, labels_train, labels_test = \
train_test_split(features, labels, test_size = 0.3, random_state = i)
grid_search.fit(features_train, labels_train)
predicts = grid_search.predict(features_test)
acc = acc + [accuracy_score(labels_test, predicts)]
pre = pre + [precision_score(labels_test, predicts)]
recall = recall + [recall_score(labels_test, predicts)]
print "accuracy1: {}".format(np.mean(acc))
print "precision1: {}".format(np.mean(pre))
print "recall1: {}".format(np.mean(recall))
best_params = grid_search.best_estimator_.get_params()
for param_name in params.keys():
print("%s = %r, " % (param_name, best_params[param_name]))