Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from sklearn.svm import SVR
- from sklearn.model_selection import cross_validate
- from sklearn.model_selection import KFold
- svr_rbf = SVR(kernel='rbf')
- scoring = ['neg_mean_absolute_error', 'neg_mean_squared_error', 'r2']
- scores = cross_validate(estimator, X, y, cv=KFold(10, shuffle=True), scoring=scoring, return_train_score=False)
- score = -1 * scores['test_neg_mean_absolute_error']
- print("MAE: %.4f (%.4f)" % (score.mean(), score.std()))
- score = -1 * scores['test_neg_mean_squared_error']
- print("MSE: %.4f (%.4f)" % (score.mean(), score.std()))
- score = scores['test_r2']
- print("R^2: %.4f (%.4f)" % (score.mean(), score.std()))
Add Comment
Please, Sign In to add comment