[Fixed] no module named ‘sklearn.cross_validation’

In this post, we will see how to resolve error modulenotfounderror: no module named ‘sklearn.cross_validation’ in Python.

Problem: no module named ‘sklearn.cross_validation’

You might get this error even through you have installed scikit-learn correctly on anaconda.

You might get this error in following scneario:

It might return you following error:

Solution: Replace cross_validation with model_selection

This error may be related to renaming and deprecation of cross_validation sub-module to model_selection.

cross_validation was deprecated in version 0.18 and was changed to model_selection from version 0.20 onwards.

You should import model_selection rather than cross_validation as below:

You can refer documents over here: https://scikit-learn.org/stable/modules/cross_validation.html

It should resolve this issue. Please comment in case this solution does not resolve no module named sklearn.cross_validation issue.

That’s all about how to resolve no module named sklearn.cross_validation error in python.

Related Posts

  • 07 April

    TypeError: ‘NoneType’ object is not iterable

    In this post, we will see about TypeError: 'NoneType' object is not iterable. You will get this error if you are iterating over object of type None in for or while loop. Let’s understand with help of example. [crayon-600827ee6a48e077544827/] If countryList is of type None, then you can get this error. Let’s see a scenario […]

  • 07 April

    TypeError: unhashable type: ‘list’

    In this post, we will see about TypeError: unhashable type: 'list'. You will get this error when you are trying to put list as key in dictionary or set because list is unhashable object.TypeError: unhashable type is generally raised when you try to hash object which is unhashable. Let’s see this with help of example: […]

  • 07 April

    Indexerror: list Index Out of Range

    In this post, we will see about Indexerror: list Index Out of Range in Python. While working with list, you can access its elements by its index. You will get this error when you are trying to access an index that does not exist. Let’s see with the help of example. Output: [crayon-600827ee6aaf9865688897/] You will […]

  • 07 April

    Valueerror: Invalid literal for int() with base 10

    In this post, we will see about Valueerror: Invalid literal for int() with base 10. You will see this error, when you are trying to convert string to int using int() function. If you provide invalid string input to int() function, you will get this error. Here is the slider to understand it better. Let’s […]

  • 07 April

    TypeError: String Indices Must be Integers

    In this post, we will see about TypeError: String Indices Must be Integers in Python. You can access the characters of string by its index. Each index specifies the position for the character. For example: Let’s say you want to print 3rd element of the String 'Java2blog', you can use str1[2]. [crayon-600827ee6b1fc774905762/] Output: v If […]

  • 05 April

    Local variable referenced before assignment

    In this post, we will see about error Local variable referenced before assignment in Python. Problem Let me explain this error with the help of an example. [crayon-600827ee6b4b5442473260/] When you run above program, you will get below output: [crayon-600827ee6b4ba031723753/] Let’s understand why we are getting this error UnboundLocalError. When Python interpreter parses any function definition […]

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.