Skip to content

Commit

Permalink
Causal T-learner (#206)
Browse files Browse the repository at this point in the history
* Included initial Meta S-learner classifier code.

* Included references in docstring.

* Fixed numpy typing.

* Removed unused import

* Created new type to allow mutable features, which is required with S-learner specifically.

* Fixed types based on new created type.

* Removed unused import.

* Requires learner to be mandatory.

* Removed lgbm import

* meta_learners.py: converted _predict_for_treatment and _predict_for_control functions into single _predict_by_treatment_flag function.

* Renamed LearnerMutableFeaturesFnType to LearnerMutableParametersFnType.

* included tests

* Fixed docstring and handled case in which uplift is negative.

* fix lint

* removed unused imports - wip

* added test__simulate_treatment_effect

* fix assertions

* fix assert_frame_equal

* meta_learners.py: included control_name parameter in _simulate_treatment_effect call.

* Included custom exceptions.

* meta_learner.py: Included exception checks in some functions.

* meta_learners.py: fixed bug. Changed treatment_col by treatment_name

* included assertion tests

* updated predict_by_treatment_flag test functions to test only the treatment value (1 or 0)

* added tests for causal_s_classification_learner

* changed function test name

* included explanation to test__simulate_treatment_effect

* moved column drop from simulate_treatment_effect to predict_by_treatment_flag

* changed mock learner for a mock function at test__simulate_treatment_effect

* included test for learners being the correct type

* meta_learners.py: fixed replace to x.replace(__uplift, )

* test_meta_learners.py: fixed test__simulate_treatment_effect to adapt change in replace on previous commit.

* meta_learners.py: fixed description of prediction_column in docstring.

* causal_s_learner_demo.ipynb: included demo notebook for causal s-learner.

* causal_s_learner_demo.ipynb: fixed notebook headers.

* Rerun notebook.

* causal_s_learner_demo.ipynb: included documentation in the notebook.

* Improved notebook description.

* Initial commit of T-Learner

* Add docstring

* Lint

* Change _get_model_fcn return type

* Fix learner type

* Removed unused import

* Removed unused import

* Updated types

* Fix variables naming

* Added tests

* Lint

* Type fix

* Improve documentation of T-Learner

Co-authored-by: Giulio Cesare Mastrocinque Santo <[email protected]>

* Fixed t-learner docstring

Co-authored-by: Giulio Cesare Mastrocinque Santo <[email protected]>

* Fixed t-learner docstring

Co-authored-by: Giulio Cesare Mastrocinque Santo <[email protected]>

* Fixed t-learner parameter type

Co-authored-by: Giulio Cesare Mastrocinque Santo <[email protected]>

* Fixed t-learner docstring

Co-authored-by: Giulio Cesare Mastrocinque Santo <[email protected]>

* Fix t-learner argument type

Co-authored-by: Giulio Cesare Mastrocinque Santo <[email protected]>

* Improve T-Learner types

Co-authored-by: Giulio Cesare Mastrocinque Santo <[email protected]>

* Remove unused type

Co-authored-by: Giulio Cesare Mastrocinque Santo <[email protected]>

* Add SHAP to logs

Co-authored-by: Giulio Cesare Mastrocinque Santo <[email protected]>

* Update src/fklearn/causal/cate_learning/meta_learners.py

* Applied review comments

* Update demo notebook

* Merged with master and included rst

* Fix test

* Update t-learner notebook

Co-authored-by: Giulio Santo <[email protected]>
Co-authored-by: Nicolas Behar <[email protected]>
Co-authored-by: Giulio Cesare Mastrocinque Santo <[email protected]>
  • Loading branch information
4 people authored Aug 26, 2022
1 parent fb0025c commit 9c31b55
Show file tree
Hide file tree
Showing 5 changed files with 2,867 additions and 58 deletions.
22 changes: 22 additions & 0 deletions docs/source/api/fklearn.causal.cate_learning.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
fklearn.causal.cate\_learning package
=====================================

Submodules
----------

fklearn.causal.cate\_learning.double\_machine\_learning module
--------------------------------------------------------------

.. automodule:: fklearn.causal.cate_learning.double_machine_learning
:members:
:undoc-members:
:show-inheritance:


Module contents
---------------

.. automodule:: fklearn.causal.cate_learning
:members:
:undoc-members:
:show-inheritance:
2 changes: 1 addition & 1 deletion notebooks/causal_s_learner_demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2439,4 +2439,4 @@
},
"nbformat": 4,
"nbformat_minor": 5
}
}
Loading

0 comments on commit 9c31b55

Please sign in to comment.