mlpy.auxiliary.datasets.DataSet

class mlpy.auxiliary.datasets.DataSet(capacity=None, filename=None, append=None)[source]

Bases: object

The data set.

The data set class a container for tracked data. Data can be tracked by adding a field for the data of interest. A numpy.ndarray is created for every field that is added for recording. Optionally a description and a numpy.dtype can be associated with the field.

Parameters:

capacity : int

The initial capacity of the record. Defaults to 10.

filename : str

The name of the file to load from/save to the record.

append : bool

Whether to append to the existing records loaded from file or to overwrite data. Defaults to False.

Examples

Creating a new dataset that stores its records in my_history.pkl:

>>> history = DataSet(capacity=2, filename="my_history.pkl")

Adding a new field:

>>> history.add_field("state", 3, dtype=DataSet.DTYPE_FLOAT)
>>> print history
state: dim(2,)
[]

Adding a new data record:

>>> import numpy as np
>>> history.append("state", np.ones(3))

Add a new sequence:

>>> history.new_sequence()

Save the dataset to file:

>>> history.save()

Methods

DTYPE_FLOAT
DTYPE_INT
DTYPE_OBJECT
add_field(name, dim[, dtype, description]) Add a field with given the specifications.
append(name, data) Append a new data record.
get_field(name) Returns the field with the given name.
get_field_names() Returns all field names.
has_field(name) Checks if a field with that name exists.
load([filename]) Load the records from file.
new_sequence() Adds a new sequence.
save([filename]) Save the record to file.