openasce.extension package¶
Subpackages¶
- openasce.extension.debias package
- Subpackages
- Submodules
- openasce.extension.debias.cfr module
- openasce.extension.debias.debias_ips module
- openasce.extension.debias.dice module
- openasce.extension.debias.dmbr module
- openasce.extension.debias.doubly_robust module
- openasce.extension.debias.fairco module
- openasce.extension.debias.ipw module
- openasce.extension.debias.macr module
- openasce.extension.debias.pda module
Submodules¶
openasce.extension.debias_model module¶
- class openasce.extension.debias_model.CausalDebiasModel[source]¶
Bases:
RuntimeDebias 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 '¶
- __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
- 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
- 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¶
- __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