cross validation python

Do you want to know the information about “cross validation python”. If yes, you’re in the correct article.

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
Cross-validation is a resampling procedure used to evaluate machine learning models on a limited data sample. The procedure has a single parameter called k that refers to the number of groups that a given data sample is to be split into. As such, the procedure is often called k-fold cross-validation.

Final Words

I hope this article helps you to know about “cross validation python”. If you have any queries regarding this post please let us know via the comment section. Share this post with your friends and family via social networks.

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coder Diksha. Here, I post about programming to help developers.

Share on:

Leave a Comment