Created
July 10, 2019 20:59
-
-
Save risenW/d39732c645a70fddeb3f80c02993c6f8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.metrics import mean_absolute_error | |
from sklearn.model_selection import KFold, cross_val_score | |
# def get_mae(pred, target): | |
# return mean_absolute_error(true, pred) | |
def cross_validate(model, nfolds, feats, targets): | |
score = -1 * (cross_val_score(model, feats, targets, cv=nfolds, scoring='neg_mean_absolute_error')) | |
return np.mean(score) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment