amueller / mglearn

mglearn helper package for "Introduction to Machine Learning with Python"
231 stars 116 forks source link

error about mglearn instalation #19

Open javed103 opened 4 years ago

javed103 commented 4 years ago

import mglearn C:\Users\Jade kamyana\AppData\Local\Programs\Python\Python37\lib\site-packages\sklearn\externals\six.py:31: FutureWarning: The module is deprecated in version 0.21 and will be removed in version 0.23 since we've dropped support for Python 2.7. Please rely on the official version of six (https://pypi.org/project/six/). "(https://pypi.org/project/six/).", FutureWarning) C:\Users\Jade kamyana\AppData\Local\Programs\Python\Python37\lib\site-packages\sklearn\externals\joblib__init__.py:15: FutureWarning: sklearn.externals.joblib is deprecated in 0.21 and will be removed in 0.23. Please import this functionality directly from joblib, which can be installed with: pip install joblib. If this warning is raised when loading pickled models, you may need to re-serialize those models with scikit-learn 0.21+. warnings.warn(msg, category=FutureWarning)

javed103 commented 4 years ago

i am already check the six and joblib these modules satisfied the requirement

amueller commented 4 years ago

This is not an error, it's a warning, and can be safely ignored.

filipjakubowski commented 4 years ago

It is not warning anymore.

Repos like scikit-learn depreciated six: https://github.com/scikit-learn/scikit-learn/pull/12916/files

>>> import mglearn
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/filip/.local/lib/python3.8/site-packages/mglearn/__init__.py", line 1, in <module>
    from . import plots
  File "/Users/filip/.local/lib/python3.8/site-packages/mglearn/plots.py", line 2, in <module>
    from .plot_interactive_tree import plot_tree_progressive, plot_tree_partition
  File "/Users/filip/.local/lib/python3.8/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'
amueller commented 4 years ago

True, it was removed in the last release. I'll fix it!

filipjakubowski commented 4 years ago

plot_interactive_tree.py

from sklearn.externals.six import StringIO -> from io import StringIO

I made it work in my repo fork.

amueller commented 4 years ago

Pushed a fix here and to the notebook repo and to pipy. please let me know if it works.

gcaldiera commented 4 years ago

Similar error. Not sure if they are connected:

ModuleNotFoundError Traceback (most recent call last)

in ----> 1 import mglearn /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/mglearn/__init__.py in ----> 1 from . import plots 2 from . import tools 3 from .plots import cm3, cm2 4 from .tools import discrete_scatter 5 from .plot_helpers import ReBl /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/mglearn/plots.py in 12 from .plot_tree_nonmonotonous import plot_tree_not_monotone 13 from .plot_scaling import plot_scaling ---> 14 from .plot_pca import plot_pca_illustration, plot_pca_whitening, plot_pca_faces 15 from .plot_decomposition import plot_decomposition 16 from .plot_nmf import plot_nmf_illustration, plot_nmf_faces /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/mglearn/plot_pca.py in 3 import numpy as np 4 ----> 5 from sklearn.externals.joblib import Memory 6 7 memory = Memory(cachedir="cache") ModuleNotFoundError: No module named 'sklearn.externals.joblib'
amueller commented 4 years ago

@gcaldiera thanks for reporting. I'm not sure why I didn't see that when I ran everything yesterday but it's definitely related. I'll look into it!

amueller commented 4 years ago

A work-around is changing the line to "from joblib import Memory"

avulaankith commented 4 years ago

I got this while installing

pip install mglearn
Collecting mglearn Using cached mglearn-0.1.8.tar.gz (540 kB) Requirement already satisfied: numpy in /opt/anaconda3/lib/python3.7/site-packages (from mglearn) (1.18.4) Requirement already satisfied: matplotlib in /opt/anaconda3/lib/python3.7/site-packages (from mglearn) (3.2.1) Requirement already satisfied: scikit-learn in /opt/anaconda3/lib/python3.7/site-packages (from mglearn) (0.23.0) Requirement already satisfied: pandas in /opt/anaconda3/lib/python3.7/site-packages (from mglearn) (1.0.3) Requirement already satisfied: pillow in /opt/anaconda3/lib/python3.7/site-packages (from mglearn) (7.1.2) Requirement already satisfied: cycler in /opt/anaconda3/lib/python3.7/site-packages (from mglearn) (0.10.0) Requirement already satisfied: imageio in /opt/anaconda3/lib/python3.7/site-packages (from mglearn) (2.8.0) Requirement already satisfied: kiwisolver>=1.0.1 in /opt/anaconda3/lib/python3.7/site-packages (from matplotlib->mglearn) (1.2.0) Requirement already satisfied: python-dateutil>=2.1 in /opt/anaconda3/lib/python3.7/site-packages (from matplotlib->mglearn) (2.8.1) Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /opt/anaconda3/lib/python3.7/site-packages (from matplotlib->mglearn) (2.4.7) Requirement already satisfied: threadpoolctl>=2.0.0 in /opt/anaconda3/lib/python3.7/site-packages (from scikit-learn->mglearn) (2.0.0) Requirement already satisfied: scipy>=0.19.1 in /opt/anaconda3/lib/python3.7/site-packages (from scikit-learn->mglearn) (1.4.1) Requirement already satisfied: joblib>=0.11 in /opt/anaconda3/lib/python3.7/site-packages (from scikit-learn->mglearn) (0.14.1) Requirement already satisfied: pytz>=2017.2 in /opt/anaconda3/lib/python3.7/site-packages (from pandas->mglearn) (2020.1) Requirement already satisfied: six in /opt/anaconda3/lib/python3.7/site-packages (from cycler->mglearn) (1.14.0) Building wheels for collected packages: mglearn WARNING: Building wheel for mglearn failed: [Errno 13] Permission denied: '/Users/avulaankithgmail.com/Library/Caches/pip/wheels/99' Failed to build mglearn Installing collected packages: mglearn Running setup.py install for mglearn ... done Successfully installed mglearn-0.1.8

