Cross Validation Import Error


This is in reference to the below tutorial

while executing the below line in Jupyter notebook, I am getting a below error.

from sklearn.linear_model import LogisticRegression
from sklearn.cross_validation import KFold
from sklearn.ensemble import RandomForestClassifier
from sklearn.tree import DecisionTreeClassifier, export_graphviz
from sklearn import metrics

ModuleNotFoundError Traceback (most recent call last)
1 from sklearn.linear_model import LogisticRegression
----> 2 from sklearn.cross_validation import KFold
3 from sklearn.ensemble import RandomForestClassifier
4 from sklearn.tree import DecisionTreeClassifier, export_graphviz
5 from sklearn import metrics

ModuleNotFoundError: No module named ‘sklearn.cross_validation’

Can you please let me know the workaround so that I am move ahead with remaining part of the tutorial?

You should check
from sklearn.model_selection import KFold

As in newer versions cross_validation is deprecated and now model_selection is used

© Copyright 2013-2019 Analytics Vidhya