Skip to content

Commit

Permalink
fix gain statistics and dummy learner docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
SvenKlaassen committed Feb 2, 2024
1 parent eda1137 commit 8431daf
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 31 deletions.
54 changes: 30 additions & 24 deletions doubleml/utils/dummy_learners.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,32 @@ class DMLDummyRegressor(BaseEstimator):
A dummy regressor that raises an AttributeError when attempting to access
its fit, predict, or set_params methods.
Attributes
Parameters
----------
_estimator_type : str
Type of the estimator, set to "regressor".
Methods
-------
fit(*args)
Raises AttributeError: "Accessed fit method of DummyRegressor!"
predict(*args)
Raises AttributeError: "Accessed predict method of DummyRegressor!"
set_params(*args)
Raises AttributeError: "Accessed set_params method of DummyRegressor!"
"""

_estimator_type = "regressor"

def fit(*args):
"""
Raises AttributeError: "Accessed fit method of DummyRegressor!"
"""

raise AttributeError("Accessed fit method of DMLDummyRegressor!")

def predict(*args):
"""
Raises AttributeError: "Accessed predict method of DummyRegressor!"
"""

raise AttributeError("Accessed predict method of DMLDummyRegressor!")

def set_params(*args):
"""
Raises AttributeError: "Accessed set_params method of DummyRegressor!"
"""

raise AttributeError("Accessed set_params method of DMLDummyRegressor!")


Expand All @@ -38,33 +40,37 @@ class DMLDummyClassifier(BaseEstimator):
A dummy classifier that raises an AttributeError when attempting to access
its fit, predict, set_params, or predict_proba methods.
Attributes
Parameters
----------
_estimator_type : str
Type of the estimator, set to "classifier".
Methods
-------
fit(*args)
Raises AttributeError: "Accessed fit method of DummyClassifier!"
predict(*args)
Raises AttributeError: "Accessed predict method of DummyClassifier!"
set_params(*args)
Raises AttributeError: "Accessed set_params method of DummyClassifier!"
predict_proba(*args, **kwargs)
Raises AttributeError: "Accessed predict_proba method of DummyClassifier!"
"""

_estimator_type = "classifier"

def fit(*args):
"""
Raises AttributeError: "Accessed fit method of DummyClassifier!"
"""

raise AttributeError("Accessed fit method of DMLDummyClassifier!")

def predict(*args):
"""
Raises AttributeError: "Accessed predict method of DummyClassifier!"
"""

raise AttributeError("Accessed predict method of DMLDummyClassifier!")

def set_params(*args):
"""
Raises AttributeError: "Accessed set_params method of DummyClassifier!"
"""

raise AttributeError("Accessed set_params method of DMLDummyClassifier!")

def predict_proba(*args, **kwargs):
"""
Raises AttributeError: "Accessed predict_proba method of DummyClassifier!"
"""

raise AttributeError("Accessed predict_proba method of DMLDummyClassifier!")
16 changes: 9 additions & 7 deletions doubleml/utils/gain_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@

def gain_statistics(dml_long, dml_short):
"""
Compute gain statistics as benchmark values for sensitivity parameters cf_d and cf_y.
Compute gain statistics as benchmark values for sensitivity parameters ``cf_d`` and ``cf_y``.
Parameters:
Parameters
----------
dml_long : :class:`doubleml.DoubleML` model including all observed confounders
dml_short : :class:`doubleml.DoubleML` model that excludes one or several benchmark confounders
dml_long :
:class:`doubleml.DoubleML` model including all observed confounders
dml_short :
:class:`doubleml.DoubleML` model that excludes one or several benchmark confounders
Returns:
Returns
--------
Benchmarking dictionary (dict) with values for cf_d, cf_y, rho, and delta_theta.
benchmark_dict : dict
Benchmarking dictionary (dict) with values for ``cf_d``, ``cf_y``, ``rho``, and ``delta_theta``.
"""
if not isinstance(dml_long.sensitivity_elements, dict):
raise TypeError("dml_long does not contain the necessary sensitivity elements. "
Expand Down

0 comments on commit 8431daf

Please sign in to comment.