Go to the profile of  Paras Patidar
Paras Patidar
I am working on Machine Learning, Python and Django.
1 min read

Cross-Validation in Machine Learning

Cross-validation is used to test how effective our machine learning model performs. Our Model's performance is dependent on the way we split the data.

Cross-Validation in Machine Learning

Cross-validation is used to test how effective our machine learning model performs. Our Model's performance is dependent on the way we split the data.

Cross-validation is a technique to evaluate model's performance by spliting the data in different ways.

Cross validation is a vital step in evaluating a model. It maximizes the amount of data that is used to train the model as during the course of training, the model is not only trained but it is also tested on all the available data.

5 - Fold Cross-Validation

As you are seeing the above diagram as we split our dataset into five folds we call this process 5- Fold Cross-Validation.

Cross-Validation and Model Performance

  • 5 Folds = 5-Fold CV
  • 10 Folds = 10-Fold CV
  • k Folds = k-Fold CV
  • More Folds = More Computationally Expensive

Code :


from sklearn.model_selection import cross_val_score
from sklearn.linear_model import LinearRegression()
model = LinearRegression()
cv_result = cross_val_score(model,X,y,cv=5)
print(cv_result)

Thank You !


Linear Regression in Machine Learning

Logistic Regression in Machine Learning