Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

cross validation python

# SVC: support vector classifier (one of the "built-in" classifiers in scikit-learn)
# X, y: array-like representing input and target variables
# X.shape = (N, num_of_features)
# y.shape = (N, 1) in case of classification problem

from sklearn.model_selection import cross_val_score
clf = svm.SVC(kernel='linear', C=1, random_state=42)
scores = cross_val_score(clf, X, y, cv=5) # 5-fold cross validation
Source by scikit-learn.org #
 
PREVIOUS NEXT
Tagged: #cross #validation #python
ADD COMMENT
Topic
Name
9+7 =