Skip to content

Commit

Permalink
Add more documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
hannanabdul55 committed Nov 19, 2020
1 parent f47a0ad commit ea04641
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 2 additions & 0 deletions docs/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Seldonian Algorithm
.. automodule:: seldonian.algorithm
:members:
:show-inheritance:
:private-members: _safetyTest

==========================
Seldonian Abstract classes
Expand All @@ -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
Expand Down
13 changes: 5 additions & 8 deletions seldonian/algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 6 additions & 5 deletions seldonian/seldonian.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ea04641

Please sign in to comment.