scludam.utils module

Module for helper functions.

scludam.utils.one_hot_encode(labels: ndarray[Any, dtype[number]][ndarray[Any, dtype[number]]])[source]

One-hot encode a list of labels.

Distinct labels must form a contiguous range, e.g. [0, 1, 2, 3].

Parameters:

labels (Numeric1DArray) – Labels.

Returns:

One-hot code.

Return type:

Numeric2DArray

class scludam.utils.Colnames(names: List[str])[source]

Bases: object

Class for column names.

Stores column names as an ordered set and allows some operations on them.

exclude(names: list | str)[source]

Exclude names from the set.

Parameters:

names (Union[list, str]) – Names to exclude from the original set.

Returns:

Column names after exclusion.

Return type:

List[str]

data(names: list | str | None = None)[source]

Get names of data columns.

A column is considered data if it does not end with “_error” or “_corr”.

Parameters:

names (Union[list, str], optional) – List of names to filter, by default None. If None, all names are used.

Returns:

Column names.

Return type:

List[str]

error(names: list | str | None = None)[source]

Get names of error columns.

A column is considered error if it ends with “_error”.

Parameters:

names (Union[list, str], optional) – List of data column names to filter, by default None. If None, the function returns error columns found. If not, the function returns error columns of the names in the list.

Returns:

Error column names.

Return type:

List[str]

missing_error(names: list | str | None = None)[source]

Check if there are missing error columns.

Parameters:

names (Union[list, str], optional) – List of data column names to filter, by default None. If None, the function will check within all data columns . If not, the function returns error columns of the names in the list.

Returns:

True if there are missing error columns, False otherwise.

Return type:

bool

corr(names: list | str | None = None)[source]

Get names of correlation columns.

A column is considered correlation if it ends with “_corr”.

Parameters:

names (Union[list, str], optional) – List of data column names to filter, by default None. If None, the function returns correlation columns found. If not, the function returns correlation columns related to the data column names in the list.

Returns:

Correlation column names.

Return type:

List[str]

missing_corr(names: list | str | None = None)[source]

Check if there are missing correlation columns.

Parameters:

names (Union[list, str], optional) – List of data column names to filter, by default None. If None, the function will check within all data columns . If not, the function wil check within the columns of the names in the list.

Returns:

True if there are missing correlation columns, False otherwise.

Return type:

bool