I got this error while running import of mglearn

import mglearn Traceback (most recent call last): File "", line 1, in File "/opt/anaconda3/lib/python3.7/site-packages/mglearn/init.py", line 1, in from . import plots File "/opt/anaconda3/lib/python3.7/site-packages/mglearn/plots.py", line 14, in from .plot_pca import plot_pca_illustration, plot_pca_whitening, plot_pca_faces File "/opt/anaconda3/lib/python3.7/site-packages/mglearn/plot_pca.py", line 5, in from sklearn.externals.joblib import Memory ModuleNotFoundError: No module named 'sklearn.externals.joblib'

amueller commented 4 years ago

Thanks, can you try upgrading mglearn with pip and see if the error persists?

gcaldiera commented 4 years ago

No error now. Just a warning (see below) but it doesn't seem to be a problem. Thanks.

/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/mglearn/plot_pca.py:7: DeprecationWarning: The 'cachedir' parameter has been deprecated in version 0.12 and will be removed in version 0.14. You provided "cachedir='cache'", use "location='cache'" instead. memory = Memory(cachedir="cache") /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/mglearn/plot_nmf.py:7: DeprecationWarning: The 'cachedir' parameter has been deprecated in version 0.12 and will be removed in version 0.14. You provided "cachedir='cache'", use "location='cache'" instead. memory = Memory(cachedir="cache")

amueller commented 4 years ago

Thanks for reporting, not an issue for now, though :)

andstanl commented 1 year ago

seems to be an issue now?

TypeError Traceback (most recent call last) Input In [80], in 13 import IPython 14 import sklearn ---> 15 import mglearn 17 from pathlib import Path 18 from datetime import datetime

File ~/.local/lib/python3.8/site-packages/mglearn/init.py:1, in ----> 1 from . import plots 2 from . import tools 3 from .plots import cm3, cm2

File ~/.local/lib/python3.8/site-packages/mglearn/plots.py:14, in 12 from .plot_tree_nonmonotonous import plot_tree_not_monotone 13 from .plot_scaling import plot_scaling ---> 14 from .plot_pca import plot_pca_illustration, plot_pca_whitening, plot_pca_faces 15 from .plot_decomposition import plot_decomposition 16 from .plot_nmf import plot_nmf_illustration, plot_nmf_faces

File ~/.local/lib/python3.8/site-packages/mglearn/plot_pca.py:7, in 3 import numpy as np 5 from joblib import Memory ----> 7 memory = Memory(cachedir="cache") 10 def plot_pca_illustration(): 11 rnd = np.random.RandomState(5)

TypeError: init() got an unexpected keyword argument 'cachedir'

tabarespozos commented 1 year ago

ImportError Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_12228\2721995799.py in ----> 1 from preamble import * 2 get_ipython().run_line_magic('matplotlib', 'inline')

~...\GitHub\introduction_to_ml_with_python\preamble.py in 3 import numpy as np 4 import matplotlib.pyplot as plt ----> 5 import mglearn 6 from cycler import cycler 7

~...\GitHub\introduction_to_ml_with_python\mglearn__init__.py in ----> 1 from . import plots 2 from . import tools 3 from .plots import cm3, cm2 4 from .tools import discrete_scatter 5 from .plot_helpers import ReBl

~...\GitHub\introduction_to_ml_with_python\mglearn\plots.py in 3 from .plot_animal_tree import plot_animal_tree 4 from .plot_rbf_svm_parameters import plot_svm ----> 5 from .plot_knn_regression import plot_knn_regression 6 from .plot_knn_classification import plot_knn_classification 7 from .plot_2d_separator import plot_2d_classification, plot_2d_separator

