November 2017
Intermediate to advanced
374 pages
10h 19m
English
To make a scorer, you need:
Before passing the SVR regressor to the cross-validation, make a scorer by supplying two elements:
from sklearn.metrics import make_scorer
#Only works for this iris example with targets 0 and 1def for_scorer(y_test, orig_y_pred): y_pred = np.rint(orig_y_pred).astype(np.int) #rounds prediction to the nearest integer return accuracy_score(y_test, y_pred)
The np.rint function rounds off the prediction to the nearest integer, hopefully one of the targets, 0 or 1. The ...
Read now
Unlock full access