UCIHousing

class paddle.text.datasets. UCIHousing [源代码]

该类是对UCI housing <[https://archive.ics.uci.edu/ml/datasets/Housing](https://archive.ics.uci.edu/ml/datasets/Housing)>_ 测试数据集的实现。

参数

  • data_file(str)- 保存数据的路径,如果参数:attr:download设置为True,

可设置为None。默认为None。 - mode(str)- ‘train’或’test’模式。默认为’train’。 - download(bool)- 如果:attr:data_file未设置,是否自动下载数据集。默认为True。

返回值

Dataset,UCI housing数据集实例。

代码示例

  1. import paddle
  2. from paddle.text.datasets import UCIHousing
  3. class SimpleNet(paddle.nn.Layer):
  4. def __init__(self):
  5. super(SimpleNet, self).__init__()
  6. def forward(self, feature, target):
  7. return paddle.sum(feature), target
  8. uci_housing = UCIHousing(mode='train')
  9. for i in range(10):
  10. feature, target = uci_housing[i]
  11. feature = paddle.to_tensor(feature)
  12. target = paddle.to_tensor(target)
  13. model = SimpleNet()
  14. feature, target = model(feature, target)
  15. print(feature.numpy().shape, target.numpy())