Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #8 from rsyi/master
Browse files Browse the repository at this point in the history
FIx documentation (mocking skopt, updating counting functions).
  • Loading branch information
rsyi authored Nov 29, 2019
2 parents 2f40ab4 + 0e37cf8 commit 8508b37
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 61 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

# Add mock modules.
import mock
MOCK_MODULES = ['matplotlib', 'matplotlib.pylab', 'matplotlib.pyplot', 'numpy', 'pandas', 'scipy', 'scipy.stats', 'sklearn', 'sklearn.ensemble', 'sklearn.metrics', 'sklearn.model_selection', 'xgboost']
MOCK_MODULES = ['matplotlib', 'matplotlib.pylab', 'matplotlib.pyplot', 'numpy', 'pandas', 'scipy', 'scipy.stats', 'sklearn', 'sklearn.ensemble', 'sklearn.metrics', 'sklearn.model_selection', 'xgboost', 'skopt', 'skopt.space']
for mod_name in MOCK_MODULES:
sys.modules[mod_name] = mock.Mock()

Expand Down
20 changes: 10 additions & 10 deletions docs/source/pylift.explore.rst
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
pylift.explore package
======================
pylift\.explore package
=======================

Submodules
----------

pylift.explore.base module
--------------------------
pylift\.explore\.base module
----------------------------

.. automodule:: pylift.explore.base
:members:
:undoc-members:
:show-inheritance:
:members:
:undoc-members:
:show-inheritance:


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

.. automodule:: pylift.explore
:members:
:undoc-members:
:show-inheritance:
:members:
:undoc-members:
:show-inheritance:
30 changes: 15 additions & 15 deletions docs/source/pylift.methods.rst
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
pylift.methods package
======================
pylift\.methods package
=======================

Submodules
----------

pylift.methods.base module
--------------------------
pylift\.methods\.base module
----------------------------

.. automodule:: pylift.methods.base
:members:
:undoc-members:
:show-inheritance:
:members:
:undoc-members:
:show-inheritance:

pylift.methods.derivatives module
---------------------------------
pylift\.methods\.derivatives module
-----------------------------------

.. automodule:: pylift.methods.derivatives
:members:
:undoc-members:
:show-inheritance:
:members:
:undoc-members:
:show-inheritance:


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

.. automodule:: pylift.methods
:members:
:undoc-members:
:show-inheritance:
:members:
:undoc-members:
:show-inheritance:
40 changes: 20 additions & 20 deletions docs/source/pylift.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,41 @@ Subpackages

.. toctree::

pylift.explore
pylift.methods
pylift.explore
pylift.methods

Submodules
----------

pylift.eval module
------------------
pylift\.eval module
-------------------

.. automodule:: pylift.eval
:members:
:undoc-members:
:show-inheritance:
:members:
:undoc-members:
:show-inheritance:

pylift.generate\_data module
----------------------------
pylift\.generate\_data module
-----------------------------

.. automodule:: pylift.generate_data
:members:
:undoc-members:
:show-inheritance:
:members:
:undoc-members:
:show-inheritance:

pylift.style module
-------------------
pylift\.style module
--------------------

.. automodule:: pylift.style
:members:
:undoc-members:
:show-inheritance:
:members:
:undoc-members:
:show-inheritance:


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

.. automodule:: pylift
:members:
:undoc-members:
:show-inheritance:
:members:
:undoc-members:
:show-inheritance:
31 changes: 16 additions & 15 deletions pylift/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ def _ensure_array(arraylike):
def _get_counts(treatment, outcome, p):
"""Extract (treatment,outcome) pair counts from treatment and outcome vectors.
Calculate counts of outcome/treatment combinations. Variables are named
nt#o#, where the # corresponds to a binary value for test and outcome,
respectively.
Calculate effective counts of outcome/treatment combinations (rescaled by
propensity). Variables are named nt#o#, where the # corresponds to a binary
value for test and outcome, respectively.
Parameters
----------
Expand All @@ -48,13 +48,13 @@ def _get_counts(treatment, outcome, p):
Returns
-------
Nt1o1 : int
Number of entries where (treatment, outcome) == (1,1).
Effective number of entries where (treatment, outcome) == (1,1).
Nt0o1 : int
Number of entries where (treatment, outcome) == (0,1).
Effective number of entries where (treatment, outcome) == (0,1).
Nt1o0 : int
Number of entries where (treatment, outcome) == (1,0).
Effective number of entries where (treatment, outcome) == (1,0).
Nt0o0 : int
Number of entries where (treatment, outcome) == (0,0).
Effective number of entries where (treatment, outcome) == (0,0).
"""
Nt1o1 = 0.5*np.sum(1/p[(treatment == 1) & (outcome > 0)])
Expand All @@ -64,27 +64,28 @@ def _get_counts(treatment, outcome, p):
return Nt1o1, Nt0o1, Nt1o0, Nt0o0

def _get_tc_counts(Nt1o1, Nt0o1, Nt1o0, Nt0o0):
"""Get treatment and control group sizes from `_get_counts` output.
"""Get effective (scaled by propensity) treatment and control group sizes
from `_get_counts` output.
Parameters
----------
Nt1o1 : int
Number of entries where (treatment, outcome) == (1,1).
Effective number of entries where (treatment, outcome) == (1,1).
Nt0o1 : int
Number of entries where (treatment, outcome) == (0,1).
Effective number of entries where (treatment, outcome) == (0,1).
Nt1o0 : int
Number of entries where (treatment, outcome) == (1,0).
Effective number of entries where (treatment, outcome) == (1,0).
Nt0o0 : int
Number of entries where (treatment, outcome) == (0,0).
Effective number of entries where (treatment, outcome) == (0,0).
Returns
-------
Nt1 : int
Size of treatment group.
Effective size of treatment group.
Nt0 : int
Size of control group.
Effective size of control group.
N : int
Size of full group.
Effective size of full group.
"""
Nt1 = Nt1o0 + Nt1o1
Expand Down

0 comments on commit 8508b37

Please sign in to comment.