twodlearn.datasets.base module

Creates a generic dataset from a given data

class twodlearn.datasets.base.Dataset(data_x, data_y=None)[source]

Bases: object

x[source]

samples, [sample_id, sample …]

y[source]

labels for each sample

epochs_completed[source]
index_in_epoch[source]
n_samples[source]
class Iloc(dataset)[source]

Bases: object

property dataset[source]
get_stats()[source]
iloc[source]
property n_samples[source]
next_batch(batch_size, shuffle=True)[source]

Return the next batch_size examples from this data set.

next_batch_x(batch_size, shuffle=True)[source]

Return the next batch_size examples from this data set.

normalizer[source]

Decorator used to specify an optional property inside a model. The decorator works similar to @property, but the specified method correponds to the initialization of the property

sample[source]

Decorator used to specify methods that have a set of local variables.

These methods consist of an initialization method (speficied with the function given to the decorator) and an execute method.

shuffle()[source]
update_data(data_x, data_y=None)[source]
property x[source]
property y[source]
class twodlearn.datasets.base.Datasets(train, valid=None, test=None)[source]

Bases: object

mapper[source]

Decorator used to specify an optional property inside a model. The decorator works similar to @property, but the specified method correponds to the initialization of the property

normalize()[source]

Normalize dataset for having a training dataset with zero mean and standard deviation of one.

normalizer[source]

Decorator used to specify an optional property inside a model. The decorator works similar to @property, but the specified method correponds to the initialization of the property

split_train(p_train, p_valid, p_test=0.0, shuffle=True)[source]
class twodlearn.datasets.base.DfDataset(data_x, data_y=None)[source]

Bases: twodlearn.datasets.base.Dataset

class twodlearn.datasets.base.MaxMinNormalizer(stats)[source]

Bases: twodlearn.datasets.base.Normalizer

denormalize(batch)[source]
normalize(batch)[source]
class twodlearn.datasets.base.Normalizer(stats)[source]

Bases: object

denormalize(batch)[source]
normalize(batch)[source]
class twodlearn.datasets.base.OneHotMap(n_classes)[source]

Bases: object

property n_classes[source]
class twodlearn.datasets.base.ReplaceMap(map)[source]

Bases: object

class twodlearn.datasets.base.StackedMapper(mappers=None)[source]

Bases: object

append(mapper)[source]
property mappers[source]
twodlearn.datasets.base.dense_to_one_hot(labels, num_classes=None)[source]

Convert class labels from scalars to one-hot vectors.

twodlearn.datasets.base.load_gz_as_nparray(work_directory, filename, dtype=<class 'numpy.float32'>)[source]
twodlearn.datasets.base.maybe_download(filename, work_directory, source_url)[source]

Download the data from source url, unless it’s already here. :param filename: string, name of the file in the directory. :param work_directory: string, path to working directory. :param source_url: url to download from if file doesn’t exist.

Returns

Path to resulting file.