You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/installation.rst
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -95,11 +95,11 @@ Next Steps
95
95
* Read about :doc:`modules/causal_specification` to understand causal specifications and :doc:`modules/causal_testing` for the end-to-end causal testing process.
96
96
* Run the command for guidance on how to generate your causal tests directly from your input DAG::
97
97
98
-
python -m causal_testing generate --help
98
+
causal-testing generate --help
99
99
100
100
* and the command on guidance on how to execute your causal tests::
Copy file name to clipboardExpand all lines: docs/source/modules/causal_testing.rst
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,7 @@ In the following sections, we describe the end-to-end process of ``causal testin
34
34
In particular, suppose we're interested in how various precautions, such as hand-washing and mask-wearing, can prevent the spread of a virus within a classroom.
35
35
36
36
1. Modelling Scenario
37
-
----------------
37
+
---------------------
38
38
39
39
For our modelling scenario, suppose we define the scenario with the following constraints:
If the supported :ref:`estimators` are not sufficient for your needs, you can implement your own custom estimator by extending the :code:`Estimator` class and implementing the abstract :code:`add_modelling_assumptions` method and the estimation method for the causal effect measure you wish to calculate.
5
+
For example, if you wished to estimate the ATE using the empirical mean of the recorded outcome under the control and treatment values, you would need to implement a method called :code:`estimate_ate`.
6
+
If you wished to estimate the risk ratio, you would need to call your method :code:`estimate_risk_ratio`.
7
+
The code for the :code:`EmpiricalMeanEstimator` is shown below.
8
+
9
+
.. code-block:: python
10
+
11
+
from causal_testing.estimation.abstract_estimator import Estimator
12
+
from scipy.stats import bootstrap
13
+
14
+
classEmpiricalMeanEstimator(Estimator):
15
+
"""
16
+
Custom estimator class to estimate the causal effect based on the empirical mean.
17
+
"""
18
+
19
+
defadd_modelling_assumptions(self):
20
+
"""
21
+
Add modelling assumptions to the estimator. This is a list of strings which list the modelling assumptions that
22
+
must hold if the resulting causal inference is to be considered valid.
23
+
"""
24
+
self.modelling_assumptions +="The data must contain runs with the exact configuration of interest."
25
+
26
+
defestimate_ate(self) -> EffectEstimate:
27
+
"""Estimate the outcomes under control and treatment.
Once you have implemented your estimator, you will need to register it as an extra entry point in your project's :code:`pyproject.toml` file so that the Causal Testing Framework can find it.
50
+
For example, if you had defined your :code:`EmpiricalMeanEstimator` class in a module called :code:`empirical_mean_estimator` in a folder called :code:`custom_estimators`, you would register it as follows.
51
+
You will also need to reinstall your project, e.g. with :code:`pip install -e .` each time you add a new estimator to your :code:`pyproject.toml`.
52
+
You do not need to reinstall each time you edit your project for source code edits.
Of course, for this to work, your module needs to be discoverable on your python path.
61
+
That is, you should be able to execute :code:`from custom_estimators.empirical_mean_estimator import EmpiricalMeanEstimator` successfully from within the current working directory.
62
+
63
+
You can also add your custom estimator to causal test cases specified in JSON.
64
+
To do so, you can simply set the :code:`estimator` property to the name of your estimator class and the :code:`estimate_type` property to the name of your causal effect measure.
65
+
In the above :code:`EmpiricalMeanEstimator` example, :code:`estimator` would be set to :code:`"EmpiricalMeanEstimator"` and :code:`estimate_type` would be set to :code:`"ate"`.
0 commit comments