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.numpy().shape, target.numpy())