【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
目录
相关文章
|
Web App开发 关系型数据库 RDS
电源缓启动(软起动)原理
该文讨论了电源的缓启动(软起动)技术,主要是为了解决热插拔过程中可能产生的电源振荡和大电流冲击问题。缓启动通过防抖动延时和控制电流上升斜率来避免系统受影响或设备受损。文章提到了两种类型的缓启动电路:电压斜率型和电流斜率型,并详细解释了电压型缓启动电路的工作原理,包括各个元件的作用和电路的缓启动阶段。
502 12
|
11月前
|
存储 小程序 前端开发
知识付费小程开发案例
随着移动互联网的发展,知识付费成为趋势,开发知识付费小程序成为企业和个人抓住机遇的重要方式。本文档提供了从需求分析到持续优化的全流程指南,涵盖技术选型、设计开发、测试上线及运营策略,旨在帮助开发者构建高效、安全的知识付费平台。
|
Linux Python
linux之部署python环境&创建虚拟环境
linux之部署python环境&创建虚拟环境
|
机器学习/深度学习 前端开发
【机器学习】机器学习30个笔试题
本文提供了一份包含30个问题的机器学习笔试试题集,覆盖了回归模型、极大似然估计、特征选择、模型评估、正则化方法、异常值检测、分类问题等多个机器学习领域的关键知识点。
1193 0
【机器学习】机器学习30个笔试题
|
Web App开发 JavaScript 前端开发
Node.js的优缺点是?
【8月更文挑战第4天】Node.js的优缺点是?
564 4
五种IO模型基本概念
正确选择与应用适合的I/O模型是提升程序性能,保证响应时间和处理能力的关键。选择时需要综合考虑程序的实际应用场景、性能要求以及开发和维护的复杂性。
238 1
|
JSON 前端开发 Java
前端如何提交数据给后端(包含前端和后端代码)
前端如何提交数据给后端(包含前端和后端代码)
445 0
|
Python
Python中defaultdict用法
Python中defaultdict用法
2000 0
|
Kubernetes Serverless 开发者
阿里云 SAE 2.0 正式商用,极简易用、百毫秒弹性效率,降本 40%
本文主要介绍阿里云 Serverless 应用引擎如何帮助企业跨越技术鸿沟,从传统应用架构无感升级到 Serverless 架构,以更高效、更经济的方式进行转型,快速进入云原生快车道,让 2 人的研发团队享受 2000 人技术团队的红利。
|
机器学习/深度学习 自然语言处理 算法
【CV大模型SAM(Segment-Anything)】真是太强大了,分割一切的SAM大模型使用方法:可通过不同的提示得到想要的分割目标
【CV大模型SAM(Segment-Anything)】真是太强大了,分割一切的SAM大模型使用方法:可通过不同的提示得到想要的分割目标