~...\GitHub\introduction_to_ml_with_python\mglearn\plot_knn_regression.py in 5 from sklearn.metrics import euclidean_distances 6 ----> 7 from .datasets import make_wave 8 from .plot_helpers import cm3 9

~...\GitHub\introduction_to_ml_with_python\mglearn\datasets.py in 3 import os 4 from scipy import signal ----> 5 from sklearn.datasets import load_boston 6 from sklearn.preprocessing import MinMaxScaler, PolynomialFeatures 7 from sklearn.datasets import make_blobs

~\AppData\Roaming\Python\Python39\site-packages\sklearn\datasets__init.py in getattr__(name) 154 """ 155 ) --> 156 raise ImportError(msg) 157 try: 158 return globals()[name]

ImportError: load_boston has been removed from scikit-learn since version 1.2.

The Boston housing prices dataset has an ethical problem: as investigated in [1], the authors of this dataset engineered a non-invertible variable "B" assuming that racial self-segregation had a positive impact on house prices [2]. Furthermore the goal of the research that led to the creation of this dataset was to study the impact of air quality but it did not give adequate demonstration of the validity of this assumption.

The scikit-learn maintainers therefore strongly discourage the use of this dataset unless the purpose of the code is to study and educate about ethical issues in data science and machine learning.

In this special case, you can fetch the dataset from the original source::

import pandas as pd
import numpy as np

data_url = "http://lib.stat.cmu.edu/datasets/boston"
raw_df = pd.read_csv(data_url, sep="\s+", skiprows=22, header=None)
data = np.hstack([raw_df.values[::2, :], raw_df.values[1::2, :2]])
target = raw_df.values[1::2, 2]

Alternative datasets include the California housing dataset and the Ames housing dataset. You can load the datasets as follows::

from sklearn.datasets import fetch_california_housing
housing = fetch_california_housing()

for the California housing dataset and::

from sklearn.datasets import fetch_openml
housing = fetch_openml(name="house_prices", as_frame=True)

for the Ames housing dataset.

[1] M Carlisle. "Racist data destruction?" https://medium.com/@docintangible/racist-data-destruction-113e3eff54a8

[2] Harrison Jr, David, and Daniel L. Rubinfeld. "Hedonic housing prices and the demand for clean air." Journal of environmental economics and management 5.1 (1978): 81-102. https://www.researchgate.net/publication/4974606_Hedonic_housing_prices_and_the_demand_for_clean_air

VasiliBalios commented 1 year ago

I am getting the same error when trying to import mglearn

ImportError: load_boston has been removed from scikit-learn since version 1.2.

The Boston housing prices dataset has an ethical problem: as investigated in [1], the authors of this dataset engineered a non-invertible variable "B" assuming that racial self-segregation had a positive impact on house prices [2]. Furthermore the goal of the research that led to the creation of this dataset was to study the impact of air quality but it did not give adequate demonstration of the validity of this assumption.

The scikit-learn maintainers therefore strongly discourage the use of this dataset unless the purpose of the code is to study and educate about ethical issues in data science and machine learning.

In this special case, you can fetch the dataset from the original source::

import pandas as pd
import numpy as np

data_url = "http://lib.stat.cmu.edu/datasets/boston"
raw_df = pd.read_csv(data_url, sep="\s+", skiprows=22, header=None)
data = np.hstack([raw_df.values[::2, :], raw_df.values[1::2, :2]])
target = raw_df.values[1::2, 2]

Alternative datasets include the California housing dataset and the Ames housing dataset. You can load the datasets as follows::

from sklearn.datasets import fetch_california_housing
housing = fetch_california_housing()

for the California housing dataset and::

from sklearn.datasets import fetch_openml
housing = fetch_openml(name="house_prices", as_frame=True)

for the Ames housing dataset.

[1] M Carlisle. "Racist data destruction?" https://medium.com/@docintangible/racist-data-destruction-113e3eff54a8

[2] Harrison Jr, David, and Daniel L. Rubinfeld. "Hedonic housing prices and the demand for clean air." Journal of environmental economics and management 5.1 (1978): 81-102. https://www.researchgate.net/publication/4974606_Hedonic_housing_prices_and_the_demand_for_clean_air

Process finished with exit code 1

Mentoni commented 1 year ago

I'm getting the same error message while trying to import dataset from mglearn. Please reply and help fix it. How does load_boston related to other data set in mglearn? What is the solution

amueller commented 1 year ago

You should be able to upload from pypi now and the error should go away. however, the book has been written with a much older version of scikit-learn, and using the current version might break some of the examples. Really, the book needs to be revised for the current version to work properly with it.