Search code examples
pythonnetwork-programmingimportmodel

Python 3: No module named 'sklearn.model_selection'


I am trying to learn Neural Networks via the Keras Deep Learning Library in Python. I am using Python 3 and referencing this link: Tutorial Link

I try to run the code below but get the following error:

ImportError: No module named 'sklearn.model_selection'

import numpy
import pandas

from keras.models import Sequential
from keras.layers import Dense
from keras.wrappers.scikit_learn import KerasRegressor
from sklearn.model_selection import cross_val_score
from sklearn.model_selection import KFold
from sklearn.preprocessing import StandardScaler
from sklearn.pipeline import Pipeline

Any help is greatly appreciated!


Solution

  • I think you install wrong version of sklearn.

    Please try this: import sklearn print (sklearn.__version__) 0.17.1

    If your version is below 0.18, please update with pip install -U scikit-learn or pip3 install -U scikit-learn

    If you have import Error, please install sklearn with pip install scikit-learn or pip3 install scikit-learn