Modulenotfounderror: No module named 'sklearn.externals.Six'

Asked

Viewed 1,128 times

0

I cannot run the script, because it is accusing that there is no module 'sklearn.externals.six'. I’ve looked for solutions, I’ve remade the venv and not the right one. Has this module become obsolete or something? Please help me out.

from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
import pandas as pd
import mglearn

iris_dataset = load_iris()

#print(f'Keys: {iris_dataset}')

'''
train_test_slit() extrai 75% dos dados de iris_dataset['data'] e iris_dataset['target'] para treinar e os outros 25% para teste

'''

X_train, X_test, y_train, y_text = train_test_split(
    iris_dataset['data'], iris_dataset['target'],    random_state=0)

iris_dataframe = pd.DataFrame(X_train, columns=iris_dataset.feature_names)

grr = pd.plotting.scatter_matrix(iris_dataframe, c=y_train, figsize=(
    15, 15), marker='o', hist_kwds={'bins': 20}, s=60, alpha=.8, cmap=mglearn.cm3)

The way out:

Traceback (most recent call last):
  File "c:\Users\Paulo\Documents\Cursos\MachineLearningPython\Cap 1\firstMLAlghoritm.py", line 4, in <module>
    import mglearn
  File "c:\Users\Paulo\Documents\Cursos\MachineLearningPython\venv\lib\site-packages\mglearn\__init__.py", line 1, in <module>
    from . import plots
  File "c:\Users\Paulo\Documents\Cursos\MachineLearningPython\venv\lib\site-packages\mglearn\plots.py", line 2, in <module>
    from .plot_interactive_tree import plot_tree_progressive, plot_tree_partition
  File "c:\Users\Paulo\Documents\Cursos\MachineLearningPython\venv\lib\site-packages\mglearn\plot_interactive_tree.py", line 6, in <module>
    from sklearn.externals.six import StringIO  # doctest: +SKIP
ModuleNotFoundError: No module named 'sklearn.externals.six'

3 answers

1

sklearn.externals.Six has been phased out with the scikit-Learn 0.21 version. Downgrade your scikit-Learn version. See the following code:

No jupyter notebook:! Pip install --upgrade scikit-Learn==0.20.3

No terminal:Pip install --upgrade scikit-Learn=0.20.3

After that the sklearn.externals.Six module will be recognized

0

By error message the module mglearn use that one script, who needs the sklearn.externals.six, whereas the sklearn.externals.six was taken from sklearn in version 0.21.0. To use the mglearn you need to downgrade sklearn for a version earlier than 0.21.0.

  • I tried to downgrade, but it says that it does not find a version that satisfies. I used: Pip install sklearn==0.20.4. And the output: ERROR: Could not find a version that satisfies the requirement sklearn==0.20.4 (from versions: 0.0) ERROR: No matching Distribution found for sklearn==0.20.4. I looked at the versions on the site, but I couldn’t downgrade

-1

In this case, I imagine it won’t make so much difference if you use this library. If you want to run the code without it, do the following:

1) Remove:

import mglearn

2) Remove last parameter from last line:

, cmap=mglearn.cm3

Browser other questions tagged

You are not signed in. Login or sign up in order to post.