UCIHousing

class paddle.text. UCIHousing ( data_file=None, mode='train', download=True ) [source]

Implementation of UCI housing dataset

Parameters
  • data_file (str) – path to data file, can be set None if download is True. Default None

  • mode (str) – ‘train’ or ‘test’ mode. Default ‘train’.

  • download (bool) – whether to download dataset automatically if data_file is not set. Default True

Returns

instance of UCI housing dataset.

Return type

Dataset

Examples

>>> import paddle
>>> from paddle.text.datasets import UCIHousing

>>> class SimpleNet(paddle.nn.Layer):
...     def __init__(self):
...         super().__init__()
...
...     def forward(self, feature, target):
...         return paddle.sum(feature), target

>>> paddle.disable_static()

>>> uci_housing = UCIHousing(mode='train')

>>> for i in range(10):
...     feature, target = uci_housing[i]
...     feature = paddle.to_tensor(feature)
...     target = paddle.to_tensor(target)
...
...     model = SimpleNet()
...     feature, target = model(feature, target)
...     print(feature.shape, target.numpy())
[] [24.]
[] [21.6]
[] [34.7]
[] [33.4]
[] [36.2]
[] [28.7]
[] [22.9]
[] [27.1]
[] [16.5]
[] [18.9]