Learn Before
Cross-Validation in scikit-learn
from sklearn.model_selection import cross_val_score cv_scores = cross_val_score(clf, X, y, cv)
clf is the model we want to evaluate, X is the data set, y is the corresponding ground truth target labels or values, cv is the number of folds.
By default, cross_val_score does threefold cross-validation, which will return a list of three accuracy scores, one for each of the three folds. We can take the mean value as the accuracy of the model on average.
0
3
Tags
Helpful Scikit-Learn functions
Data Science
Related
sklearn.preprocessing.OneHotEncoder
sklearn.neighbors.KNeighborsClassifier
sklearn.dummy.DummyClassifier
sklearn.preprocessing.LabelEncoder
Train Test Split Function
sklearn.datasets.make_regression
sklearn.datasets.make_friedman1
sklearn.datasets.make_classification
sklearn.svm.SVC
sklearn.tree.DecisionTreeClassifier
sklearn.ensemble.RandomForestClassifier
sklearn.dummy.DummyRegressor
sklearn.model_selection.GridSearchCV
sklearn.ensemble.RandomForestRegressor
Cross-Validation in scikit-learn