mglearn
mglearn copied to clipboard
error about mglearn instalation
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)
i am already check the six and joblib these modules satisfied the requirement
This is not an error, it's a warning, and can be safely ignored.
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'
True, it was removed in the last release. I'll fix it!
from sklearn.externals.six import StringIO
->
from io import StringIO
I made it work in my repo fork.
Pushed a fix here and to the notebook repo and to pipy. please let me know if it works.
Similar error. Not sure if they are connected:
ModuleNotFoundError Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/mglearn/init.py in
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/mglearn/plots.py in
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/mglearn/plot_pca.py in
ModuleNotFoundError: No module named 'sklearn.externals.joblib'
@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!
A work-around is changing the line to "from joblib import Memory"
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'
Thanks, can you try upgrading mglearn with pip and see if the error persists?
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")
Thanks for reporting, not an issue for now, though :)
seems to be an issue now?
TypeError Traceback (most recent call last)
Input In [80], in
File ~/.local/lib/python3.8/site-packages/mglearn/init.py:1, in
File ~/.local/lib/python3.8/site-packages/mglearn/plots.py:14, in
File ~/.local/lib/python3.8/site-packages/mglearn/plot_pca.py:7, in
TypeError: init() got an unexpected keyword argument 'cachedir'
ImportError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_12228\2721995799.py in
~...\GitHub\introduction_to_ml_with_python\preamble.py in
~...\GitHub\introduction_to_ml_with_python\mglearn_init_.py in
~...\GitHub\introduction_to_ml_with_python\mglearn\plots.py in
~...\GitHub\introduction_to_ml_with_python\mglearn\plot_knn_regression.py in
~...\GitHub\introduction_to_ml_with_python\mglearn\datasets.py in
~\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
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
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
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.