openasce.inference package¶
- class openasce.inference.GraphInferModel(*, graph: CausalGraph = None, column_names: List[str] = None, treatment_name: str = None, label_name: str = None, num_iteration=20)[source]¶
Bases:
InferenceModelThe inference using the causal graph
- graph¶
The causal graph. If not set, the class will try to find it out if discovery is available.
- column_names¶
all names of sample
- treatment_name¶
treatment column name in column_names
- label_name¶
target column name in column_names
- Parameters
graph – causal graph
column_names – all names of column
treatment_name – the name of treatment column
label_name – the name of target name
- __init__(*, graph: CausalGraph = None, column_names: List[str] = None, treatment_name: str = None, label_name: str = None, num_iteration=20) None[source]¶
- Parameters
graph – causal graph
column_names – all names of column
treatment_name – the name of treatment column
label_name – the name of target name
- property column_names¶
All nodes’ name. Note: should include the treatment node and label node.
- property data¶
Return the sample data
- estimate(*, X: Iterable[ndarray] = None, Y: Iterable[ndarray] = None, T: Iterable[ndarray] = None, **kwargs) None[source]¶
Feed the sample data and estimate the outcome on the samples
- Parameters
X – Features of the samples.
Y – Ignore in causal graph inference
T – Ignore in causal graph inference
kwargs – {‘treat_value’: treat_value, ‘label_value’:label_value}
Returns:
- fit(*, X: Iterable[ndarray], Y: Iterable[ndarray] = None, T: Iterable[ndarray] = None, **kwargs) None[source]¶
Feed the sample data to train the graph
- Parameters
X – All features of the samples including the treatment and the label node.
Y – Ignore in causal graph inference
T – Ignore in causal graph inference.
Returns:
- get_result()[source]¶
Get the estimated result
The sub-class should implement this routine and runtime invokes it.
Arguments:
- Returns
The estimation result.
- property graph¶
- property label_name¶
- output()[source]¶
Output the estimated result to files
The sub-class should implement this routine and runtime invokes it.
Arguments:
Returns:
- property treatment_name¶
- class openasce.inference.TModel(hidden_units: Dict, lr: float = 0.1, name: str = 't_model')[source]¶
Bases:
InferenceModelT_model based on NN
Initialize.
- Parameters
hidden_units (dict) – list of positive integer, the layer number and units in each layer.
lr (float) – learning rate
- __init__(hidden_units: Dict, lr: float = 0.1, name: str = 't_model') None[source]¶
Initialize.
- Parameters
hidden_units (dict) – list of positive integer, the layer number and units in each layer.
lr (float) – learning rate
- estimate(X: Iterable[Tensor] = None, T: Iterable[Tensor] = None, *, Z: Iterable[Tuple[Tensor, Tensor, Tensor]] = 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 :param X: Features of the samples. :param T: Treatments of the samples. :param Z: The iterable object returning (a batch of X, a batch of Y, a batch of T)
- Returns
None
- fit(X: Iterable[Tensor] = None, Y: Iterable[Tensor] = None, T: Iterable[Tensor] = None, *, Z: Iterable[Tuple[Tensor, Tensor, Tensor]] = 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.
T – Treatments of the samples.
Z – The iterable object returning (a batch of X, a batch of Y, a batch of T)
num_epochs – number of the train epoch
- Returns
None
- property trainable_variables¶
Subpackages¶
- openasce.inference.learner package
- openasce.inference.tree package
- Submodules
- openasce.inference.tree.bin module
- openasce.inference.tree.boosting module
- openasce.inference.tree.cppnode module
- openasce.inference.tree.csv_dataset module
- openasce.inference.tree.dataset module
- openasce.inference.tree.didtree module
- openasce.inference.tree.gbct module
- openasce.inference.tree.gradient_causal_tree module
- openasce.inference.tree.histogram module
- openasce.inference.tree.information module
- openasce.inference.tree.losses module
- openasce.inference.tree.reflect_utils module
- openasce.inference.tree.splitting_losses module
- openasce.inference.tree.tree_node module
- openasce.inference.tree.utils module
Submodules¶
openasce.inference.graph_inference module¶
- class openasce.inference.graph_inference.GraphInferModel(*, graph: CausalGraph = None, column_names: List[str] = None, treatment_name: str = None, label_name: str = None, num_iteration=20)[source]¶
Bases:
InferenceModelThe inference using the causal graph
- graph¶
The causal graph. If not set, the class will try to find it out if discovery is available.
- column_names¶
all names of sample
- treatment_name¶
treatment column name in column_names
- label_name¶
target column name in column_names
- Parameters
graph – causal graph
column_names – all names of column
treatment_name – the name of treatment column
label_name – the name of target name
- __init__(*, graph: CausalGraph = None, column_names: List[str] = None, treatment_name: str = None, label_name: str = None, num_iteration=20) None[source]¶
- Parameters
graph – causal graph
column_names – all names of column
treatment_name – the name of treatment column
label_name – the name of target name
- property column_names¶
All nodes’ name. Note: should include the treatment node and label node.
- property data¶
Return the sample data
- estimate(*, X: Iterable[ndarray] = None, Y: Iterable[ndarray] = None, T: Iterable[ndarray] = None, **kwargs) None[source]¶
Feed the sample data and estimate the outcome on the samples
- Parameters
X – Features of the samples.
Y – Ignore in causal graph inference
T – Ignore in causal graph inference
kwargs – {‘treat_value’: treat_value, ‘label_value’:label_value}
Returns:
- fit(*, X: Iterable[ndarray], Y: Iterable[ndarray] = None, T: Iterable[ndarray] = None, **kwargs) None[source]¶
Feed the sample data to train the graph
- Parameters
X – All features of the samples including the treatment and the label node.
Y – Ignore in causal graph inference
T – Ignore in causal graph inference.
Returns:
- get_result()[source]¶
Get the estimated result
The sub-class should implement this routine and runtime invokes it.
Arguments:
- Returns
The estimation result.
- property graph¶
- property label_name¶
- output()[source]¶
Output the estimated result to files
The sub-class should implement this routine and runtime invokes it.
Arguments:
Returns:
- property treatment_name¶
openasce.inference.inference_model module¶
- class openasce.inference.inference_model.InferenceModel[source]¶
Bases:
RuntimeInference Class
Base class of the causal inference
Attributes:
- CONDITION_DICT_NAME = 'condition'¶
- LABEL_VALUE = 'label_value'¶
- TREATMENT_VALUE = 'treatment_value'¶
- property data¶
Return the sample data
- estimate(*, X: Iterable[ndarray], T: Iterable[ndarray], **kwargs) None[source]¶
Feed the sample data and estimate the effect on the samples
- Parameters
X – Features of the samples.
T – Treatments of the samples.
- Returns
None
- fit(*, X: Iterable[ndarray], Y: Iterable[ndarray], T: Iterable[ndarray], **kwargs) None[source]¶
Feed the sample data and train the model used to effect on the samples.
- Parameters
X – Features of the samples.
Y – Outcomes of the samples.
T – Treatments of the samples.
- Returns
None
openasce.inference.t_model module¶
- class openasce.inference.t_model.TModel(hidden_units: Dict, lr: float = 0.1, name: str = 't_model')[source]¶
Bases:
InferenceModelT_model based on NN
Initialize.
- Parameters
hidden_units (dict) – list of positive integer, the layer number and units in each layer.
lr (float) – learning rate
- __init__(hidden_units: Dict, lr: float = 0.1, name: str = 't_model') None[source]¶
Initialize.
- Parameters
hidden_units (dict) – list of positive integer, the layer number and units in each layer.
lr (float) – learning rate
- estimate(X: Iterable[Tensor] = None, T: Iterable[Tensor] = None, *, Z: Iterable[Tuple[Tensor, Tensor, Tensor]] = 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 :param X: Features of the samples. :param T: Treatments of the samples. :param Z: The iterable object returning (a batch of X, a batch of Y, a batch of T)
- Returns
None
- fit(X: Iterable[Tensor] = None, Y: Iterable[Tensor] = None, T: Iterable[Tensor] = None, *, Z: Iterable[Tuple[Tensor, Tensor, Tensor]] = 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.
T – Treatments of the samples.
Z – The iterable object returning (a batch of X, a batch of Y, a batch of T)
num_epochs – number of the train epoch
- Returns
None
- property trainable_variables¶