repo_name
stringlengths
8
38
pr_number
int64
3
47.1k
pr_title
stringlengths
8
175
pr_description
stringlengths
2
19.8k
author
null
date_created
stringlengths
25
25
date_merged
stringlengths
25
25
filepath
stringlengths
6
136
before_content
stringlengths
54
884k
after_content
stringlengths
56
884k
pr_author
stringlengths
3
21
previous_commit
stringlengths
40
40
pr_commit
stringlengths
40
40
comment
stringlengths
2
25.4k
comment_author
stringlengths
3
29
__index_level_0__
int64
0
5.1k
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
docs/source/example_notebooks/sensitivity_analysis_nonparametric_estimators.ipynb
{ "cells": [ { "cell_type": "markdown", "id": "0bbaacaa", "metadata": {}, "source": [ "# Sensitivity analysis for non-parametric causal estimators\n", "Sensitivity analysis helps us study how robust an estimated effect is when the assumption of no unobserved confounding is violated. That is, how ...
{ "cells": [ { "cell_type": "markdown", "id": "0bbaacaa", "metadata": {}, "source": [ "# Sensitivity analysis for non-parametric causal estimators\n", "Sensitivity analysis helps us study how robust an estimated effect is when the assumption of no unobserved confounding is violated. That is, how ...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
it will change with every commit we modify the notebook (if we are using vscode)
andresmor-ms
184
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimator.py
import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy import causal_estimators from dowhy.causal_graph import CausalGraph from do...
import copy import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy.causal_identifier.identified_estimand import IdentifiedEstimand...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
some methods do support multiple treatments. especially the EconML ones. That's why we always pass the treatment list, as you can see. whereas for outcome, we pass the first element of the list
amit-sharma
185
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimator.py
import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy import causal_estimators from dowhy.causal_graph import CausalGraph from do...
import copy import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy.causal_identifier.identified_estimand import IdentifiedEstimand...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
docstring `treatment` should be `treatment_name`.
amit-sharma
186
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimator.py
import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy import causal_estimators from dowhy.causal_graph import CausalGraph from do...
import copy import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy.causal_identifier.identified_estimand import IdentifiedEstimand...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
Changing the value of `need_conditional_estimates` is a side-effect of this method. Will be good to mention in the docstring.
amit-sharma
187
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimator.py
import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy import causal_estimators from dowhy.causal_graph import CausalGraph from do...
import copy import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy.causal_identifier.identified_estimand import IdentifiedEstimand...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
In the old code, the `estimate` param was used to initialize the different variables. But now we are using the `self` object. The estimate param becomes redundant. We can remove it
amit-sharma
188
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimator.py
import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy import causal_estimators from dowhy.causal_graph import CausalGraph from do...
import copy import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy.causal_identifier.identified_estimand import IdentifiedEstimand...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
why is the typehint in quotes?
amit-sharma
189
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimator.py
import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy import causal_estimators from dowhy.causal_graph import CausalGraph from do...
import copy import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy.causal_identifier.identified_estimand import IdentifiedEstimand...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
should we define the signature of fit and effect methods here so that the signature is enforced for child estimators? We can simply return "raise NotImplementedError" --conveying that child classes have to implement this method.
amit-sharma
190
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimator.py
import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy import causal_estimators from dowhy.causal_graph import CausalGraph from do...
import copy import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy.causal_identifier.identified_estimand import IdentifiedEstimand...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
docstring needs to be updated. * estimator is not referenced.
amit-sharma
191
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimator.py
import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy import causal_estimators from dowhy.causal_graph import CausalGraph from do...
import copy import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy.causal_identifier.identified_estimand import IdentifiedEstimand...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
why is identified_estimand removed from the params? Logically, a user should provide the output of identify_effect to this function. I see that you are using the estimator's target_estimand, but then having a str parameter feels odd. What are the possible values for identifier name? Rather than identifier_name, I ...
amit-sharma
192
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimator.py
import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy import causal_estimators from dowhy.causal_graph import CausalGraph from do...
import copy import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy.causal_identifier.identified_estimand import IdentifiedEstimand...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
test_significance is not used anywhere in this method. It should be passed to the estimator.
amit-sharma
193
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimator.py
import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy import causal_estimators from dowhy.causal_graph import CausalGraph from do...
import copy import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy.causal_identifier.identified_estimand import IdentifiedEstimand...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
can rename it to `get_new_estimator_object` to make it clear that it is not returning the same old estimator, since it is an instance method now
amit-sharma
194
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimator.py
import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy import causal_estimators from dowhy.causal_graph import CausalGraph from do...
import copy import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy.causal_identifier.identified_estimand import IdentifiedEstimand...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
fit_estimator is not needed. We can remove the `fit` code from this method and expect refuters to call it explicitly.
amit-sharma
195
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimator.py
import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy import causal_estimators from dowhy.causal_graph import CausalGraph from do...
import copy import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy.causal_identifier.identified_estimand import IdentifiedEstimand...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
in the docstring below, need to update how estimator is provided. Providing strings is not allowed.
amit-sharma
196
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimator.py
import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy import causal_estimators from dowhy.causal_graph import CausalGraph from do...
import copy import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy.causal_identifier.identified_estimand import IdentifiedEstimand...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
Oh, I copied this comment from: https://github.com/py-why/dowhy/blob/main/dowhy/causal_estimator.py#L109 I guess that it is a legacy comment that was never removed? If that's the case I'll need to update the types for all treatment parameters and the docs, because from the text of it (at least to me) it says that i...
andresmor-ms
197
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimator.py
import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy import causal_estimators from dowhy.causal_graph import CausalGraph from do...
import copy import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy.causal_identifier.identified_estimand import IdentifiedEstimand...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
This is a forward reference, since CausalEstimate is defined below the CausalEstimator class we need to do use the quotes, otherwise we get a syntax error https://peps.python.org/pep-0484/#forward-references
andresmor-ms
198
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimator.py
import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy import causal_estimators from dowhy.causal_graph import CausalGraph from do...
import copy import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy.causal_identifier.identified_estimand import IdentifiedEstimand...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
The issue with creating abstract methods here is that we would essentially set the method signature (including parameters) so we would make all the effect and fit methods take the same parameters for all estimators (preventing new estimators to take different parameters or having a bunch of unneeded parameters in all e...
andresmor-ms
199
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimator.py
import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy import causal_estimators from dowhy.causal_graph import CausalGraph from do...
import copy import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy.causal_identifier.identified_estimand import IdentifiedEstimand...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
What information from the removed parameter are we missing from the estimator target_estimand? shouldn't they be the same? the identifier name replaces the first part of the previous parameter `method_name` which was a string. According to the docs it: > Currently requires an explicit method name to be specified. Me...
andresmor-ms
200
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimator.py
import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy import causal_estimators from dowhy.causal_graph import CausalGraph from do...
import copy import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy.causal_identifier.identified_estimand import IdentifiedEstimand...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
got it, I understand the motivation now.
amit-sharma
201
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimator.py
import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy import causal_estimators from dowhy.causal_graph import CausalGraph from do...
import copy import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy.causal_identifier.identified_estimand import IdentifiedEstimand...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
oh I see. yeah, that's my bad. I may have updated the code without the docstring. But yes, we do support multiple treatments for some methods, that's why treatment is always passed as a list.
amit-sharma
202
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimator.py
import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy import causal_estimators from dowhy.causal_graph import CausalGraph from do...
import copy import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy.causal_identifier.identified_estimand import IdentifiedEstimand...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
Good point. There's another case to consider, where a user will not provide any estimator and the function will automatically find the right Estimator and initialize it. This is the direction we'll be moving in the future. In that case, we would need the `identified_estimand` parameter. Also, the identifier_name par...
amit-sharma
203
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimator.py
import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy import causal_estimators from dowhy.causal_graph import CausalGraph from do...
import copy import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy.causal_identifier.identified_estimand import IdentifiedEstimand...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
Can we avoid this method? At least, I think we should not make it part of the contract of a `CausalEstimator`. If some implementation of `CausalEstimator` needs the data after `fit`, that specific implementation is still free to store it. I think having such a method is too inviting to get into the business of very ...
petergtz
204
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimator.py
import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy import causal_estimators from dowhy.causal_graph import CausalGraph from do...
import copy import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy.causal_identifier.identified_estimand import IdentifiedEstimand...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
This is similar to `set_data` above. Since it seems like this is common functionality needed in multiple places, how about defining a module-based (not class-based): ```python def `effect_modifiers(effect_modifier_names: ...) -> Tuple[... , ... ,...]: ... ``` and then calling it in those places where it is n...
petergtz
205
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimator.py
import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy import causal_estimators from dowhy.causal_graph import CausalGraph from do...
import copy import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy.causal_identifier.identified_estimand import IdentifiedEstimand...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
Good point. I think we can avoid storing these data-based objects completely. For context, the earlier version had this code inside the init method of the estimator. But now the init method does not get access to the data, only fit method gets access to the data (as in sklearn API). That's why this method needed to...
amit-sharma
206
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimator.py
import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy import causal_estimators from dowhy.causal_graph import CausalGraph from do...
import copy import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy.causal_identifier.identified_estimand import IdentifiedEstimand...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
I'll take a look at this, I tried to do this in a previous version but found out that self._data was used in several places and decided to go with setting self._data and focus on getting the fit() to work correctly, if this becomes a big change, would you agree that it could go into another PR? @amit-sharma @petergtz
andresmor-ms
207
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimator.py
import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy import causal_estimators from dowhy.causal_graph import CausalGraph from do...
import copy import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy.causal_identifier.identified_estimand import IdentifiedEstimand...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
That's a good idea, tbh I didn't like the `set_*` methods I created, but as I mentioned in a comment before I was focusing on getting the fit() to work correctly :)
andresmor-ms
208
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimator.py
import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy import causal_estimators from dowhy.causal_graph import CausalGraph from do...
import copy import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy.causal_identifier.identified_estimand import IdentifiedEstimand...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
Agree with @amit-sharma that ideally we wouldn't have to store this data at all. But to avoid delaying this PR too much, I'd be fine by simply renaming this method to `_set_data` to make it very explicit, that this is not part of the API of that class.
petergtz
209
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimator.py
import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy import causal_estimators from dowhy.causal_graph import CausalGraph from do...
import copy import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy.causal_identifier.identified_estimand import IdentifiedEstimand...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
yeah, let's just make the `set` methods as private for this PR, as Peter suggested. This will be work for a future PR
amit-sharma
210
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimator.py
import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy import causal_estimators from dowhy.causal_graph import CausalGraph from do...
import copy import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy.causal_identifier.identified_estimand import IdentifiedEstimand...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
`test_significance` is used only on the estimate.add_params, this is because at this point the Estimator is already instantiated by the CausalModel and the `test_significance` was already passed by the `CausalModel.estimate_effect` method, we don't need them as parameter here
andresmor-ms
211
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimator.py
import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy import causal_estimators from dowhy.causal_graph import CausalGraph from do...
import copy import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy.causal_identifier.identified_estimand import IdentifiedEstimand...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
okay, let's move this discussion for the next PR.
amit-sharma
212
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimators/distance_matching_estimator.py
import numpy as np import pandas as pd from sklearn.neighbors import NearestNeighbors from dowhy.causal_estimator import CausalEstimate, CausalEstimator class DistanceMatchingEstimator(CausalEstimator): """Simple matching estimator for binary treatments based on a distance metric. For a list of standard...
from typing import Any, List, Optional, Union import numpy as np import pandas as pd from sklearn.neighbors import NearestNeighbors from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_identifier import IdentifiedEstimand class DistanceMatchingEstimator(CausalEstimator): """Simpl...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
need a docstring for this method.
amit-sharma
213
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimators/distance_matching_estimator.py
import numpy as np import pandas as pd from sklearn.neighbors import NearestNeighbors from dowhy.causal_estimator import CausalEstimate, CausalEstimator class DistanceMatchingEstimator(CausalEstimator): """Simple matching estimator for binary treatments based on a distance metric. For a list of standard...
from typing import Any, List, Optional, Union import numpy as np import pandas as pd from sklearn.neighbors import NearestNeighbors from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_identifier import IdentifiedEstimand class DistanceMatchingEstimator(CausalEstimator): """Simpl...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
Also, how do you feel about renaming this instance method to simply "effect"? Its shorter and the meaning is clear because we do `Estimator.effect()`. If you agree we can change it for all estimators.
amit-sharma
214
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimators/distance_matching_estimator.py
import numpy as np import pandas as pd from sklearn.neighbors import NearestNeighbors from dowhy.causal_estimator import CausalEstimate, CausalEstimator class DistanceMatchingEstimator(CausalEstimator): """Simple matching estimator for binary treatments based on a distance metric. For a list of standard...
from typing import Any, List, Optional, Union import numpy as np import pandas as pd from sklearn.neighbors import NearestNeighbors from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_identifier import IdentifiedEstimand class DistanceMatchingEstimator(CausalEstimator): """Simpl...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
I like it, I just didn't know if we actually wanted to rename it. I'll rename it in the estimators but leave the estimate_effect method name in the CausalModel otherwise we might break backwards compatibility.
andresmor-ms
215
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimators/distance_matching_estimator.py
import numpy as np import pandas as pd from sklearn.neighbors import NearestNeighbors from dowhy.causal_estimator import CausalEstimate, CausalEstimator class DistanceMatchingEstimator(CausalEstimator): """Simple matching estimator for binary treatments based on a distance metric. For a list of standard...
from typing import Any, List, Optional, Union import numpy as np import pandas as pd from sklearn.neighbors import NearestNeighbors from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_identifier import IdentifiedEstimand class DistanceMatchingEstimator(CausalEstimator): """Simpl...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
That sounds good!
amit-sharma
216
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimators/distance_matching_estimator.py
import numpy as np import pandas as pd from sklearn.neighbors import NearestNeighbors from dowhy.causal_estimator import CausalEstimate, CausalEstimator class DistanceMatchingEstimator(CausalEstimator): """Simple matching estimator for binary treatments based on a distance metric. For a list of standard...
from typing import Any, List, Optional, Union import numpy as np import pandas as pd from sklearn.neighbors import NearestNeighbors from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_identifier import IdentifiedEstimand class DistanceMatchingEstimator(CausalEstimator): """Simpl...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
Will rename in future PR as there are other places where the `effect()` function exist.
andresmor-ms
217
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimators/econml.py
import inspect from importlib import import_module from typing import Callable import numpy as np import pandas as pd from numpy.distutils.misc_util import is_sequence from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.utils.api import parse_state class Econml(CausalEstimator): """Wra...
import inspect from importlib import import_module from typing import Any, Callable, List, Optional, Protocol, Union from warnings import warn import numpy as np import pandas as pd from numpy.distutils.misc_util import is_sequence from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_i...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
needs a docstring
amit-sharma
218
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimators/econml.py
import inspect from importlib import import_module from typing import Callable import numpy as np import pandas as pd from numpy.distutils.misc_util import is_sequence from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.utils.api import parse_state class Econml(CausalEstimator): """Wra...
import inspect from importlib import import_module from typing import Any, Callable, List, Optional, Protocol, Union from warnings import warn import numpy as np import pandas as pd from numpy.distutils.misc_util import is_sequence from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_i...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
Could this already be a `Union[str,EconMLEstimator]` where `EconMLEstimator` is something along the lines of: ```python class EconMLEstimator(Protocol): def estimate(self, ...): ... ... ``` Then, when actually using this, you could check if it's a string or not. Long-term, we could deprecate ...
petergtz
219
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimators/econml.py
import inspect from importlib import import_module from typing import Callable import numpy as np import pandas as pd from numpy.distutils.misc_util import is_sequence from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.utils.api import parse_state class Econml(CausalEstimator): """Wra...
import inspect from importlib import import_module from typing import Any, Callable, List, Optional, Protocol, Union from warnings import warn import numpy as np import pandas as pd from numpy.distutils.misc_util import is_sequence from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_i...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
+1 This is a good idea to maintain backwards compatibility while still following the new API.
amit-sharma
220
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimators/econml.py
import inspect from importlib import import_module from typing import Callable import numpy as np import pandas as pd from numpy.distutils.misc_util import is_sequence from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.utils.api import parse_state class Econml(CausalEstimator): """Wra...
import inspect from importlib import import_module from typing import Any, Callable, List, Optional, Protocol, Union from warnings import warn import numpy as np import pandas as pd from numpy.distutils.misc_util import is_sequence from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_i...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
Yep, I actually created an example of this to show Amit some days ago :) I think we could even deprecate the string now and move the code that creates an econml instance from the string to the CausalModel estimate_effect class, what do you think? @petergtz And this also applies to the CausalML estimator
andresmor-ms
221
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimators/econml.py
import inspect from importlib import import_module from typing import Callable import numpy as np import pandas as pd from numpy.distutils.misc_util import is_sequence from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.utils.api import parse_state class Econml(CausalEstimator): """Wra...
import inspect from importlib import import_module from typing import Any, Callable, List, Optional, Protocol, Union from warnings import warn import numpy as np import pandas as pd from numpy.distutils.misc_util import is_sequence from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_i...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
> we could even deprecate the string now and move the code that creates an econml instance from the string to the CausalModel estimate_effect class From a point of getting more concrete on this, I like it. But in terms of backwards compatibility, I'm not sure sure we should already be so bold. But that's mostly depe...
petergtz
222
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimators/econml.py
import inspect from importlib import import_module from typing import Callable import numpy as np import pandas as pd from numpy.distutils.misc_util import is_sequence from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.utils.api import parse_state class Econml(CausalEstimator): """Wra...
import inspect from importlib import import_module from typing import Any, Callable, List, Optional, Protocol, Union from warnings import warn import numpy as np import pandas as pd from numpy.distutils.misc_util import is_sequence from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_i...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
this is nice way of using the protocol!
amit-sharma
223
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimators/econml.py
import inspect from importlib import import_module from typing import Callable import numpy as np import pandas as pd from numpy.distutils.misc_util import is_sequence from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.utils.api import parse_state class Econml(CausalEstimator): """Wra...
import inspect from importlib import import_module from typing import Any, Callable, List, Optional, Protocol, Union from warnings import warn import numpy as np import pandas as pd from numpy.distutils.misc_util import is_sequence from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_i...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
data: dataframe containing the data on which treatment effect is to be estimated. treatment_value: value of the treatment variable for which the effect is to be estimated. control_value: value of the treatment variable that denotes its absence (usually 0) target_units: The units for which the treatment effect should...
amit-sharma
224
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimators/generalized_linear_model_estimator.py
import itertools import statsmodels.api as sm from dowhy.causal_estimators.regression_estimator import RegressionEstimator class GeneralizedLinearModelEstimator(RegressionEstimator): """Compute effect of treatment using a generalized linear model such as logistic regression. Implementation uses statsmodels...
import itertools from typing import Any, List, Optional, Union import pandas as pd import statsmodels.api as sm from dowhy.causal_estimator import CausalEstimator from dowhy.causal_estimators.regression_estimator import RegressionEstimator from dowhy.causal_identifier import IdentifiedEstimand class GeneralizedLine...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
since this is a fit method, `outcome_is_binary` looks out of place. Shall we move it to the `predict_fn` where it is used? Ideally we would want to avoid side-effects of the fit method.
amit-sharma
225
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimators/instrumental_variable_estimator.py
import numpy as np import sympy as sp import sympy.stats as spstats from statsmodels.sandbox.regression.gmm import IV2SLS from dowhy.causal_estimator import CausalEstimate, CausalEstimator, RealizedEstimand from dowhy.utils.api import parse_state class InstrumentalVariableEstimator(CausalEstimator): """Compute e...
from typing import Any, Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp import sympy.stats as spstats from statsmodels.sandbox.regression.gmm import IV2SLS from dowhy.causal_estimator import CausalEstimate, CausalEstimator, RealizedEstimand from dowhy.causal_identifier import Ide...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
empty line can be removed.
amit-sharma
226
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimators/instrumental_variable_estimator.py
import numpy as np import sympy as sp import sympy.stats as spstats from statsmodels.sandbox.regression.gmm import IV2SLS from dowhy.causal_estimator import CausalEstimate, CausalEstimator, RealizedEstimand from dowhy.utils.api import parse_state class InstrumentalVariableEstimator(CausalEstimator): """Compute e...
from typing import Any, Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp import sympy.stats as spstats from statsmodels.sandbox.regression.gmm import IV2SLS from dowhy.causal_estimator import CausalEstimate, CausalEstimator, RealizedEstimand from dowhy.causal_identifier import Ide...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
needs docstring
amit-sharma
227
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimators/instrumental_variable_estimator.py
import numpy as np import sympy as sp import sympy.stats as spstats from statsmodels.sandbox.regression.gmm import IV2SLS from dowhy.causal_estimator import CausalEstimate, CausalEstimator, RealizedEstimand from dowhy.utils.api import parse_state class InstrumentalVariableEstimator(CausalEstimator): """Compute e...
from typing import Any, Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp import sympy.stats as spstats from statsmodels.sandbox.regression.gmm import IV2SLS from dowhy.causal_estimator import CausalEstimate, CausalEstimator, RealizedEstimand from dowhy.causal_identifier import Ide...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
effect modifiers are not used by IV method. Can update the docstring and say that effect_modifiers are not supported. Shall we also raise a valueerror here if a user provides them?
amit-sharma
228
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimators/instrumental_variable_estimator.py
import numpy as np import sympy as sp import sympy.stats as spstats from statsmodels.sandbox.regression.gmm import IV2SLS from dowhy.causal_estimator import CausalEstimate, CausalEstimator, RealizedEstimand from dowhy.utils.api import parse_state class InstrumentalVariableEstimator(CausalEstimator): """Compute e...
from typing import Any, Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp import sympy.stats as spstats from statsmodels.sandbox.regression.gmm import IV2SLS from dowhy.causal_estimator import CausalEstimate, CausalEstimator, RealizedEstimand from dowhy.causal_identifier import Ide...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
I think it is a better idea to just remove it since it is not used.
andresmor-ms
229
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimators/instrumental_variable_estimator.py
import numpy as np import sympy as sp import sympy.stats as spstats from statsmodels.sandbox.regression.gmm import IV2SLS from dowhy.causal_estimator import CausalEstimate, CausalEstimator, RealizedEstimand from dowhy.utils.api import parse_state class InstrumentalVariableEstimator(CausalEstimator): """Compute e...
from typing import Any, Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp import sympy.stats as spstats from statsmodels.sandbox.regression.gmm import IV2SLS from dowhy.causal_estimator import CausalEstimate, CausalEstimator, RealizedEstimand from dowhy.causal_identifier import Ide...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
If I remove this the tests will fail, I'll remove it as part of another PR once this one is completed.
andresmor-ms
230
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimators/propensity_score_estimator.py
import numpy as np import pandas as pd from sklearn import linear_model from sklearn.exceptions import NotFittedError from dowhy.causal_estimator import CausalEstimator class PropensityScoreEstimator(CausalEstimator): """ Base class for estimators that estimate effects based on propensity of treatment as...
from typing import Any, List, Optional, Union import numpy as np import pandas as pd from sklearn import linear_model from sklearn.exceptions import NotFittedError from dowhy.causal_estimator import CausalEstimator from dowhy.causal_identifier import IdentifiedEstimand class PropensityScoreEstimator(CausalEstimator...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
we do not need this parameter now, recalculate_propensity_score, because we have separate fit and estimate. can remove this
amit-sharma
231
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimators/propensity_score_estimator.py
import numpy as np import pandas as pd from sklearn import linear_model from sklearn.exceptions import NotFittedError from dowhy.causal_estimator import CausalEstimator class PropensityScoreEstimator(CausalEstimator): """ Base class for estimators that estimate effects based on propensity of treatment as...
from typing import Any, List, Optional, Union import numpy as np import pandas as pd from sklearn import linear_model from sklearn.exceptions import NotFittedError from dowhy.causal_estimator import CausalEstimator from dowhy.causal_identifier import IdentifiedEstimand class PropensityScoreEstimator(CausalEstimator...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
This method needs to be wrapped inside/moved to the fit method. It was useful earlier to prevent re-fitting because we did not have an explicit fit method. We need to support three usecases in the fit method: 1. user provides their own scores in the propensity_score_column of dataframe. In that case, fit is a no...
amit-sharma
232
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimators/propensity_score_matching_estimator.py
import pandas as pd from sklearn import linear_model from sklearn.neighbors import NearestNeighbors from dowhy.causal_estimator import CausalEstimate from dowhy.causal_estimators.propensity_score_estimator import PropensityScoreEstimator class PropensityScoreMatchingEstimator(PropensityScoreEstimator): """Estima...
from typing import Any, List, Optional, Union import pandas as pd from sklearn.neighbors import NearestNeighbors from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_estimators.propensity_score_estimator import PropensityScoreEstimator from dowhy.causal_identifier import IdentifiedEsti...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
The line below, "For a list of standards args and kwargs" , can be removed.
amit-sharma
233
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimators/propensity_score_matching_estimator.py
import pandas as pd from sklearn import linear_model from sklearn.neighbors import NearestNeighbors from dowhy.causal_estimator import CausalEstimate from dowhy.causal_estimators.propensity_score_estimator import PropensityScoreEstimator class PropensityScoreMatchingEstimator(PropensityScoreEstimator): """Estima...
from typing import Any, List, Optional, Union import pandas as pd from sklearn.neighbors import NearestNeighbors from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_estimators.propensity_score_estimator import PropensityScoreEstimator from dowhy.causal_identifier import IdentifiedEsti...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
do not need recalculate_ps param
amit-sharma
234
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimators/propensity_score_matching_estimator.py
import pandas as pd from sklearn import linear_model from sklearn.neighbors import NearestNeighbors from dowhy.causal_estimator import CausalEstimate from dowhy.causal_estimators.propensity_score_estimator import PropensityScoreEstimator class PropensityScoreMatchingEstimator(PropensityScoreEstimator): """Estima...
from typing import Any, List, Optional, Union import pandas as pd from sklearn.neighbors import NearestNeighbors from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_estimators.propensity_score_estimator import PropensityScoreEstimator from dowhy.causal_identifier import IdentifiedEsti...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
the code of "refresh propensity score" should be inside the fit function. This logic was created because we did not have a fit method. So refresh method checks whether model is fitted already, if not it fits it. We can remove this refresh function and move its code to the fit method.
amit-sharma
235
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimators/propensity_score_stratification_estimator.py
import pandas as pd from sklearn import linear_model from dowhy.causal_estimator import CausalEstimate from dowhy.causal_estimators.propensity_score_estimator import PropensityScoreEstimator class PropensityScoreStratificationEstimator(PropensityScoreEstimator): """Estimate effect of treatment by stratifying the...
from typing import Any, List, Optional, Union import pandas as pd from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_estimators.propensity_score_estimator import PropensityScoreEstimator from dowhy.causal_identifier import IdentifiedEstimand class PropensityScoreStratificationEstim...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
do not need refresh propensity score here, just the assignment of model's predictions to the propensity score column
amit-sharma
236
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimators/propensity_score_weighting_estimator.py
import numpy as np import pandas as pd from dowhy.causal_estimator import CausalEstimate from dowhy.causal_estimators.propensity_score_estimator import PropensityScoreEstimator class PropensityScoreWeightingEstimator(PropensityScoreEstimator): """Estimate effect of treatment by weighing the data by inverse p...
from typing import Any, List, Optional, Union import numpy as np import pandas as pd from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_estimators.propensity_score_estimator import PropensityScoreEstimator from dowhy.causal_identifier import IdentifiedEstimand class PropensityScore...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
recalculate ps param is not needed.
amit-sharma
237
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimators/propensity_score_weighting_estimator.py
import numpy as np import pandas as pd from dowhy.causal_estimator import CausalEstimate from dowhy.causal_estimators.propensity_score_estimator import PropensityScoreEstimator class PropensityScoreWeightingEstimator(PropensityScoreEstimator): """Estimate effect of treatment by weighing the data by inverse p...
from typing import Any, List, Optional, Union import numpy as np import pandas as pd from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_estimators.propensity_score_estimator import PropensityScoreEstimator from dowhy.causal_identifier import IdentifiedEstimand class PropensityScore...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
same comment for refresh ps method
amit-sharma
238
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimators/regression_discontinuity_estimator.py
import numpy as np import pandas as pd from dowhy.causal_estimator import CausalEstimator from dowhy.causal_estimators.instrumental_variable_estimator import InstrumentalVariableEstimator class RegressionDiscontinuityEstimator(CausalEstimator): """Compute effect of treatment using the regression discontinuity me...
from typing import Any, List, Optional, Union import numpy as np import pandas as pd from dowhy.causal_estimator import CausalEstimator from dowhy.causal_estimators.instrumental_variable_estimator import InstrumentalVariableEstimator from dowhy.causal_identifier import IdentifiedEstimand class RegressionDiscontinui...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
up until this line, it may be better to move the code to the fit method.
amit-sharma
239
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimators/regression_discontinuity_estimator.py
import numpy as np import pandas as pd from dowhy.causal_estimator import CausalEstimator from dowhy.causal_estimators.instrumental_variable_estimator import InstrumentalVariableEstimator class RegressionDiscontinuityEstimator(CausalEstimator): """Compute effect of treatment using the regression discontinuity me...
from typing import Any, List, Optional, Union import numpy as np import pandas as pd from dowhy.causal_estimator import CausalEstimator from dowhy.causal_estimators.instrumental_variable_estimator import InstrumentalVariableEstimator from dowhy.causal_identifier import IdentifiedEstimand class RegressionDiscontinui...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
treatment_value, control_value etc. should be passed to the IV estimate_effect.
amit-sharma
240
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimators/regression_estimator.py
import numpy as np import pandas as pd import statsmodels.api as sm from dowhy.causal_estimator import CausalEstimate, CausalEstimator class RegressionEstimator(CausalEstimator): """Compute effect of treatment using some regression function. Fits a regression model for estimating the outcome using treatment...
from typing import Any, List, Optional, Union import numpy as np import pandas as pd import statsmodels.api as sm from dowhy.causal_estimator import CausalEstimate, CausalEstimator, IdentifiedEstimand class RegressionEstimator(CausalEstimator): """Compute effect of treatment using some regression function. ...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
up until line 126, a model is being fit. All this code should be inside fit method.
amit-sharma
241
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimators/regression_estimator.py
import numpy as np import pandas as pd import statsmodels.api as sm from dowhy.causal_estimator import CausalEstimate, CausalEstimator class RegressionEstimator(CausalEstimator): """Compute effect of treatment using some regression function. Fits a regression model for estimating the outcome using treatment...
from typing import Any, List, Optional, Union import numpy as np import pandas as pd import statsmodels.api as sm from dowhy.causal_estimator import CausalEstimate, CausalEstimator, IdentifiedEstimand class RegressionEstimator(CausalEstimator): """Compute effect of treatment using some regression function. ...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
need docstring
amit-sharma
242
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimators/regression_estimator.py
import numpy as np import pandas as pd import statsmodels.api as sm from dowhy.causal_estimator import CausalEstimate, CausalEstimator class RegressionEstimator(CausalEstimator): """Compute effect of treatment using some regression function. Fits a regression model for estimating the outcome using treatment...
from typing import Any, List, Optional, Union import numpy as np import pandas as pd import statsmodels.api as sm from dowhy.causal_estimator import CausalEstimate, CausalEstimator, IdentifiedEstimand class RegressionEstimator(CausalEstimator): """Compute effect of treatment using some regression function. ...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
it's the same as for econml estimator. Additionally, need_conditional_estimates: Boolean flag on whether treatment effect estimates conditional on the effect modifiers are needed. Otherwise, the average treatment effect is returned.
amit-sharma
243
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimators/two_stage_regression_estimator.py
import copy import itertools import numpy as np import pandas as pd from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_estimators.linear_regression_estimator import LinearRegressionEstimator from dowhy.causal_identifier.identify_effect import EstimandType from dowhy.utils.api import ...
import copy from typing import Any, List, Optional, Type, Union import numpy as np import pandas as pd from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_estimators.linear_regression_estimator import LinearRegressionEstimator from dowhy.causal_identifier import EstimandType, Identifi...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
okay this is a major refactor. I did try to check the details, but I just wanted to confirm the logic: each of these models just change the treatment or outcome column and call the user-provided estimators. Will be good to double-check that the name changes have been done correctly. It looks good to me.
amit-sharma
244
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimators/two_stage_regression_estimator.py
import copy import itertools import numpy as np import pandas as pd from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_estimators.linear_regression_estimator import LinearRegressionEstimator from dowhy.causal_identifier.identify_effect import EstimandType from dowhy.utils.api import ...
import copy from typing import Any, List, Optional, Type, Union import numpy as np import pandas as pd from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_estimators.linear_regression_estimator import LinearRegressionEstimator from dowhy.causal_identifier import EstimandType, Identifi...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
why not change the identifier_method to "backdoor" here? For others, we need the data, but do not need it for this one.
amit-sharma
245
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimators/two_stage_regression_estimator.py
import copy import itertools import numpy as np import pandas as pd from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_estimators.linear_regression_estimator import LinearRegressionEstimator from dowhy.causal_identifier.identify_effect import EstimandType from dowhy.utils.api import ...
import copy from typing import Any, List, Optional, Type, Union import numpy as np import pandas as pd from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_estimators.linear_regression_estimator import LinearRegressionEstimator from dowhy.causal_identifier import EstimandType, Identifi...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
both these lines can be moved to the init method. Will make code easier to understand too
amit-sharma
246
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimators/two_stage_regression_estimator.py
import copy import itertools import numpy as np import pandas as pd from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_estimators.linear_regression_estimator import LinearRegressionEstimator from dowhy.causal_identifier.identify_effect import EstimandType from dowhy.utils.api import ...
import copy from typing import Any, List, Optional, Type, Union import numpy as np import pandas as pd from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_estimators.linear_regression_estimator import LinearRegressionEstimator from dowhy.causal_identifier import EstimandType, Identifi...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
these lines can be moved to the init method since they are part of initializing the model correctly.
amit-sharma
247
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_estimators/two_stage_regression_estimator.py
import copy import itertools import numpy as np import pandas as pd from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_estimators.linear_regression_estimator import LinearRegressionEstimator from dowhy.causal_identifier.identify_effect import EstimandType from dowhy.utils.api import ...
import copy from typing import Any, List, Optional, Type, Union import numpy as np import pandas as pd from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_estimators.linear_regression_estimator import LinearRegressionEstimator from dowhy.causal_identifier import EstimandType, Identifi...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
these lines can also be moved to init. Essentially, init creates the constructor for all these estimators. And then fit just fits them.
amit-sharma
248
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_model.py
""" Module containing the main model class for the dowhy package. """ import logging from itertools import combinations from sympy import init_printing import dowhy.causal_estimators as causal_estimators import dowhy.causal_refuters as causal_refuters import dowhy.graph_learners as graph_learners import dowhy.utils....
""" Module containing the main model class for the dowhy package. """ import logging from itertools import combinations from sympy import init_printing import dowhy.causal_estimators as causal_estimators import dowhy.causal_refuters as causal_refuters import dowhy.graph_learners as graph_learners import dowhy.utils....
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
If I understand correctly, we do not pass the actual params here because we expect the `estimate_effect` call to take care of it, right?
amit-sharma
249
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_model.py
""" Module containing the main model class for the dowhy package. """ import logging from itertools import combinations from sympy import init_printing import dowhy.causal_estimators as causal_estimators import dowhy.causal_refuters as causal_refuters import dowhy.graph_learners as graph_learners import dowhy.utils....
""" Module containing the main model class for the dowhy package. """ import logging from itertools import combinations from sympy import init_printing import dowhy.causal_estimators as causal_estimators import dowhy.causal_refuters as causal_refuters import dowhy.graph_learners as graph_learners import dowhy.utils....
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
extra_args should also be passed to estimate_effect? Right now, they are ignored.
amit-sharma
250
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_model.py
""" Module containing the main model class for the dowhy package. """ import logging from itertools import combinations from sympy import init_printing import dowhy.causal_estimators as causal_estimators import dowhy.causal_refuters as causal_refuters import dowhy.graph_learners as graph_learners import dowhy.utils....
""" Module containing the main model class for the dowhy package. """ import logging from itertools import combinations from sympy import init_printing import dowhy.causal_estimators as causal_estimators import dowhy.causal_refuters as causal_refuters import dowhy.graph_learners as graph_learners import dowhy.utils....
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
Yep, here we are initializing the estimator, just creating it, then we need to call `fit()` and then `estimate_effect()`
andresmor-ms
251
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_model.py
""" Module containing the main model class for the dowhy package. """ import logging from itertools import combinations from sympy import init_printing import dowhy.causal_estimators as causal_estimators import dowhy.causal_refuters as causal_refuters import dowhy.graph_learners as graph_learners import dowhy.utils....
""" Module containing the main model class for the dowhy package. """ import logging from itertools import combinations from sympy import init_printing import dowhy.causal_estimators as causal_estimators import dowhy.causal_refuters as causal_refuters import dowhy.graph_learners as graph_learners import dowhy.utils....
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
`extra_args` is only used for `init_params` which is used to instantiate estimators, method_params are the extra parameters for executing the estimate_effect method
andresmor-ms
252
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_refuters/add_unobserved_common_cause.py
import copy import logging import math from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import scipy.stats import statsmodels.api as sm from sklearn.linear_model import LogisticRegression from sklearn.preprocessing import StandardScaler from tqdm.auto import tqdm from dowhy.causal...
import copy import logging import math from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import scipy.stats import statsmodels.api as sm from sklearn.linear_model import LogisticRegression from sklearn.preprocessing import StandardScaler from tqdm.auto import tqdm from dowhy.causal...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
add fit call for all estimators.
amit-sharma
253
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_refuters/bootstrap_refuter.py
import logging import random from typing import List, Optional, Union import numpy as np import pandas as pd from joblib import Parallel, delayed from sklearn.utils import resample from tqdm.auto import tqdm from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_identifier.identified_est...
import logging import random from typing import List, Optional, Union import numpy as np import pandas as pd from joblib import Parallel, delayed from sklearn.utils import resample from tqdm.auto import tqdm from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_estimators.econml import ...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
I think we should have an explicit fit method here, to be consistent with the new API.
amit-sharma
254
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_refuters/bootstrap_refuter.py
import logging import random from typing import List, Optional, Union import numpy as np import pandas as pd from joblib import Parallel, delayed from sklearn.utils import resample from tqdm.auto import tqdm from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_identifier.identified_est...
import logging import random from typing import List, Optional, Union import numpy as np import pandas as pd from joblib import Parallel, delayed from sklearn.utils import resample from tqdm.auto import tqdm from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_estimators.econml import ...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
and then make sure that the right effect modifiers and other parameters are passed to the fit method.
amit-sharma
255
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_refuters/data_subset_refuter.py
import logging from typing import Optional, Union import numpy as np import pandas as pd from joblib import Parallel, delayed from tqdm.auto import tqdm from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_identifier import IdentifiedEstimand from dowhy.causal_refuter import CausalRefu...
import logging from typing import Optional, Union import numpy as np import pandas as pd from joblib import Parallel, delayed from tqdm.auto import tqdm from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_estimators.econml import Econml from dowhy.causal_identifier import IdentifiedEs...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
add fit method. Same comment for all refuters.
amit-sharma
256
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_refuters/placebo_treatment_refuter.py
import copy import logging from enum import Enum from typing import Dict, List, Optional, Union import numpy as np import pandas as pd from joblib import Parallel, delayed from tqdm.auto import tqdm from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_identifier.identified_estimand imp...
import copy import logging from enum import Enum from typing import Dict, List, Optional, Union import numpy as np import pandas as pd from joblib import Parallel, delayed from tqdm.auto import tqdm from dowhy.causal_estimator import CausalEstimate from dowhy.causal_estimators.econml import Econml from dowhy.causal_e...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
do we need this InstrumentalVariableEstimator import?
amit-sharma
257
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_refuters/placebo_treatment_refuter.py
import copy import logging from enum import Enum from typing import Dict, List, Optional, Union import numpy as np import pandas as pd from joblib import Parallel, delayed from tqdm.auto import tqdm from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_identifier.identified_estimand imp...
import copy import logging from enum import Enum from typing import Dict, List, Optional, Union import numpy as np import pandas as pd from joblib import Parallel, delayed from tqdm.auto import tqdm from dowhy.causal_estimator import CausalEstimate from dowhy.causal_estimators.econml import Econml from dowhy.causal_e...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
why is this IV code removed? is it redundant?
amit-sharma
258
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_refuters/placebo_treatment_refuter.py
import copy import logging from enum import Enum from typing import Dict, List, Optional, Union import numpy as np import pandas as pd from joblib import Parallel, delayed from tqdm.auto import tqdm from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_identifier.identified_estimand imp...
import copy import logging from enum import Enum from typing import Dict, List, Optional, Union import numpy as np import pandas as pd from joblib import Parallel, delayed from tqdm.auto import tqdm from dowhy.causal_estimator import CausalEstimate from dowhy.causal_estimators.econml import Econml from dowhy.causal_e...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
it is used now by updating a piece of code i removed by mistake
andresmor-ms
259
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
dowhy/causal_refuters/placebo_treatment_refuter.py
import copy import logging from enum import Enum from typing import Dict, List, Optional, Union import numpy as np import pandas as pd from joblib import Parallel, delayed from tqdm.auto import tqdm from dowhy.causal_estimator import CausalEstimate, CausalEstimator from dowhy.causal_identifier.identified_estimand imp...
import copy import logging from enum import Enum from typing import Dict, List, Optional, Union import numpy as np import pandas as pd from joblib import Parallel, delayed from tqdm.auto import tqdm from dowhy.causal_estimator import CausalEstimate from dowhy.causal_estimators.econml import Econml from dowhy.causal_e...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
good catch, I removed it by mistake.
andresmor-ms
260
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
poetry.lock
[[package]] name = "absl-py" version = "1.3.0" description = "Abseil Python Common Libraries, see https://github.com/abseil/abseil-py." category = "dev" optional = false python-versions = ">=3.6" [[package]] name = "alabaster" version = "0.7.12" description = "A configurable sidebar-enabled Sphinx theme" category = "m...
[[package]] name = "absl-py" version = "1.3.0" description = "Abseil Python Common Libraries, see https://github.com/abseil/abseil-py." category = "dev" optional = false python-versions = ">=3.6" [[package]] name = "alabaster" version = "0.7.12" description = "A configurable sidebar-enabled Sphinx theme" category = "m...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
I'm assuming that this file is auto-generated and doesn't need my review, right?
amit-sharma
261
py-why/dowhy
746
Functional api/causal estimators
* Introduce `fit()` method to estimators. * Refactor constructors to avoid using `*args` and `**kwargs` and have more explicit parameters. * Refactor refuters and other parts of the code to use `fit()` and modify arguments to `estimate_effect()`
null
2022-11-04 16:15:39+00:00
2022-12-03 17:07:53+00:00
poetry.lock
[[package]] name = "absl-py" version = "1.3.0" description = "Abseil Python Common Libraries, see https://github.com/abseil/abseil-py." category = "dev" optional = false python-versions = ">=3.6" [[package]] name = "alabaster" version = "0.7.12" description = "A configurable sidebar-enabled Sphinx theme" category = "m...
[[package]] name = "absl-py" version = "1.3.0" description = "Abseil Python Common Libraries, see https://github.com/abseil/abseil-py." category = "dev" optional = false python-versions = ">=3.6" [[package]] name = "alabaster" version = "0.7.12" description = "A configurable sidebar-enabled Sphinx theme" category = "m...
andresmor-ms
11c4e0dafd6e824eb81ad14262457d954ae61468
affe0952f4aba6845247355c171565510c2c1673
yep it is autogenerated
andresmor-ms
262
py-why/dowhy
737
Add polynom regressor and classifier to gcm
This replaces the ProductRegressor. Signed-off-by: Patrick Bloebaum <bloebp@amazon.com>
null
2022-11-01 15:56:18+00:00
2022-11-04 17:32:01+00:00
dowhy/gcm/auto.py
import warnings from enum import Enum, auto from functools import partial from typing import Callable, List, Optional, Union import numpy as np import pandas as pd from joblib import Parallel, delayed from sklearn import metrics from sklearn.exceptions import ConvergenceWarning from sklearn.linear_model import LinearR...
import warnings from enum import Enum, auto from functools import partial from typing import Callable, List, Optional, Union import numpy as np import pandas as pd from joblib import Parallel, delayed from sklearn import metrics from sklearn.exceptions import ConvergenceWarning from sklearn.linear_model import LinearR...
bloebp
fb5b4d52606826cd54a0c2436193753ff06c4855
2ed7cf4e93e01de4f16ebd2f66af07196aa1065f
Address the typo `creat_` everywhere.
kailashbuki
263
py-why/dowhy
737
Add polynom regressor and classifier to gcm
This replaces the ProductRegressor. Signed-off-by: Patrick Bloebaum <bloebp@amazon.com>
null
2022-11-01 15:56:18+00:00
2022-11-04 17:32:01+00:00
tests/gcm/test_auto.py
import networkx as nx import numpy as np import pandas as pd from flaky import flaky from sklearn.ensemble import HistGradientBoostingClassifier, HistGradientBoostingRegressor from sklearn.linear_model import ElasticNetCV, LassoCV, LinearRegression, LogisticRegression, RidgeCV from sklearn.naive_bayes import GaussianNB...
import networkx as nx import numpy as np import pandas as pd from flaky import flaky from sklearn.ensemble import HistGradientBoostingClassifier, HistGradientBoostingRegressor from sklearn.linear_model import ElasticNetCV, LassoCV, LinearRegression, LogisticRegression, RidgeCV from sklearn.naive_bayes import GaussianNB...
bloebp
fb5b4d52606826cd54a0c2436193753ff06c4855
2ed7cf4e93e01de4f16ebd2f66af07196aa1065f
Is there a reason why moved to this generative model?
kailashbuki
264
py-why/dowhy
737
Add polynom regressor and classifier to gcm
This replaces the ProductRegressor. Signed-off-by: Patrick Bloebaum <bloebp@amazon.com>
null
2022-11-01 15:56:18+00:00
2022-11-04 17:32:01+00:00
tests/gcm/test_auto.py
import networkx as nx import numpy as np import pandas as pd from flaky import flaky from sklearn.ensemble import HistGradientBoostingClassifier, HistGradientBoostingRegressor from sklearn.linear_model import ElasticNetCV, LassoCV, LinearRegression, LogisticRegression, RidgeCV from sklearn.naive_bayes import GaussianNB...
import networkx as nx import numpy as np import pandas as pd from flaky import flaky from sklearn.ensemble import HistGradientBoostingClassifier, HistGradientBoostingRegressor from sklearn.linear_model import ElasticNetCV, LassoCV, LinearRegression, LogisticRegression, RidgeCV from sklearn.naive_bayes import GaussianNB...
bloebp
fb5b4d52606826cd54a0c2436193753ff06c4855
2ed7cf4e93e01de4f16ebd2f66af07196aa1065f
Wanted to have non-linear data that cannot be capture by a model with polynomial features (here, `X**2` would be captured by it with a degree 2).
bloebp
265
py-why/dowhy
736
Add independence test based on the General Covariance Measure
Signed-off-by: Patrick Bloebaum <bloebp@amazon.com>
null
2022-11-01 01:38:35+00:00
2022-11-22 17:51:14+00:00
dowhy/gcm/independence_test/__init__.py
from .kernel import approx_kernel_based, kernel_based from .regression import regression_based def independence_test(X, Y, conditioned_on=None, method="kernel"): """Performs a (conditional) independence test. Three methods for (conditional) independence test are supported at the moment: * `kernel`: Kerne...
from .general_cov_measure import general_cov_based from .kernel import approx_kernel_based, kernel_based from .regression import regression_based def independence_test(X, Y, conditioned_on=None, method="kernel"): """Performs a (conditional) independence test. Three methods for (conditional) independence test ...
bloebp
d9f27afc18cfec14ffd2e0178f7ba143f409c832
099b8c474c35cc3d528be001e8c49fc16643eebc
Typo: Generalised Covariance Measure
kailashbuki
266
py-why/dowhy
732
Set seed on data generation for deterministic test
* Set seed for deterministic data generation on `dowhy_function_api.ipynb` notebook. * Fix wrong parameters on backwards compatibility example. Fixes #704 Signed-off-by: Andres Morales <andresmor@microsoft.com>
null
2022-10-31 18:37:31+00:00
2022-11-01 15:16:07+00:00
docs/source/example_notebooks/dowhy_functional_api.ipynb
{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Functional API Preview\n", "\n", "This notebook is part of a set of notebooks that provides a preview of the proposed functional API for dowhy. For details on the new API for DoWhy, check out https://github.com/py-why/dowhy/w...
{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Functional API Preview\n", "\n", "This notebook is part of a set of notebooks that provides a preview of the proposed functional API for dowhy. For details on the new API for DoWhy, check out https://github.com/py-why/dowhy/w...
andresmor-ms
b9bab69d737f34fc32a73feb426d0ddc2f471df2
68f5d2b1bc7c5357b243dcef31510cfdc65ff871
Why comment this stuff out? Should we delete it itstead?
darthtrevino
267
py-why/dowhy
732
Set seed on data generation for deterministic test
* Set seed for deterministic data generation on `dowhy_function_api.ipynb` notebook. * Fix wrong parameters on backwards compatibility example. Fixes #704 Signed-off-by: Andres Morales <andresmor@microsoft.com>
null
2022-10-31 18:37:31+00:00
2022-11-01 15:16:07+00:00
docs/source/example_notebooks/dowhy_functional_api.ipynb
{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Functional API Preview\n", "\n", "This notebook is part of a set of notebooks that provides a preview of the proposed functional API for dowhy. For details on the new API for DoWhy, check out https://github.com/py-why/dowhy/w...
{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Functional API Preview\n", "\n", "This notebook is part of a set of notebooks that provides a preview of the proposed functional API for dowhy. For details on the new API for DoWhy, check out https://github.com/py-why/dowhy/w...
andresmor-ms
b9bab69d737f34fc32a73feb426d0ddc2f471df2
68f5d2b1bc7c5357b243dcef31510cfdc65ff871
Those are other examples of executing the same code above, I commented them to avoid making this notebook take more time executing. A user could just copy them to use the API in a slightly different way. But now that I write this, I realize that this also works as test and making sure that it actually works :D I'll unc...
andresmor-ms
268
py-why/dowhy
732
Set seed on data generation for deterministic test
* Set seed for deterministic data generation on `dowhy_function_api.ipynb` notebook. * Fix wrong parameters on backwards compatibility example. Fixes #704 Signed-off-by: Andres Morales <andresmor@microsoft.com>
null
2022-10-31 18:37:31+00:00
2022-11-01 15:16:07+00:00
docs/source/example_notebooks/dowhy_functional_api.ipynb
{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Functional API Preview\n", "\n", "This notebook is part of a set of notebooks that provides a preview of the proposed functional API for dowhy. For details on the new API for DoWhy, check out https://github.com/py-why/dowhy/w...
{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Functional API Preview\n", "\n", "This notebook is part of a set of notebooks that provides a preview of the proposed functional API for dowhy. For details on the new API for DoWhy, check out https://github.com/py-why/dowhy/w...
andresmor-ms
b9bab69d737f34fc32a73feb426d0ddc2f471df2
68f5d2b1bc7c5357b243dcef31510cfdc65ff871
Just want to note that we shouldn't use random seeds in unit tests. However, here it's a notebook, so its fine :)
bloebp
269
py-why/dowhy
732
Set seed on data generation for deterministic test
* Set seed for deterministic data generation on `dowhy_function_api.ipynb` notebook. * Fix wrong parameters on backwards compatibility example. Fixes #704 Signed-off-by: Andres Morales <andresmor@microsoft.com>
null
2022-10-31 18:37:31+00:00
2022-11-01 15:16:07+00:00
docs/source/example_notebooks/dowhy_functional_api.ipynb
{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Functional API Preview\n", "\n", "This notebook is part of a set of notebooks that provides a preview of the proposed functional API for dowhy. For details on the new API for DoWhy, check out https://github.com/py-why/dowhy/w...
{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Functional API Preview\n", "\n", "This notebook is part of a set of notebooks that provides a preview of the proposed functional API for dowhy. For details on the new API for DoWhy, check out https://github.com/py-why/dowhy/w...
andresmor-ms
b9bab69d737f34fc32a73feb426d0ddc2f471df2
68f5d2b1bc7c5357b243dcef31510cfdc65ff871
We use notebooks as unit tests though, so we should probably disable random seeds in all of them by default.
darthtrevino
270
py-why/dowhy
727
Re-introduce include_simulated_confounder as method
Fixes #721 Signed-off-by: Andres Morales <andresmor@microsoft.com>
null
2022-10-28 22:32:39+00:00
2022-10-31 16:28:12+00:00
dowhy/causal_refuters/add_unobserved_common_cause.py
import copy import logging import math from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import scipy.stats import statsmodels.api as sm from sklearn.linear_model import LogisticRegression from sklearn.preprocessing import StandardScaler from tqdm.auto import tqdm from dowhy.causal...
import copy import logging import math from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import scipy.stats import statsmodels.api as sm from sklearn.linear_model import LogisticRegression from sklearn.preprocessing import StandardScaler from tqdm.auto import tqdm from dowhy.causal...
andresmor-ms
f13ed30f42440552e4a912372abcb7c3023fc9c0
18bd1fe5d9941867dbd135e0d2a0af2fb24feea7
should these constants be named?
darthtrevino
271
py-why/dowhy
727
Re-introduce include_simulated_confounder as method
Fixes #721 Signed-off-by: Andres Morales <andresmor@microsoft.com>
null
2022-10-28 22:32:39+00:00
2022-10-31 16:28:12+00:00
dowhy/causal_refuters/add_unobserved_common_cause.py
import copy import logging import math from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import scipy.stats import statsmodels.api as sm from sklearn.linear_model import LogisticRegression from sklearn.preprocessing import StandardScaler from tqdm.auto import tqdm from dowhy.causal...
import copy import logging import math from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import scipy.stats import statsmodels.api as sm from sklearn.linear_model import LogisticRegression from sklearn.preprocessing import StandardScaler from tqdm.auto import tqdm from dowhy.causal...
andresmor-ms
f13ed30f42440552e4a912372abcb7c3023fc9c0
18bd1fe5d9941867dbd135e0d2a0af2fb24feea7
Added names for these
andresmor-ms
272
py-why/dowhy
695
Change mechanics of Docker image build and usage
- Introduce a GH Action to build Docker image for docs generation every time the Dockerfile is changed - Trigger docs generation when a new Docker image was built Addresses: - https://github.com/py-why/dowhy/issues/690 - https://github.com/py-why/dowhy/issues/691
null
2022-10-19 15:03:32+00:00
2022-10-26 21:10:00+00:00
docs/Dockerfile
# # This dockerfile was used to generate darthtrevino/dowhy-docs, used in the # build-and-publish-docs.yml workflow # FROM pego/dowhy-examples-notebooks-deps RUN apt update RUN DEBIAN_FRONTEND=noninteractive apt install --yes --quiet curl RUN curl -sSL https://install.python-poetry.org | python3 - --version 1.2.1 ENV...
# # This dockerfile was used to generate darthtrevino/dowhy-docs, used in the # build-and-publish-docs.yml workflow # FROM ghcr.io/py-why/dowhy-example-notebooks-deps RUN apt update RUN DEBIAN_FRONTEND=noninteractive apt install --yes --quiet curl RUN curl -sSL https://install.python-poetry.org | python3 - --version ...
petergtz
9b7e6a74c4dbb7228999998c81d43c5330df9d31
3c5cf3a67b054b2baebaae254c31f457e1fd3365
I'm assuming this comes packed with all the R deps? Do we have a plan for deprecating the R notebooks?
darthtrevino
273
py-why/dowhy
695
Change mechanics of Docker image build and usage
- Introduce a GH Action to build Docker image for docs generation every time the Dockerfile is changed - Trigger docs generation when a new Docker image was built Addresses: - https://github.com/py-why/dowhy/issues/690 - https://github.com/py-why/dowhy/issues/691
null
2022-10-19 15:03:32+00:00
2022-10-26 21:10:00+00:00
docs/Dockerfile
# # This dockerfile was used to generate darthtrevino/dowhy-docs, used in the # build-and-publish-docs.yml workflow # FROM pego/dowhy-examples-notebooks-deps RUN apt update RUN DEBIAN_FRONTEND=noninteractive apt install --yes --quiet curl RUN curl -sSL https://install.python-poetry.org | python3 - --version 1.2.1 ENV...
# # This dockerfile was used to generate darthtrevino/dowhy-docs, used in the # build-and-publish-docs.yml workflow # FROM ghcr.io/py-why/dowhy-example-notebooks-deps RUN apt update RUN DEBIAN_FRONTEND=noninteractive apt install --yes --quiet curl RUN curl -sSL https://install.python-poetry.org | python3 - --version ...
petergtz
9b7e6a74c4dbb7228999998c81d43c5330df9d31
3c5cf3a67b054b2baebaae254c31f457e1fd3365
> I'm assuming this comes packed with all the R deps? yes > Do we have a plan for deprecating the R notebooks? Yes. I've already removed R dependencies in a couple of notebooks that use the Lalonde dataset and use R only to load it (see recent commit history). Actually, the plan is not to deprecate the note...
petergtz
274
py-why/dowhy
693
Functional api/estimate effect function
#### Estimate Effect function * Refactors the estimate effect into a separate function to keep backwards compatibility #### TODO (future PRs): * Add `fit(...)` method to estimators - Move data related parameters from the constructor to the `fit(...)` method * Refactor code to avoid `**kwargs` in `__init__(...)` c...
null
2022-10-18 15:49:21+00:00
2022-10-25 17:02:02+00:00
docs/source/example_notebooks/dowhy_functional_api.ipynb
{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Functional API Preview\n", "\n", "This notebook is part of a set of notebooks that provides a preview of the proposed functional API for dowhy. For details on the new API for DoWhy, check out https://github.com/py-why/dowhy/w...
{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Functional API Preview\n", "\n", "This notebook is part of a set of notebooks that provides a preview of the proposed functional API for dowhy. For details on the new API for DoWhy, check out https://github.com/py-why/dowhy/w...
andresmor-ms
2044d216c322a4b32c6eadce5da7d83463f19c2f
05bfa49dacf0061988c96c6f3e3756219df5422a
@andresmor-ms @amit-sharma Hey guys, I was wondering how you think about the following proposal (which is what I believe is what we have also discussed in the past at some point). It might be a bit naiv, because I don't understand all the details and subtleties of the existing implementation. But just throwing it out t...
petergtz
275
py-why/dowhy
693
Functional api/estimate effect function
#### Estimate Effect function * Refactors the estimate effect into a separate function to keep backwards compatibility #### TODO (future PRs): * Add `fit(...)` method to estimators - Move data related parameters from the constructor to the `fit(...)` method * Refactor code to avoid `**kwargs` in `__init__(...)` c...
null
2022-10-18 15:49:21+00:00
2022-10-25 17:02:02+00:00
docs/source/example_notebooks/dowhy_functional_api.ipynb
{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Functional API Preview\n", "\n", "This notebook is part of a set of notebooks that provides a preview of the proposed functional API for dowhy. For details on the new API for DoWhy, check out https://github.com/py-why/dowhy/w...
{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Functional API Preview\n", "\n", "This notebook is part of a set of notebooks that provides a preview of the proposed functional API for dowhy. For details on the new API for DoWhy, check out https://github.com/py-why/dowhy/w...
andresmor-ms
2044d216c322a4b32c6eadce5da7d83463f19c2f
05bfa49dacf0061988c96c6f3e3756219df5422a
Or maybe I'm misunderstanding this, and the whole point of the _function_ `estimate_effect` is to take care of calling the _methods_ `fit` and `estimate_effect`. Then never mind my comment above.
petergtz
276
py-why/dowhy
693
Functional api/estimate effect function
#### Estimate Effect function * Refactors the estimate effect into a separate function to keep backwards compatibility #### TODO (future PRs): * Add `fit(...)` method to estimators - Move data related parameters from the constructor to the `fit(...)` method * Refactor code to avoid `**kwargs` in `__init__(...)` c...
null
2022-10-18 15:49:21+00:00
2022-10-25 17:02:02+00:00
docs/source/example_notebooks/dowhy_functional_api.ipynb
{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Functional API Preview\n", "\n", "This notebook is part of a set of notebooks that provides a preview of the proposed functional API for dowhy. For details on the new API for DoWhy, check out https://github.com/py-why/dowhy/w...
{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Functional API Preview\n", "\n", "This notebook is part of a set of notebooks that provides a preview of the proposed functional API for dowhy. For details on the new API for DoWhy, check out https://github.com/py-why/dowhy/w...
andresmor-ms
2044d216c322a4b32c6eadce5da7d83463f19c2f
05bfa49dacf0061988c96c6f3e3756219df5422a
Hey @petergtz, I believe that what you just described is my end goal here, I think that @amit-sharma still wants to keep the `estimate_effect` function as a way to automatically select parameters (for users that maybe don't know which parameters to pick) I want to separate this into several PRs to avoid creating one gi...
andresmor-ms
277
py-why/dowhy
693
Functional api/estimate effect function
#### Estimate Effect function * Refactors the estimate effect into a separate function to keep backwards compatibility #### TODO (future PRs): * Add `fit(...)` method to estimators - Move data related parameters from the constructor to the `fit(...)` method * Refactor code to avoid `**kwargs` in `__init__(...)` c...
null
2022-10-18 15:49:21+00:00
2022-10-25 17:02:02+00:00
docs/source/example_notebooks/dowhy_functional_api.ipynb
{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Functional API Preview\n", "\n", "This notebook is part of a set of notebooks that provides a preview of the proposed functional API for dowhy. For details on the new API for DoWhy, check out https://github.com/py-why/dowhy/w...
{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Functional API Preview\n", "\n", "This notebook is part of a set of notebooks that provides a preview of the proposed functional API for dowhy. For details on the new API for DoWhy, check out https://github.com/py-why/dowhy/w...
andresmor-ms
2044d216c322a4b32c6eadce5da7d83463f19c2f
05bfa49dacf0061988c96c6f3e3756219df5422a
That's great! Thanks for providing the context, @andresmor-ms. Resolving.
petergtz
278
py-why/dowhy
693
Functional api/estimate effect function
#### Estimate Effect function * Refactors the estimate effect into a separate function to keep backwards compatibility #### TODO (future PRs): * Add `fit(...)` method to estimators - Move data related parameters from the constructor to the `fit(...)` method * Refactor code to avoid `**kwargs` in `__init__(...)` c...
null
2022-10-18 15:49:21+00:00
2022-10-25 17:02:02+00:00
dowhy/causal_estimator.py
import logging from collections import namedtuple import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy.utils.api import parse_state class CausalEstimator: """Base class for an estimator of causal effect. Subclasses...
import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy import causal_estimators from dowhy.causal_graph import CausalGraph from do...
andresmor-ms
2044d216c322a4b32c6eadce5da7d83463f19c2f
05bfa49dacf0061988c96c6f3e3756219df5422a
estimate_effect does not need the graph as a parameter
amit-sharma
279
py-why/dowhy
693
Functional api/estimate effect function
#### Estimate Effect function * Refactors the estimate effect into a separate function to keep backwards compatibility #### TODO (future PRs): * Add `fit(...)` method to estimators - Move data related parameters from the constructor to the `fit(...)` method * Refactor code to avoid `**kwargs` in `__init__(...)` c...
null
2022-10-18 15:49:21+00:00
2022-10-25 17:02:02+00:00
dowhy/causal_estimator.py
import logging from collections import namedtuple import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy.utils.api import parse_state class CausalEstimator: """Base class for an estimator of causal effect. Subclasses...
import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy import causal_estimators from dowhy.causal_graph import CausalGraph from do...
andresmor-ms
2044d216c322a4b32c6eadce5da7d83463f19c2f
05bfa49dacf0061988c96c6f3e3756219df5422a
shall we provide the method object here? And get rid of method_kwargs, as done in identification?
amit-sharma
280
py-why/dowhy
693
Functional api/estimate effect function
#### Estimate Effect function * Refactors the estimate effect into a separate function to keep backwards compatibility #### TODO (future PRs): * Add `fit(...)` method to estimators - Move data related parameters from the constructor to the `fit(...)` method * Refactor code to avoid `**kwargs` in `__init__(...)` c...
null
2022-10-18 15:49:21+00:00
2022-10-25 17:02:02+00:00
dowhy/causal_estimator.py
import logging from collections import namedtuple import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy.utils.api import parse_state class CausalEstimator: """Base class for an estimator of causal effect. Subclasses...
import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy import causal_estimators from dowhy.causal_graph import CausalGraph from do...
andresmor-ms
2044d216c322a4b32c6eadce5da7d83463f19c2f
05bfa49dacf0061988c96c6f3e3756219df5422a
this needs to be modified since causal_estimator is not defined so far. Assuming that the user provides a method object, we can use just use that method object and assign it to `causal_estimator`
amit-sharma
281
py-why/dowhy
693
Functional api/estimate effect function
#### Estimate Effect function * Refactors the estimate effect into a separate function to keep backwards compatibility #### TODO (future PRs): * Add `fit(...)` method to estimators - Move data related parameters from the constructor to the `fit(...)` method * Refactor code to avoid `**kwargs` in `__init__(...)` c...
null
2022-10-18 15:49:21+00:00
2022-10-25 17:02:02+00:00
dowhy/causal_estimator.py
import logging from collections import namedtuple import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy.utils.api import parse_state class CausalEstimator: """Base class for an estimator of causal effect. Subclasses...
import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy import causal_estimators from dowhy.causal_graph import CausalGraph from do...
andresmor-ms
2044d216c322a4b32c6eadce5da7d83463f19c2f
05bfa49dacf0061988c96c6f3e3756219df5422a
In line 741 we use graph to get the effect modifiers, unless you want them to be provided in parameter without option to get them from the CausalGraph object?
andresmor-ms
282
py-why/dowhy
693
Functional api/estimate effect function
#### Estimate Effect function * Refactors the estimate effect into a separate function to keep backwards compatibility #### TODO (future PRs): * Add `fit(...)` method to estimators - Move data related parameters from the constructor to the `fit(...)` method * Refactor code to avoid `**kwargs` in `__init__(...)` c...
null
2022-10-18 15:49:21+00:00
2022-10-25 17:02:02+00:00
dowhy/causal_estimator.py
import logging from collections import namedtuple import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy.utils.api import parse_state class CausalEstimator: """Base class for an estimator of causal effect. Subclasses...
import logging from collections import namedtuple from typing import Dict, List, Optional, Union import numpy as np import pandas as pd import sympy as sp from sklearn.utils import resample import dowhy.interpreters as interpreters from dowhy import causal_estimators from dowhy.causal_graph import CausalGraph from do...
andresmor-ms
2044d216c322a4b32c6eadce5da7d83463f19c2f
05bfa49dacf0061988c96c6f3e3756219df5422a
I'd prefer if we leave it as this and change it when I refactor the actual estimator objects in the next PR
andresmor-ms
283