【发布时间】:2023-01-24 04:39:54
【问题描述】:
我是一名新的数据科学训练营学生。最近买了一本书《Introduction to Machine Learning with Pyhton》。然而,这本书大量使用了 mglearn 库。当我想导入库时出现错误。 (您可以从下面看到。)我无法演示书中提供的示例。有什么办法可以解决这个问题吗?
提前谢谢了!。
ImportError Traceback (most recent call last)
Cell In [3], line 1
----> 1 import mglearn
File c:\Users\murad\AppData\Local\Programs\Python\Python310\lib\site-packages\mglearn\__init__.py:1
----> 1 from . import plots
2 from . import tools
3 from .plots import cm3, cm2
File c:\Users\murad\AppData\Local\Programs\Python\Python310\lib\site-packages\mglearn\plots.py:5
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
File c:\Users\murad\AppData\Local\Programs\Python\Python310\lib\site-packages\mglearn\plot_knn_regression.py:7
4 from sklearn.neighbors import KNeighborsRegressor
5 from sklearn.metrics import euclidean_distances
----> 7 from .datasets import make_wave
8 from .plot_helpers import cm3
11 def plot_knn_regression(n_neighbors=1):
File c:\Users\murad\AppData\Local\Programs\Python\Python310\lib\site-packages\mglearn\datasets.py:5
3 import os
4 from scipy import signal
----> 5 from sklearn.datasets import load_boston
6 from sklearn.preprocessing import MinMaxScaler, PolynomialFeatures
7 from .make_blobs import make_blobs
File c:\Users\murad\AppData\Local\Programs\Python\Python310\lib\site-packages\sklearn\datasets\__init__.py:156, in __getattr__(name)
105 if name == "load_boston":
106 msg = textwrap.dedent(
107 """
108 `load_boston` has been removed from scikit-learn since version 1.2.
(...)
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
...
[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>
我试图从网上找到答案,但找不到任何东西。
【问题讨论】:
标签: python machine-learning scikit-learn importerror