openasce.extension package

Subpackages

Submodules

openasce.extension.debias_model module

class openasce.extension.debias_model.CausalDebiasModel[source]

Bases: Runtime

Debias Inference Class

Base class of the causal debias

Attributes:

__annotations__ = {}
__doc__ = 'Debias Inference Class\n\n    Base class of the causal debias\n\n    Attributes:\n\n    '
__init__() None[source]
__module__ = 'openasce.extension.debias_model'
_call(*, x: ndarray, y: ndarray, c: Dict[str, ndarray], training: bool) Union[None, Dict[str, ndarray]][source]

The derived class should override this method to train the model using loss_object and optimizer or predict on the samples.

Parameters
  • x – one batch of features

  • y – one batch of labels

  • c – one batch for each concerned columns of the samples, e.g. {‘weight’: Iterable[np.ndarray]}

  • training – True means training and False for predict

Returns

None for training and Dict for predict

Raises

StopIteration – The process can be finished

_generator(**kwargs)[source]

main loop

_predict_loop()[source]

main loop for prediction

_train_loop(*, num_epochs, **kwargs)[source]

main loop for train

fit(*, X: Iterable[ndarray] = None, Y: Iterable[ndarray] = None, C: Dict[str, Iterable[ndarray]] = None, Z: Iterable[Tuple[ndarray, ndarray, Dict[str, ndarray]]] = None, num_epochs: int = 1, **kwargs) None[source]

Feed the sample data and train the model on the samples.

Parameters
  • X – Features of the samples.

  • Y – Outcomes of the samples.

  • C – Other concerned columns of the samples, e.g. {‘weight’: Iterable[np.ndarray]}

  • Z – The iterable object returning (a batch of X, a batch of Y, a batch of C) if having

  • num_epochs – number of the train epoch

Returns

None

get_result()[source]

Get the predict result

Arguments:

Returns

predict result

predict(*, X: Iterable[ndarray] = None, C: Dict[str, Iterable[ndarray]] = None, Z: Iterable[Tuple[ndarray, ndarray, Dict[str, ndarray]]] = None, **kwargs) None[source]

Feed the sample data

Estimate the effect on the samples, and get_result method can be used to get the result of prediction

Parameters
  • X – Features of the samples.

  • C – Other concerned columns of the samples, e.g. {‘weight’: Iterable[np.ndarray]}

  • Z – The iterable object returning (a batch of X, a batch of Y, a batch of C) if having

Returns

None

openasce.extension.debias_model_test module

class openasce.extension.debias_model_test.MockDebiasModel[source]

Bases: CausalDebiasModel

__annotations__ = {}
__doc__ = None
__init__() None[source]
__module__ = 'openasce.extension.debias_model_test'
_call(*, x: ndarray, y: ndarray, c: Dict[str, ndarray], training: bool) None[source]

The derived class should override this method to train the model using loss_object and optimizer or predict on the samples.

Parameters
  • x – one batch of features

  • y – one batch of labels

  • c – one batch for each concerned columns of the samples, e.g. {‘weight’: Iterable[np.ndarray]}

  • training – True means training and False for predict

Returns

None for training and Dict for predict

Raises

StopIteration – The process can be finished

openasce.extension.debias_model_test.get_iris_dataset()[source]