0
点赞
收藏
分享

微信扫一扫

数据集--load_boston()函数

倚然君 2022-05-04 阅读 41

目录

参数

sklearn.datasets.load_boston(*, return_X_y=False)

return_X_y:bool

若为True,则返回(data,target)
若为False,则返回一个Bunch对象

返回值

return_X_y=True

返回(data,target)一个元组
data:ndarray of shape(506,13)
target:ndarray of shape(506,)

return_X_y=Flase

返回一个Bunch对象

Bunch对象属性

Bunch对象:Dictionary-like object

data:ndarray

shape:(506,13)
数据矩阵

target:ndarray

shape:(506,)
标签(回归目标)

filename:str

boston.csv文件在电脑硬盘中的存储位置

DESCR:str

关于数据集的完整描述

feature_name:ndarray

所有特征的名称

使用举例

from sklearn.datasets import load_boston
from sklearn.model_selection import train_test_split
the_data=load_boston()
x=the_data.data
y=the_data.target
'''
the_data=load_boston(return_X_y=True)
x=the_data[0]
y=the_data[1]
'''
x.shape,y.shape
>>> (506,13),(506,)
x_train,x_test,y_train,y_test=train_test_split(test_size=0.2)
x_train.shape,y_train.shape
>>> (404,13),(404,)
举报

相关推荐

0 条评论