bedroc package

Subpackages

Submodules

bedroc.containers module

Containers

class bedroc.containers.DataContainer(dataframe: DataFrame, *, name: str = 'data', feature_suffix: str = '_feature', feature_std_suffix: str = '_uncertainty', std_scale: float = 1.0, select_features: Iterable[str] | None = None, select_data: Iterable[Any] | None = None, data_column: str = 'ID')

Bases: object

A generic data container

Parameters:
  • dataframe – A dataframe with columns of feature values and their standard deviations

  • name – Data container name. Defaults to data.

  • feature_suffix – Suffix of feature value columns. Defaults to _feature.

  • feature_std_suffix – Suffix of feature standard deviation columns. Defaults to _uncertainty.

  • std_scale – Number of standard deviations represented by the uncertainty columns. For example, use 2.0 if the input uncertainties are reported as 2SE. Defaults to 1.0.

  • select_features – An optional iterable (tuple or list) of bare feature names (without feature_suffix) to select. Defaults to None to select all features.

  • select_data – An optional iterable (tuple or list) of data to select. Defaults to None to select all data.

  • data_column – Name of the data column used by select_data. Defaults to ID.

classmethod from_csv(filename_path: str | Path, **kwargs) DataContainer

Creates an instance from a CSV file.

Parameters:
  • filename_path – Path to the CSV file

  • **kwargs – Arbitrary keyword arguments for constructor

Returns:

An instance

classmethod from_excel(filename_path: str | Path, sheet_name: Any, **kwargs) DataContainer

Creates an instance from an Excel file.

Parameters:
  • filename_path – Path to the Excel file

  • sheet_name – Sheet name

  • **kwargs – Arbitrary keyword arguments for constructor

Returns:

An instance

property data_names: list[str]

Data names

property feature_columns: Index

Index of feature columns

property feature_std_columns: Index

Index of feature uncertainty columns

property feature_names: Index

Index of feature names with the suffix removed

property n_data: int

Number of data

property n_features: int

Number of features

_compute_scaling_means() Any

Computes the feature means for scaling

_compute_scaling_stds() Any

Computes the feature standard deviations for scaling

_compute_standardized_data() DataFrame

Computes standardized data

get_dataframe(*, standardized: bool = True) DataFrame

Returns standardized (default) or raw dataframe

get_destandardized_values(standardized_values: ndarray[tuple[Any, ...], dtype[float64]]) ndarray[tuple[Any, ...], dtype[float64]]

Gets destandardized values.

Parameters:

standardized_values – Standardized values. Must have a shape of: (n_data, n_features) or (n_data, n_features, n_samples)

Returns:

Destandardized values with matching shape

get_feature_values(*, standardized: bool = True) ndarray[tuple[Any, ...], dtype[float64]]

Returns standardized (default) or raw feature values

Parameters:

standardized – Whether to return standardized feature values. Defaults to True.

Returns:

Feature values

get_feature_stds(*, standardized: bool = True) ndarray[tuple[Any, ...], dtype[float64]]

Returns standardized (default) or raw feature standard deviations

Parameters:

standardized – Whether to return standardized standard deviations. Defaults to True.

Returns:

Feature standard deviations

get_covariance_matrix(*, standardized: bool = True) ndarray[tuple[Any, ...], dtype[float64]]

Gets the covariance matrix.

Parameters:

standardized – Whether to return standardized standard deviations. Defaults to True.

Returns:

Covariance matrix

plot_pearson_correlation_coefficient(*, standardized: bool = True) Axes

Plots a heatmap of the Pearson correlation coefficient.

Parameters:

standardized – Whether to process standardized standard deviations. Defaults to True.

Returns:

Figure axes

bedroc.core module

bedroc.hierarchical module

bedroc.pca module

bedroc.type_aliases module

Common type aliases

This module centralizes type definitions for NumPy arrays and scalar values. Having a single place for these aliases improves readability and consistency across the codebase, whilst also simplifying type checking and documentation.

Module contents

Package level variables and initialises the package logger

bedroc.complex_formatter() Formatter

Complex formatter

bedroc.simple_formatter() Formatter

Simple formatter for logging

Returns:

Formatter for logging

bedroc.debug_logger() Logger

Sets up debug logging to the console.

Returns:

A logger

bedroc.debug_file_logger() Logger

Sets up info logging to the console and debug logging to a file.

Returns:

A logger