Skip to content

Data Base Clasess#

The dataset representations as well as the evaluation results are based on common base classes.

RelationBase #

RelationBase(
    relation_code: str,
    *,
    lazy_options: Optional[dict[str, Any]] = None,
    instance_table: Optional[DataFrame] = None,
    answer_space: Optional[Series] = None,
    relation_info: Optional[dict[str, Any]] = None
)

Base class for the representation of relations and relations results.

Methods:

Name Description
activated

Return self or a copy of self with the instance_table loaded (lazy loading disabled).

copy

Create a copy of the isntance with specified fields replaced by new values.

from_path

Load data from the given path.

get_metadata

Get or set metadata.

relation_info

Get or set additional relation information.

save

Save results to a file and export meta_data

save_instance_table

Save instance table with the format determined by the path suffix.

search_path

Search path for instance files.

Attributes:

Name Type Description
answer_space Series

The answer space of the relation.

instance_table DataFrame

A pandas.DataFrame containing all items in the relation.

relation_code str

The identifier of the relation.

answer_space property #

answer_space: Series

The answer space of the relation.

instance_table property #

instance_table: DataFrame

A pandas.DataFrame containing all items in the relation.

relation_code property #

relation_code: str

The identifier of the relation.

activated #

activated() -> Self

Return self or a copy of self with the instance_table loaded (lazy loading disabled).

copy #

copy(**kw)

Create a copy of the isntance with specified fields replaced by new values.

from_path abstractmethod classmethod #

from_path(
    path: PathLike,
    *,
    lazy: bool = True,
    fmt: InstanceTableFileFormat = None
) -> DataBase

Load data from the given path.

If lazy, only the metadata is loaded and the instances are loaded once they are accessed.

get_metadata #

get_metadata() -> dict[str, Any]
get_metadata(key: str) -> Any
get_metadata(
    key: Optional[str] = None,
) -> Union[Any, dict[str, Any]]

Get or set metadata.

Parameters:

Name Type Description Default

key #

Optional[str]

The metadata to retrieve. If not field is specified, the complete dictionary is returned.

None

Returns:

Type Description
Union[Any, dict[str, Any]]

Either the selected field or the complete dictionary.

relation_info #

relation_info(**kw) -> dict[str, Any]
relation_info(key: str) -> Any
relation_info(
    key: Optional[str] = None, /, **kw
) -> Union[None, Any, dict[str, Any]]

Get or set additional relation information.

Use relation.relation_info(<field name>=<new value>) to set fields in the relation info dictionary. If a single field is selected, the respective value is returned. Otherwise the complete dictionary is returned.

Parameters:

Name Type Description Default

key #

Optional[str]

The field to retrieve.

None

**kw #

The fields not modify.

{}

Returns:

Type Description
Union[None, Any, dict[str, Any]]

If a field is selected, the respective value is returned, otherwise, the complete info dictionary is

Union[None, Any, dict[str, Any]]

returned.

save #

save(
    path: PathLike, fmt: InstanceTableFileFormat = None
) -> Optional[Path]

Save results to a file and export meta_data

save_instance_table classmethod #

save_instance_table(
    instance_table: DataFrame,
    path: Path,
    fmt: InstanceTableFileFormat = None,
)

Save instance table with the format determined by the path suffix.

Parameters:

Name Type Description Default

instance_table #

DataFrame

The instances to save.

required

path #

Path

Where to save the instance table. If format is not specified, the suffix is used to determined the format.

required

fmt #

str

Which to save the instances in.

None

search_path classmethod #

search_path(
    path: Path,
    relation_code: None = None,
    fmt: InstanceTableFileFormat = None,
) -> list[Path]
search_path(
    path: Path,
    relation_code: str,
    fmt: InstanceTableFileFormat = None,
) -> Path
search_path(
    path: Path,
    relation_code: Optional[str] = None,
    fmt: InstanceTableFileFormat = None,
) -> Union[list[Path], Path, None]

Search path for instance files.

DatasetBase #

Base class for a collection of relations or relations results.

Methods:

Name Description
activated

Return self if lazy loading is active, otherwise return a copy without lazy loading.

from_path

Load data from the given path.

activated abstractmethod #

activated() -> Self

Return self if lazy loading is active, otherwise return a copy without lazy loading.

from_path abstractmethod classmethod #

from_path(
    path: PathLike,
    *,
    lazy: bool = True,
    fmt: InstanceTableFileFormat = None
) -> DataBase

Load data from the given path.

If lazy, only the metadata is loaded and the instances are loaded once they are accessed.