Skip to content

Commit 3466834

Browse files
committed
Fixed docs build
1 parent 5e0d3cc commit 3466834

4 files changed

Lines changed: 15 additions & 22 deletions

File tree

causal_testing/discovery/nsga_discovery.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def binary_string_to_causal_dag(self, individual: np.array) -> CausalDAG:
3939
Converts a binary string representation of a causal DAG to a CausalDAG object.
4040
4141
:param individual: Bitstring of the same length as `possible_edges` such that 1 at position `i` represents
42-
possible_edges[i] being an edge in the graph and 0 represents it not being.
42+
possible_edges[i] being an edge in the graph and 0 represents it not being.
4343
:returns: The converted CausalDAG instance.
4444
"""
4545
causal_dag = CausalDAG()

causal_testing/estimation/abstract_regression_estimator.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def __init__(
6464
def _get_adjusted_variables(self, tree: ast.AST) -> set[str]:
6565
"""
6666
Recursively return variables in an AST.
67+
6768
:returns: Set of all variables not used as part of a function.
6869
"""
6970
if isinstance(tree, ast.Name) and tree.id != self.treatment_variable:
@@ -108,7 +109,9 @@ def _setup_covariates(self, df: pd.DataFrame) -> pd.Series:
108109
Parse the formula and set up the covariates from the design matrix so we can use them in the statsmodels array
109110
API. This allows us to only parse the formula once, rather than using the formula API, which parses it every
110111
time the regression model is fit, which can be a lot if using causal test adequacy.
112+
111113
:param df: The data to use.
114+
112115
:returns: The data and the covariate columns.
113116
"""
114117
_, covariate_data = dmatrices(self.formula, df, return_type="dataframe")
@@ -154,9 +157,10 @@ def treatment_columns(self, model: RegressionResultsWrapper) -> list[str]:
154157
This is a workaround for statsmodels mangling the names of categorical variables to include the values.
155158
156159
:param model: The fitted model from which to extract the variable names.
160+
157161
:returns: A list of the feature names in the model that represent the treatment. Normally this will just be
158-
[treatment_name], but for categorical treatments, you'll have
159-
[treatment_name[value_1], treatment_name[value_2]].
162+
[treatment_name], but for categorical treatments, you'll have
163+
[treatment_name[value_1], treatment_name[value_2]].
160164
"""
161165
return [
162166
param
@@ -170,7 +174,7 @@ def _predict(self, df) -> pd.DataFrame:
170174
:param df: The data to use.
171175
:param: adjustment_config: The values of the adjustment variables to use.
172176
173-
:return: The estimated outcome under control and treatment, with confidence intervals in the form of a
177+
:returns: The estimated outcome under control and treatment, with confidence intervals in the form of a
174178
dataframe with columns "predicted", "se", "ci_lower", and "ci_upper".
175179
"""
176180
model = self.fit_model(df)

causal_testing/testing/causal_test_case.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class CausalTestCase:
2020
variables, a CausalTestCase stores the values of these variables. Also the outcome variable and value are
2121
specified. The goal of a CausalTestCase is to test whether the intervention made to the control via the treatment
2222
causes the model-under-test to produce the expected change.
23+
2324
:param base_test_case: A BaseTestCase object consisting of a treatment variable, outcome variable and effect
2425
:param expected_causal_effect: The expected causal effect (Positive, Negative, No Effect).
2526
:param effect_measure: A string which denotes the type of estimate to return.
@@ -70,10 +71,11 @@ def measure_adequacy(
7071
) -> DataAdequacy:
7172
"""
7273
Calculate the adequacy measurement, and populate the data_adequacy field.
74+
7375
:param df: The original dataset to use.
7476
:param bootstrap_size: The number of bootstrap samples to use. (Defaults to 100)
7577
:param group_by: For IPCWEstimator - the "id" column to ensure that entire individuals are sampled rather than
76-
random rows.
78+
random rows.
7779
"""
7880
results = []
7981
outcomes = []
@@ -130,8 +132,7 @@ def execute_test(
130132
:param suppress_estimation_errors: Set to True to suppress estimation errors. (Defaults to False)
131133
:param bootstrap_size: The number of bootstrap samples to use. (Defaults to 100)
132134
:param group_by: For IPCWEstimator - the "id" column to ensure that entire individuals are sampled rather than
133-
random rows.
134-
:return causal_test_result: A CausalTestResult for the executed causal test case.
135+
random rows.
135136
"""
136137
if not self.skip:
137138
try:
@@ -161,7 +162,8 @@ def estimate_effect(self, df: pd.DataFrame) -> CausalTestResult:
161162
Execute a causal test case and return the causal test result.
162163
163164
:param df: The data to use.
164-
:return causal_test_result: A CausalTestResult for the executed causal test case.
165+
166+
:returns: A CausalTestResult for the executed causal test case.
165167
"""
166168
if self.query:
167169
df = df.query(self.query)

docs/source/modules/estimators.rst

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ LogisticRegressionEstimator
3131
:noindex:
3232

3333
MultinomialRegressionEstimator
34-
~~~~~~~~~~~~~~~~~~~~~~~~~~~
34+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3535

3636
**Recommended use:** For categorical outcomes (e.g. colurs: Red, Green, Blue).
3737

@@ -42,19 +42,6 @@ MultinomialRegressionEstimator
4242
:show-inheritance:
4343
:noindex:
4444

45-
CubicSplineRegressionEstimator
46-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
47-
48-
**Recommended use:** For continuous outcomes with non-linear relationships or changes in behaviour.
49-
Useful when the relationship between treatment and outcome cannot be captured by a linear model.
50-
51-
.. autoclass:: causal_testing.estimation.cubic_spline_estimator.CubicSplineRegressionEstimator
52-
:members:
53-
:undoc-members:
54-
:show-inheritance:
55-
:noindex:
56-
57-
5845
InstrumentalVariableEstimator
5946
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6047

0 commit comments

Comments
 (0)