Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop global refactoring #105

Open
wants to merge 86 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 80 commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
8530e26
Input check (#81)
judithabk6 Jul 10, 2024
e062cbd
Modularized estimators
brash6 Aug 1, 2024
ea38355
nuisances functions
brash6 Aug 1, 2024
6d78313
some new constants
brash6 Aug 1, 2024
124873e
some new utils functions
brash6 Aug 1, 2024
84c185d
useful decorators
brash6 Aug 1, 2024
b13147e
useful estimator loader to be uysed in the future
brash6 Aug 1, 2024
5e88fc1
still messy nuisances.py file
brash6 Aug 1, 2024
3e4a995
some scoring functions
brash6 Aug 1, 2024
f100116
experiment file to try estimators (to be enhanced)
brash6 Aug 1, 2024
90b7184
remove unused class variables
brash6 Oct 23, 2024
c828524
enhance base file
brash6 Oct 23, 2024
5bc00b4
rename experiment.y into example.py file
brash6 Oct 23, 2024
81263ee
apply refactoring PR comments
brash6 Oct 23, 2024
632a094
minor reformat example file
brash6 Oct 25, 2024
8927181
get rid of _get_interactions in base and add _input_reshape function
brash6 Oct 25, 2024
9ad7c0a
application of modifications
brash6 Oct 25, 2024
48fb5ed
remove cross fitting
brash6 Oct 29, 2024
d35f7d2
minor changes in coefficient product
brash6 Oct 30, 2024
ab8207a
remove discrete procedure in g computation
brash6 Oct 30, 2024
f2ed579
minor changes in ipw
brash6 Oct 30, 2024
09936d4
minor changes in ipw
brash6 Oct 30, 2024
9c36a8a
Revert "minor changes in ipw"
brash6 Oct 30, 2024
118a8c3
clean dml
brash6 Oct 30, 2024
c14ef7a
clean dml correct
brash6 Oct 30, 2024
4645318
not clean multiply robust
brash6 Oct 30, 2024
8140f40
clean multiply robust
brash6 Oct 30, 2024
8f783d4
remove useless loader file
brash6 Oct 30, 2024
c7b1e1f
old example
brash6 Oct 30, 2024
a743d74
new example
brash6 Oct 30, 2024
8ac63aa
fix reshape in coefficient product
brash6 Oct 30, 2024
3ffc4c0
remove _fit_nuisances and _score functions
brash6 Oct 30, 2024
e9475ca
fix predict_proba results reshape
brash6 Oct 30, 2024
43c8c51
default trim value for mediation DML
brash6 Oct 30, 2024
163fab5
remove trimming in DML
brash6 Oct 30, 2024
df342d2
minor bug fix in MR
brash6 Oct 30, 2024
cc6dfb1
working examples with comparions to med_bench
brash6 Oct 30, 2024
b23426c
remove unrelevant crossfitting in docstrings
brash6 Nov 4, 2024
b74bd36
intercept instead of m1
brash6 Nov 4, 2024
8da1d74
line formatting
houssamzenati Nov 6, 2024
435ed25
line formatting
houssamzenati Nov 6, 2024
cf8af6d
line formatting
houssamzenati Nov 6, 2024
d022006
line formatting changes
houssamzenati Nov 6, 2024
6378d43
line formatting
houssamzenati Nov 6, 2024
ae48827
remove comments, main module
houssamzenati Nov 6, 2024
6e59dd0
partial tests of new modularized estimators
houssamzenati Nov 8, 2024
f6ede7a
partial tests of new modularized estimators
houssamzenati Nov 8, 2024
cef6b32
rename ipw
brash6 Nov 13, 2024
817abec
regressor and classifier now child class variables
brash6 Nov 13, 2024
47a3723
Fixed GComputation
brash6 Nov 13, 2024
3650467
Merge remote-tracking branch 'refs/remotes/origin/refactoring' into r…
brash6 Nov 13, 2024
192ea20
tests refactor
brash6 Nov 13, 2024
b29becf
remove reg from IPW
brash6 Nov 13, 2024
046e977
clean dml docstrings
brash6 Nov 13, 2024
9da25c0
get rid of estimators using cross fitting
brash6 Nov 14, 2024
ac77369
fix tests
brash6 Nov 14, 2024
825bb12
tests refactored
brash6 Nov 14, 2024
9bff44b
files cleaning
brash6 Nov 14, 2024
b344910
fix tests
brash6 Nov 14, 2024
cd93d77
started to remove R dependencies
Dec 6, 2024
6290ddb
rename methods, clean inputs
judithabk6 Dec 6, 2024
a95e610
tmle testing, exactness tests
houssamzenati Dec 9, 2024
2789d63
tmle testing, exactness tests
houssamzenati Dec 9, 2024
e4f124f
tmle testing, exactness tests
houssamzenati Dec 9, 2024
6cc1b66
explanations and docstrings TMLE, line formatting
houssamzenati Dec 12, 2024
13c591f
refactor tests (remove old config parameter and have better names fo…
judithabk6 Dec 12, 2024
80f4fa0
remove unused options in get_estimation_results
judithabk6 Dec 12, 2024
bc21e83
direct effect treated, indirect effect control fixes
houssamzenati Dec 13, 2024
ce48988
removed exactness tests, fixed TMLE outputs for tolerance tests
houssamzenati Dec 17, 2024
5a77e67
slight change in test formatting
judithabk6 Dec 17, 2024
005fb21
remove unused file for the tests
judithabk6 Dec 18, 2024
566a08c
Update src/med_bench/estimation/base.py
bthirion Dec 19, 2024
b22d50f
Update src/tests/estimation/test_get_estimation.py
bthirion Dec 19, 2024
dce928d
Update src/med_bench/estimation/base.py
bthirion Dec 19, 2024
dfc0cc0
Update src/med_bench/estimation/base.py
bthirion Dec 19, 2024
b4a26a9
Update src/med_bench/estimation/base.py
bthirion Dec 19, 2024
08a997d
Merge pull request #92 from judithabk6/refactoring
judithabk6 Jan 15, 2025
ab36036
add doc files
brash6 Apr 22, 2024
b93cf22
make doc build
judithabk6 Feb 9, 2025
c7a9d3c
Merge branch 'main' into develop
judithabk6 Feb 9, 2025
064dd29
fix bug in tests
judithabk6 Feb 11, 2025
bbc6749
unused file
judithabk6 Feb 11, 2025
48e3224
remove utils module from API doc as it is internal
judithabk6 Feb 11, 2025
54a0a6c
remove unused code
judithabk6 Feb 11, 2025
2bc2944
fix absence of return self in DML estimator
judithabk6 Feb 14, 2025
c479ee9
fix indentation
judithabk6 Feb 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/code-cov.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ jobs:
dependencies: 'NA'
install-pandoc: false
packages: |
[email protected]
[email protected]
grf
causalweight
mediation
Expand All @@ -53,6 +55,7 @@ jobs:

- name: Run tests with coverage
run: |
export LD_LIBRARY_PATH=$(python -m rpy2.situation LD_LIBRARY_PATH):${LD_LIBRARY_PATH}
pytest --cov=med_bench --cov-report=xml

- name: Upload coverage to Codecov
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/tests-with-R.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ jobs:
dependencies: 'NA'
install-pandoc: false
packages: |
[email protected]
[email protected]
grf
causalweight
mediation
Expand All @@ -53,4 +55,5 @@ jobs:

- name: Run tests
run: |
pytest
export LD_LIBRARY_PATH=$(python -m rpy2.situation LD_LIBRARY_PATH):${LD_LIBRARY_PATH}
pytest
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,13 @@ dmypy.json
# DS_STORE files
src/.DS_Store
.DS_Store

# Mac
.idea/

# Ignore PDFs
*.pdf

# Ignore local scripts

scripts/
20 changes: 0 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,6 @@ pip install git+git://github.com/judithabk6/med_bench.git

Installation time is a few minutes on a standard personal computer.

Some estimators rely on their R implementation which requires the installation of the corresponding R packages. This can be done using `rpy2`

````python
import rpy2
import rpy2.robjects.packages as rpackages
utils = rpackages.importr('utils')
utils.chooseCRANmirror(ind=33)

utils.install_packages('grf')

utils.install_packages('causalweight')

utils.install_packages('mediation')


utils.install_packages('devtools')
devtools = rpackages.importr('devtools')
devtools.install_github('ohines/plmed')
plmed = rpackages.importr('plmed')
````

## Content
The `src` folder contains the main module with the implementation of the different estimators, the `script` folder contains the function used to simulate data and run the experiments, and the `results` folder contains all available results and code to reproduce the figures.
15 changes: 10 additions & 5 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,24 @@
import sys

import med_bench
import med_bench.get_estimation
import med_bench.get_simulated_data
import med_bench.mediation
import med_bench.estimation
from med_bench.estimation.mediation_coefficient_product import CoefficientProduct
from med_bench.estimation.mediation_dml import DoubleMachineLearning
from med_bench.estimation.mediation_g_computation import GComputation
from med_bench.estimation.mediation_ipw import InversePropensityWeighting
from med_bench.estimation.mediation_mr import MultiplyRobust
from med_bench.estimation.mediation_tmle import TMLE
import med_bench.utils
import med_bench.utils.utils
import med_bench.utils.nuisances


sys.path.insert(0, os.path.abspath('../'))

project = 'med_bench'
copyright = '2024, Judith Abecassis, Houssam Zenati, Bertrand Thirion, Hadrien Mariaccia, Mouad Zbakh'
author = 'Judith Abecassis, Houssam Zenati, Bertrand Thirion, Hadrien Mariaccia, Mouad Zbakh'
copyright = '2025, Judith Abecassis, Houssam Zenati, Bertrand Thirion, Hadrien Mariaccia, Mouad Zbakh, Sami Boumaïza, Julie Josse'
author = 'Judith Abecassis, Houssam Zenati, Bertrand Thirion, Hadrien Mariaccia, Mouad Zbakh, Sami Boumaïza, Julie Josse'


# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
59 changes: 35 additions & 24 deletions docs/modules.rst
Original file line number Diff line number Diff line change
@@ -1,57 +1,68 @@
.. toctree::
:maxdepth: 4
:caption: Contents:
:caption: API:


med_bench
=================
.. automodule:: med_bench
:members:
:undoc-members:
:show-inheritance:


get_estimation
--------

.. automodule:: med_bench.get_estimation

Estimation
==========
.. automodule:: med_bench.estimation
:members:
:undoc-members:
:show-inheritance:


get_simulated_data
--------
.. automodule:: med_bench.estimation.mediation_coefficient_product
:members:
:undoc-members:

.. automodule:: med_bench.get_simulated_data

.. automodule:: med_bench.estimation.mediation_g_computation
:members:
:undoc-members:
:show-inheritance:

.. automodule:: med_bench.estimation.mediation_ipw
:members:
:undoc-members:

mediation
--------

.. automodule:: med_bench.mediation
.. automodule:: med_bench.estimation.mediation_mr
:members:
:undoc-members:
:show-inheritance:


utils
--------
.. automodule:: med_bench.estimation.mediation_dml
:members:
:undoc-members:

.. automodule:: med_bench.utils.utils


.. automodule:: med_bench.estimation.mediation_tmle
:members:
:undoc-members:



get_simulated_data
==========

.. automodule:: med_bench.get_simulated_data
:members:
:undoc-members:
:show-inheritance:


nuisances
--------
utils
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure it is interesting to do a documentation about the utils module ?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be happy to check some internal functions as a user. Here it is just to display the parameters the function takes etc, but ok... We will see in the doc refactor

==========

.. automodule:: med_bench.utils.nuisances
.. automodule:: med_bench.utils.utils
:members:
:undoc-members:
:show-inheritance:




Binary file removed notebooks/noisymoons.pdf
Binary file not shown.
1,221 changes: 0 additions & 1,221 deletions notebooks/toy_example.ipynb

This file was deleted.

1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
'pandas>=1.2.1',
'scikit-learn>=0.22.1',
'numpy>=1.19.2',
'rpy2>=2.9.4',
'scipy>=1.5.2',
'seaborn>=0.11.1',
'matplotlib>=3.3.2',
Expand Down
Loading