Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
statmlben committed Oct 17, 2023
1 parent 2ea75d3 commit c964d7e
Show file tree
Hide file tree
Showing 10 changed files with 192 additions and 34 deletions.
Binary file modified dist/rehline-0.0.1.tar.gz
Binary file not shown.
11 changes: 11 additions & 0 deletions doc/_templates/autoapi/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
API Reference
=============

This page contains auto-generated API reference documentation [#f1]_.

.. toctree::
:titlesonly:

/autoapi/rehline/index

.. [#f1] Created with `sphinx-autoapi <https://github.com/readthedocs/sphinx-autoapi>`_
12 changes: 7 additions & 5 deletions doc/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ API Reference
rehline.ReHLine
###############

ReHLine
*******
.. toctree::

.. autoclass:: rehline._class.ReHLine
:members:
:show-inheritance:
autoapi/rehline/index

.. .. autoclass:: rehline._class.ReHLine
.. :members:
.. :show-inheritance:
20 changes: 18 additions & 2 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
# release = '0.10'

import sys, os
# sys.path.append('.')
# sys.path.append('..')
sys.path.append('.')
sys.path.insert(0, os.path.abspath('../..'))
sys.path.insert(0, os.path.abspath('../rehline'))
# sys.path.append('../..')
# sys.path.insert(0, os.path.abspath('.'))
# sys.path.insert(0, os.path.abspath('../'))
# sys.path.insert(0, os.path.abspath('../..'))
Expand All @@ -39,13 +41,15 @@
master_doc = 'index'
extensions = [
'sphinx.ext.autodoc',
'autoapi.extension',
# "sphinx.ext.linkcode",
# "sphinx.ext.intersphinx",
"sphinx_autodoc_typehints",
'sphinx.ext.autosummary',
'numpydoc',
'nbsphinx'
]
autoapi_dirs = ['../../rehline']

autosummary_generate = True
numpydoc_show_class_members = False
Expand Down Expand Up @@ -102,3 +106,15 @@
# html_css_files = [
# 'css/custom.css',
# ]

def skip_submodules(app, what, name, obj, skip, options):
if what == "module":
skip = True
return skip


def setup(sphinx):
sphinx.connect("autoapi-skip-member", skip_submodules)

autoapi_template_dir = "_templates/autoapi"
# autoapi_add_toctree_entry = False
2 changes: 2 additions & 0 deletions doc/source/example.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Example
=======
10 changes: 8 additions & 2 deletions doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,14 @@ See more details in `installation <./installation.rst>`_.
\min_{\mathbf{\beta} \in \mathbb{R}^d} \sum_{i=1}^n \sum_{l=1}^L \text{ReLU}( u_{li} \mathbf{x}_i^\intercal \mathbf{\beta} + v_{li}) + \sum_{i=1}^n \sum_{h=1}^H {\text{ReHU}}_{\tau_{hi}}( s_{hi} \mathbf{x}_i^\intercal \mathbf{\beta} + t_{hi}) + \frac{1}{2} \| \mathbf{\beta} \|_2^2, \ \text{ s.t. } \mathbf{A} \mathbf{\beta} + \mathbf{b} \geq \mathbf{0},
where :math:`\mathbf{U} = (u_{li}),\mathbf{V} = (v_{li}) \in \mathbb{R}^{L \times n}` and :math:`\mathbf{S} = (s_{hi}),\mathbf{T} = (t_{hi}),\mathbf{\tau} = (\tau_{hi}) \in \mathbb{R}^{H \times n}` are the ReLU-ReHU loss parameters, and $(\mathbf{A},\mathbf{b})$ are the constraint parameters. This formulation has a wide range of applications spanning various fields, including statistics, machine learning, computational biology, and social studies. Some popular examples include SVMs with fairness constraints (FairSVM), elastic net regularized quantile regression (ElasticQR), and ridge regularized Huber minimization (RidgeHuber).
where :math:`\mathbf{U} = (u_{li}),\mathbf{V} = (v_{li}) \in \mathbb{R}^{L \times n}`
and :math:`\mathbf{S} = (s_{hi}),\mathbf{T} = (t_{hi}),\mathbf{\tau} = (\tau_{hi}) \in \mathbb{R}^{H \times n}`
are the ReLU-ReHU loss parameters, and :math:`(\mathbf{A},\mathbf{b})` are the constraint parameters.
This formulation has a wide range of applications spanning various fields, including statistics,
machine learning, computational biology, and social studies.
Some popular examples include SVMs with fairness constraints (FairSVM),
elastic net regularized quantile regression (ElasticQR),
and ridge regularized Huber minimization (RidgeHuber).

.. image:: ./figs/tab.png

Expand Down Expand Up @@ -99,7 +106,6 @@ Reference

installation
example
api

Indices and tables
==================
Expand Down
6 changes: 5 additions & 1 deletion rehline/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@

from ._loss import ReHLoss, PQLoss
from ._class import ReHLine, ReHLine_solver
from ._base import make_fair_classification
from ._base import relu, rehu, make_fair_classification

__all__ = ("ReHLine",
"ReHLoss",
"make_fair_classification", "relu", "rehu")
15 changes: 13 additions & 2 deletions rehline/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,27 @@

def relu(x):
"""
Evaluation of ReLU given a vector
Evaluation of ReLU given a vector.
Parameters
----------
x: {array-like} of shape (n_samples, )
Training vector, where `n_samples` is the number of samples
Returns
-------
array of shape (n_samples, )
An array with ReLU applied, i.e., all negative values are replaced with 0.
"""
return np.maximum(x, 0)


def rehu(x, cut=1):
"""
Evaluation of ReHU given a vector
Evaluation of ReHU given a vector.
Parameters
----------
Expand All @@ -37,6 +43,11 @@ def rehu(x, cut=1):
cut: {array-like} of shape (n_samples, )
Cutpoints of ReHU, where `n_samples` is the number of samples
Returns
-------
array of shape (n_samples, )
The result of the ReHU function.
"""
n_samples = x.shape[0]
cut = cut * np.ones_like(x)
Expand Down
Loading

0 comments on commit c964d7e

Please sign in to comment.