【Bug记录】ModuleNotFoundError: No module named ‘sklearn.datasets.california_housing‘

简介: 【Bug记录】ModuleNotFoundError: No module named ‘sklearn.datasets.california_housing‘

@[toc]


一、报错代码

from sklearn.datasets.california_housing import fetch_california_housing
housing = fetch_california_housing()
print(housing.DESCR)

二、报错信息

ModuleNotFoundError                       Traceback (most recent call last)
Input In [14], in <cell line: 1>()
----> 1 from sklearn.datasets.california_housing import fetch_california_housing
      2 housing = fetch_california_housing()
      3 print(housing.DESCR)

ModuleNotFoundError: No module named 'sklearn.datasets.california_housing'

三、报错原因

新版本sklearn结构发生了变化

四、解决方案

将错误代码改为下面的代码:

from sklearn.datasets import fetch_california_housing
housing = fetch_california_housing()
print(housing.DESCR)

正常输出:

.. _california_housing_dataset:

California Housing dataset
--------------------------

**Data Set Characteristics:**

    :Number of Instances: 20640

    :Number of Attributes: 8 numeric, predictive attributes and the target

    :Attribute Information:
        - MedInc        median income in block group
        - HouseAge      median house age in block group
        - AveRooms      average number of rooms per household
        - AveBedrms     average number of bedrooms per household
        - Population    block group population
        - AveOccup      average number of household members
        - Latitude      block group latitude
        - Longitude     block group longitude

    :Missing Attribute Values: None

This dataset was obtained from the StatLib repository.
https://www.dcc.fc.up.pt/~ltorgo/Regression/cal_housing.html

The target variable is the median house value for California districts,
expressed in hundreds of thousands of dollars ($100,000).

This dataset was derived from the 1990 U.S. census, using one row per census
block group. A block group is the smallest geographical unit for which the U.S.
Census Bureau publishes sample data (a block group typically has a population
of 600 to 3,000 people).

An household is a group of people residing within a home. Since the average
number of rooms and bedrooms in this dataset are provided per household, these
columns may take surpinsingly large values for block groups with few households
and many empty houses, such as vacation resorts.

It can be downloaded/loaded using the
:func:`sklearn.datasets.fetch_california_housing` function.

.. topic:: References

    - Pace, R. Kelley and Ronald Barry, Sparse Spatial Autoregressions,
      Statistics and Probability Letters, 33 (1997) 291-297
目录
相关文章
|
7月前
|
Linux iOS开发 索引
【已解决】ModuleNotFoundError: No module named ‘matplotlib‘
【已解决】ModuleNotFoundError: No module named ‘matplotlib‘
|
5月前
|
机器学习/深度学习 Python
【Python】已解决:ModuleNotFoundError: No module named ‘paddle’
【Python】已解决:ModuleNotFoundError: No module named ‘paddle’
866 1
|
5月前
|
自然语言处理 开发者 Python
【Python】已解决:ModuleNotFoundError: No module named ‘nltk’
【Python】已解决:ModuleNotFoundError: No module named ‘nltk’
183 0
【Python】已解决:ModuleNotFoundError: No module named ‘nltk’
|
5月前
|
机器学习/深度学习 算法 Python
【Python】已解决:ModuleNotFoundError: No module named ‘sklearn‘
【Python】已解决:ModuleNotFoundError: No module named ‘sklearn‘
3298 0
|
5月前
|
计算机视觉 Python
【Python】已解决:ModuleNotFoundError: No module named ‘PIL’
【Python】已解决:ModuleNotFoundError: No module named ‘PIL’
1395 0
|
7月前
|
Linux iOS开发 MacOS
[已解决]ModuleNotFoundError: No module named ‘tqdm‘
[已解决]ModuleNotFoundError: No module named ‘tqdm‘
|
异构计算
ModuleNotFoundError: No module named ‘mmcv._ext‘
最近想将mmsegmentation打包成exe进行使用,但是遇到了一个问题,在打包的过程中不会显示报错信息,但是在执行exe程序之后,exe会出现ModuleNotFoundError: No module named 'mmcv._ext'的报错,导致软件崩溃。
1043 0
|
Python
1. 成功解决 Bug:ModuleNotFoundError: No module named 'pip'
Traceback (most recent call last): File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 87, in _ru
210 0
解决ModuleNotFoundError: No module named ‘tensorflow_datasets‘
解决ModuleNotFoundError: No module named ‘tensorflow_datasets‘
334 0
解决ModuleNotFoundError: No module named ‘tensorflow_datasets‘