【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
目录
相关文章
|
1月前
|
机器学习/深度学习 算法 Python
【Python】已解决:ModuleNotFoundError: No module named ‘sklearn‘
【Python】已解决:ModuleNotFoundError: No module named ‘sklearn‘
20 0
|
3月前
|
Linux iOS开发 MacOS
[已解决]ModuleNotFoundError: No module named ‘tqdm‘
[已解决]ModuleNotFoundError: No module named ‘tqdm‘
|
9月前
|
Python
spyder下报错ModuleNotFoundError: No module named
spyder下报错ModuleNotFoundError: No module named
346 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
187 0
解决ModuleNotFoundError: No module named ‘tensorflow_datasets‘
解决ModuleNotFoundError: No module named ‘tensorflow_datasets‘
298 0
解决ModuleNotFoundError: No module named ‘tensorflow_datasets‘
|
TensorFlow 算法框架/工具 Python
成功解决ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'
成功解决ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'
|
并行计算 PyTorch 算法框架/工具
Python安装Pytorch(解决ModuleNotFoundError: No module named ‘torch‘)
Python安装Pytorch(解决ModuleNotFoundError: No module named ‘torch‘)
470 0
Python安装Pytorch(解决ModuleNotFoundError: No module named ‘torch‘)
|
机器学习/深度学习 算法 安全
解决ModuleNotFoundError: No module named ‘dlib‘问题-提供3.7x与3.9两个版本
解决ModuleNotFoundError: No module named ‘dlib‘问题-提供3.7x与3.9两个版本
1089 0
解决ModuleNotFoundError: No module named ‘dlib‘问题-提供3.7x与3.9两个版本
ImportError: No module named tensorrt
ImportError: No module named tensorrt
262 0