From ea04641e8db1f31c256d739a60bf95caa0d00a50 Mon Sep 17 00:00:00 2001 From: Abdul Hannan Kanji Date: Thu, 19 Nov 2020 08:46:42 -0500 Subject: [PATCH] Add more documentation --- docs/reference.rst | 2 ++ seldonian/algorithm.py | 13 +++++-------- seldonian/seldonian.py | 11 ++++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/reference.rst b/docs/reference.rst index 219de7c2..0d30636a 100644 --- a/docs/reference.rst +++ b/docs/reference.rst @@ -8,6 +8,7 @@ Seldonian Algorithm .. automodule:: seldonian.algorithm :members: :show-inheritance: + :private-members: _safetyTest ========================== Seldonian Abstract classes @@ -18,6 +19,7 @@ Use this as a base class to implement your own fair model using the Seldonian ap :members: :show-inheritance: :special-members: + :private-members: _safetyTest =========================== Sample constraint functions diff --git a/seldonian/algorithm.py b/seldonian/algorithm.py index f6d74431..22f6b5f5 100644 --- a/seldonian/algorithm.py +++ b/seldonian/algorithm.py @@ -36,25 +36,22 @@ def predict(self, X): @abstractmethod def _safetyTest(self, **kwargs): """ - Run the safety test on the trained model from the candidate selection part i.e. the - :func:`fit` function. - It is also used to predict the :math:`g(\\theta)` value used in candidate selection. + Run the safety test on the trained model from the candidate selection part i.e. the :func:`fit` function. It is also used to predict the :math:`g(\\theta)` value used in candidate selection. :param kwargs Key value arguments sent to the subclass implementation of safety test. :return Depending on the implementation, it will either return `0` if it passes or `1` if it doesn't. Or, it will also return the :math:`g(\\theta)` value - if it does not pass the safety test. - - Either way, use the ``safetyTest()`` method (with the _) to get a boolean value. + if it does not pass the safety test. Use the ``safetyTest()`` method to get a boolean value. """ raise NotImplementedError("_safetyTest function must be implemented") pass def safetyTest(self, **kwargs): """ - A wrapper for the ``_safetyTest`` method that return a ``Boolean`` indicating whther the + A wrapper for the ``_safetyTest`` method that return a ``Boolean`` indicating whether the model passed the safety test. - :param kwargs: Key-value arguments that is passed directly to ``_safetyTest`. + + :param kwargs: Key-value arguments that is passed directly to ``_safetyTest``. :return: - ``True`` if model passed the safety test. - ``False`` if the model fails the safety test. diff --git a/seldonian/seldonian.py b/seldonian/seldonian.py index 17d5e9ac..5a457276 100644 --- a/seldonian/seldonian.py +++ b/seldonian/seldonian.py @@ -344,11 +344,12 @@ def data(self): def _safetyTest(self, theta=None, predict=False, ub=True): """ - This - :param theta: - :param predict: - :param ub: - :return: + This is the mehtod that implements the safety test. for this model. + + :param theta: Model parameters to be used to run the safety test. **Default** - ``None``. If ``None``, the current model parameters used. + :param predict: **Default** - ``False``. Indicate whether you want to predict the upper bound of :math:`g(\\theta)` using the candidate set (this is used when running candidate selection). + :param ub: returns the upper bound if ``True``. Else, it returns the calculated value. **Default**- ``True``. + :return: Returns the value :math:`max\{0, g(\\theta) | X\}` if `predict` = ``False`` , else :math:`max\{0, \\hat{g}(\\theta) | X\}`. """ if theta is None: theta = self.theta