Skip to content

Helpers

siapy.datasets.helpers

generate_classification_target

generate_classification_target(dataframe: DataFrame, column_names: str | list[str]) -> ClassificationTarget
PARAMETER DESCRIPTION
dataframe

TYPE: DataFrame

column_names

TYPE: str | list[str]

Source code in siapy/datasets/helpers.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
def generate_classification_target(
    dataframe: pd.DataFrame,
    column_names: str | list[str],
) -> "ClassificationTarget":
    from .schemas import (
        ClassificationTarget,  # Local import to avoid circular dependency
    )

    if isinstance(column_names, str):
        column_names = [column_names]
    # create one column labels from multiple columns
    label = dataframe[column_names].apply(tuple, axis=1)
    # Convert tuples to strings with '__' delimiter
    label = label.apply(lambda x: "__".join(x))
    # encode to numbers
    encoded_np, encoding_np = pd.factorize(label)
    encoded = pd.Series(encoded_np, name="encoded")
    encoding = pd.Series(encoding_np, name="encoding")
    return ClassificationTarget(label=label, value=encoded, encoding=encoding)

generate_regression_target

generate_regression_target(dataframe: DataFrame, column_name: str) -> RegressionTarget
PARAMETER DESCRIPTION
dataframe

TYPE: DataFrame

column_name

TYPE: str

Source code in siapy/datasets/helpers.py
36
37
38
39
40
41
42
def generate_regression_target(
    dataframe: pd.DataFrame,
    column_name: str,
) -> "RegressionTarget":
    from .schemas import RegressionTarget  # Local import to avoid circular dependency

    return RegressionTarget(name=column_name, value=dataframe[column_name])

merge_signals_from_multiple_cameras

merge_signals_from_multiple_cameras(data: TabularDatasetData)
PARAMETER DESCRIPTION
data

TYPE: TabularDatasetData

Source code in siapy/datasets/helpers.py
45
46
def merge_signals_from_multiple_cameras(data: "TabularDatasetData"):
    data.signals.copy()