mlrl.testbed_arff.experiments.input.sources package

Author Michael Rapp (michael.rapp.ml@gmail.com)

Provides classes that allow to read input data from ARFF files.

class mlrl.testbed_arff.experiments.input.sources.ArffFileSource(directory: Path)

Bases: DatasetFileSource

Allows to read a dataset from an ARFF file.

class ArffDataset(arff_file: ArffFile, output_names: set[str] | None)

Bases: object

Provides access to the content of an ARFF file and the corresponding Mulan XML file, if available.

property feature_matrix: sparray

The feature matrix contained in the dataset.

property features: list[Attribute]

A list that stores all features contained in the dataset.

static from_file(arff_file: ArffFile, file_path: Path) ArffDataset

Creates and returns an ARFF dataset from given ARFF file and a corresponding Mulan XML file, if available.

Parameters:
  • arff_file – The content of the ARFF file

  • file_path – The path to the XML file

Returns:

The ARFF dataset that has been created

property output_matrix: sparray

The output matrix contained in the dataset.

property outputs: list[Attribute]

A list that stores all outputs contained in the dataset.

property outputs_at_start: bool

True, if the outputs are defined before the features, False otherwise.

class ArffFile(matrix: sparray, arff_attributes: list[Any], relation: str)

Bases: object

Provides access to the content of an ARFF file.

property attributes: list[Attribute]

A list that contains all attributes defined in the ARFF file.

static from_file(file_path: Path, sparse: bool, dtype: dtype) ArffFile

Loads the content of an ARFF file.

Parameters:
  • file_path – The path to the ARFF file

  • sparse – True, if the ARFF file is given in sparse format, False otherwise. If the given format is incorrect, an arff.BadLayout is raised

  • dtype – The type of the data matrix to be read from the file

Returns:

An ArffFileSource.ArffFile that has been loaded

SUFFIX_ARFF = 'arff'
SUFFIX_XML = 'xml'

Submodules