causalicp.Result¶
The result of running causalicp.fit()
is returned in a causalicp.Result object, which contains the estimate, accepted sets, p-values, etc.
- class causalicp.Result(target, data, estimate, accepted, rejected, conf_intervals, set_pvalues, set_coefs)¶
The result of running Invariant Causal Prediction, produced as output of
causalicp.fit()
.- p¶
The total number of variables in the data (including the response/target).
- Type
int
- target¶
The index of the response/target.
- Type
int
- estimate¶
The estimated parental set returned by ICP, or None if all sets of predictors were rejected.
- Type
set or None
- accepted_sets¶
A list containing the accepted sets of predictors.
- Type
list of set
- rejected_sets¶
A list containing the rejected sets of predictors.
- Type
list of set
- pvalues¶
A dictionary containing the p-value for the causal effect of each individual predictor. The target/response is included in the dictionary and has value nan.
- Type
dict of (int, float)
- conf_intervals¶
A 2 x p array of floats representing the confidence interval for the causal effect of each variable. Each column corresponds to a variable, and the first and second row correspond to the lower and upper limit of the interval, respectively. The column corresponding to the target/response is set to nan.
- Type
numpy.ndarray or None
Example
>>> import causalicp as icp >>> result = icp.fit(data, 3)
>>> result.p 4
>>> result.target 3
>>> result.estimate set()
>>> result.accepted_sets [{1}, {2}, {0, 1}, {1, 2}, {0, 1, 2}]
>>> result.rejected_sets [set(), {0}, {0, 2}]
>>> result.pvalues {0: 1, 1: 0.187430598304751, 2: 1, 3: nan}
>>> result.conf_intervals array([[0. , 0. , 0. , nan], [2.37257655, 1.95012059, 5.88760917, nan]])
When all sets are rejected (e.g. there is a model violation), the estimate and confidence intervals are set to None:
>>> result = icp.fit(data_bad_model, 3) >>> result.estimate >>> result.conf_intervals
And the individual p-value for the causal effect of each variable is set to 1:
>>> result.pvalues {0: 1, 1: 1, 2: 1, 3: nan}