fairxai.bbox package

Submodules

fairxai.bbox.bbox module

class fairxai.bbox.bbox.AbstractBBox[source]

Bases: ABC

Generic Black Box class witch provides two sklearn-like methods.

pass

model()[source]

Provides the bbox.

abstract predict(sample_matrix: list)[source]

Wrap of sklearn predict method, that predict the class labels for the provided data.

Parameters:

sample_matrix – {array-like, sparse matrix} of shape (n_queries, n_features) samples.

Returns:

ndarray of shape (n_queries, n_classes), or a list of n_outputs of such arrays if n_outputs > 1.

abstract predict_proba(sample_matrix: list)[source]

Wrap of sklearn predict_proba method, that return probability estimates for the test data.

Parameters:

sample_matrix – {array-like, sparse matrix} of shape (n_queries, n_features) samples

Returns:

ndarray of shape (n_queries, n_classes), or a list of n_outputs of such arrays if n_outputs > 1.

fairxai.bbox.bbox_factory module

class fairxai.bbox.bbox_factory.ModelFactory[source]

Bases: object

Scalable factory for creating AbstractBBox wrappers (SklearnBBox, TorchBBox, etc.) based on the framework name. Supports dynamic framework registration.

This approach avoids the need for a model instance and works directly with saved files (.pkl/.pth) by calling the wrapper’s load() method.

classmethod available_frameworks() list[str][source]

Return all currently registered frameworks.

classmethod create(framework: str, model_path: str | None = None, model_params: Dict[str, Any] | None = None, device: str = 'cpu') AbstractBBox[source]

Instantiate the correct AbstractBBox wrapper for the given framework.

Parameters:
  • framework – Name of the ML framework (‘sklearn’, ‘torch’, etc.)

  • model_path – Optional path to pre-trained model (.pkl or .pth)

  • model_params – Optional parameters to initialize the model if needed

  • device – Device for TorchBBox (‘cpu’ or ‘cuda’)

Returns:

AbstractBBox instance with loaded model if model_path provided

Raises:

ValueError – if framework is unsupported or wrapper instantiation fails

classmethod register_framework(framework_name: str, wrapper_cls: Type[AbstractBBox], base_class: Type)[source]

Dynamically register a new ML framework.

Parameters:
  • framework_name – Logical name of the framework

  • wrapper_cls – Wrapper class implementing AbstractBBox

  • base_class – Base class for validation (optional)

Module contents

class fairxai.bbox.AbstractBBox[source]

Bases: ABC

Generic Black Box class witch provides two sklearn-like methods.

pass

model()[source]

Provides the bbox.

abstract predict(sample_matrix: list)[source]

Wrap of sklearn predict method, that predict the class labels for the provided data.

Parameters:

sample_matrix – {array-like, sparse matrix} of shape (n_queries, n_features) samples.

Returns:

ndarray of shape (n_queries, n_classes), or a list of n_outputs of such arrays if n_outputs > 1.

abstract predict_proba(sample_matrix: list)[source]

Wrap of sklearn predict_proba method, that return probability estimates for the test data.

Parameters:

sample_matrix – {array-like, sparse matrix} of shape (n_queries, n_features) samples

Returns:

ndarray of shape (n_queries, n_classes), or a list of n_outputs of such arrays if n_outputs > 1.