aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorGertjan van den Burg <gertjanvandenburg@gmail.com>2018-01-08 20:07:38 +0100
committerGertjan van den Burg <gertjanvandenburg@gmail.com>2018-01-08 20:07:38 +0100
commit3d1a7658a52a3f04adb9cf9c776ec3dd7bd5ca06 (patch)
treec47300f14360c23a0c2741ba3417ac06c8051c76 /docs
parentadd documentation for kernels in GenSVM (diff)
downloadpygensvm-3d1a7658a52a3f04adb9cf9c776ec3dd7bd5ca06.tar.gz
pygensvm-3d1a7658a52a3f04adb9cf9c776ec3dd7bd5ca06.zip
update documentation and fix autodocs
Diffstat (limited to 'docs')
-rw-r--r--docs/cls_gensvm.rst21
-rw-r--r--docs/generate_autodocs.py43
-rw-r--r--docs/index.rst2
3 files changed, 53 insertions, 13 deletions
diff --git a/docs/cls_gensvm.rst b/docs/cls_gensvm.rst
index 4e67631..fc19bf4 100644
--- a/docs/cls_gensvm.rst
+++ b/docs/cls_gensvm.rst
@@ -26,16 +26,19 @@
'linear', 'poly', 'rbf', or 'sigmoid'.
:type kernel: string, optional (default='linear')
:param gamma: Kernel parameter for the rbf, poly, and sigmoid kernel. If gamma is
- 'auto' then 1/n_features will be used.
+ 'auto' then 1/n_features will be used. See `Kernels in GenSVM
+ <gensvm_kernels_>`_ for the exact implementation of the kernels.
:type gamma: float, optional (default='auto')
- :param coef: Kernel parameter for the poly and sigmoid kernel
+ :param coef: Kernel parameter for the poly and sigmoid kernel. See `Kernels in
+ GenSVM <gensvm_kernels_>`_ for the exact implementation of the kernels.
:type coef: float, optional (default=0.0)
- :param degree: Kernel parameter for the poly kernel
+ :param degree: Kernel parameter for the poly kernel. See `Kernels in GenSVM
+ <gensvm_kernels_>`_ for the exact implementation of the kernels.
:type degree: float, optional (default=2.0)
- :param kernel_eigen_cutoff: Cutoff point for the reduced eigendecomposition used with
- kernel-GenSVM. Eigenvectors for which the ratio between their
- corresponding eigenvalue and the largest eigenvalue is smaller than the
- cutoff will be dropped.
+ :param kernel_eigen_cutoff: Cutoff point for the reduced eigendecomposition used with nonlinear
+ GenSVM. Eigenvectors for which the ratio between their corresponding
+ eigenvalue and the largest eigenvalue is smaller than the cutoff will
+ be dropped.
:type kernel_eigen_cutoff: float, optional (default=1e-8)
:param verbose: Enable verbose output
:type verbose: int, (default=0)
@@ -67,6 +70,10 @@
:class:`.GenSVMGridSearchCV`
Helper class to run an efficient grid search for GenSVM.
+ .. _gensvm_kernels:
+ https://gensvm.readthedocs.io/en/latest/#kernels-in-gensvm
+
+
.. py:method:: GenSVM.fit(X, y, seed_V=None)
:noindex:
diff --git a/docs/generate_autodocs.py b/docs/generate_autodocs.py
index 6138287..b2c9fb6 100644
--- a/docs/generate_autodocs.py
+++ b/docs/generate_autodocs.py
@@ -15,7 +15,8 @@ import os
from docutils.statemachine import StringList, ViewList
-from sphinx.ext.autodoc import AutoDirective, ClassDocumenter, Options
+from sphinx.ext.autodoc import (AutoDirective, ClassDocumenter, Options,
+ FunctionDocumenter)
from sphinx.application import Sphinx
from sphinx.environment import BuildEnvironment
@@ -27,14 +28,20 @@ CLASSES = [
'GenSVM'
]
+FUNCTIONS = [
+ 'load_default_grid'
+ ]
+
FULL_NAMES = {
'GenSVM': 'gensvm.core.GenSVM',
- 'GenSVMGridSearchCV': 'gensvm.gridsearch.GenSVMGridSearchCV'
+ 'GenSVMGridSearchCV': 'gensvm.gridsearch.GenSVMGridSearchCV',
+ 'load_default_grid': 'gensvm.gridsearch.load_default_grid'
}
OUTPUT_FILES = {
'GenSVMGridSearchCV': os.path.join(DOCDIR, 'cls_gridsearch.rst'),
- 'GenSVM': os.path.join(DOCDIR, 'cls_gensvm.rst')
+ 'GenSVM': os.path.join(DOCDIR, 'cls_gensvm.rst'),
+ 'load_default_grid': os.path.join(DOCDIR, 'auto_functions.rst')
}
@@ -49,7 +56,7 @@ def load_app():
return app
-def generate_autodoc(app, cls):
+def generate_class_autodoc(app, cls):
ad = AutoDirective(name='autoclass', arguments=[FULL_NAMES[cls]],
options={'noindex': True}, content=StringList([], items=[]),
lineno=0, content_offset=1, block_text='', state=None,
@@ -67,10 +74,36 @@ def generate_autodoc(app, cls):
for line in ad.result:
fid.write(line + '\n')
+
+def generate_func_autodoc(app, func):
+ ad = AutoDirective(name='autofunc', arguments=[FULL_NAMES[func]],
+ options={'noindex': True}, content=StringList([], items=[]),
+ lineno=0, content_offset=1, block_text='', state=None,
+ state_machine=None)
+
+ ad.env = BuildEnvironment(app)
+ ad.genopt = Options(noindex=True)
+ ad.filename_set = set()
+ ad.result = ViewList()
+
+ documenter = FunctionDocumenter(ad, ad.arguments[0])
+ documenter.generate(all_members=True)
+
+ with open(OUTPUT_FILES[func], 'a') as fid:
+ for line in ad.result:
+ fid.write(line + '\n')
+
+
def main():
+ for of in OUTPUT_FILES:
+ fname = OUTPUT_FILES[of]
+ os.unlink(fname)
app = load_app()
for cls in CLASSES:
- generate_autodoc(app, cls)
+ generate_class_autodoc(app, cls)
+ for func in FUNCTIONS:
+ generate_func_autodoc(app, func)
+
if __name__ == '__main__':
main()
diff --git a/docs/index.rst b/docs/index.rst
index 6064b56..403dc8b 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -23,7 +23,7 @@ GenSVMGridSearchCV
Functions
---------
-.. autofunction:: gensvm.gridsearch.load_default_grid
+.. include:: ./auto_functions.rst
.. include:: ./kernels.rst