波士顿房价数据集

本文介绍了如何在Keras中加载和分析波士顿房价数据集,包括加载数据、访问数据集信息以及数据可视化,展示了平均房间数与房价的关系,并通过循环语句输出所有属性与房价的关系图。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


Keras是一个高层的神经网络和深度学习库,可以快速搭建神经网络,易于调试和从扩展,是TensorFlow的官方API,内置了常用的公共数据集,可通过 keras.datasets模块来加载和访问。

Keras中常见的集成数据集

名称 说明
boston_sousing 波士顿房价数据集
CIFAR10 10种类别的图片集
CIFAR100 100种类别的图片集
MNIST 手写数字图片集
Fashion-MNIST 10重时尚类别的图片集
IMDB 电影点评数据集
reuters 路透社新闻数据集

波士顿房价数据集

1. 加载数据集

import tensorflow as tf

boston_housing=tf.keras.datasets.boston_housing
#train_x和train_y分别接收训练数据集的属性和房价
#test_x和test_y分别接收测试数据集的属性和房价
#(train_x,train_y),(test_x,test_y)=boston_housing.load_data()    #默认test_split=0.2,即train数据占比0.8,test数据占比0.2
(train_x,train_y),(test_x,test_y)=boston_housing.load_data(test_split=0)#所有数据划分为训练数据

print("Training set:",len(train_x))
print("Testing set:",len(test_x))
print("Dim of train_x:",train_x.ndim)#维度
print("Dim of train_x:",train_x.shape)#形状
print("Dim of train_y:",train_y.ndim)
print("Dim of train_y:",train_y.shape)

输出结果如下:

Training set: 506
Testing set: 0
Dim of train_x: 2
Dim of train_x: (506, 13)
Dim of train_y: 1
Dim of
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值