Skip to content

Commit

Permalink
Updated: sphinx theme to pydata, autoapi removed, custom API document…
Browse files Browse the repository at this point in the history
…ation added
  • Loading branch information
Caparrini committed Oct 24, 2024
1 parent c2d4c81 commit 2e526cf
Show file tree
Hide file tree
Showing 10 changed files with 129 additions and 23 deletions.
8 changes: 8 additions & 0 deletions docs/api/api_reference.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
API reference
=============

.. toctree::
:maxdepth: 4

mloptimizer

20 changes: 20 additions & 0 deletions docs/api/interfaces/genetic_search.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
GeneticSearch
-------------

This class provides a genetic algorithm-based optimization framework.


.. autosummary::

~mloptimizer.interfaces.GeneticSearch.fit
~mloptimizer.interfaces.GeneticSearch.predict
~mloptimizer.interfaces.GeneticSearch.score


.. autoclass:: mloptimizer.interfaces.GeneticSearch
:members:
:undoc-members:
:show-inheritance:
:exclude-members: __init__


9 changes: 9 additions & 0 deletions docs/api/interfaces/hyperspace_builder.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
HyperparameterSpaceBuilder
--------------------------

The `HyperparameterSpaceBuilder` class provides tools to define and construct hyperparameter search spaces for optimization.

.. autoclass:: mloptimizer.interfaces.HyperparameterSpaceBuilder
:members:
:undoc-members:
:show-inheritance:
17 changes: 17 additions & 0 deletions docs/api/mloptimizer.interfaces.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
interfaces
==========

The `interfaces` subpackage provides interfaces for building and optimizing machine learning models.
It includes tools for defining search spaces, managing optimization processes, and more.

This package contains the following classes:

- **:class:`~mloptimizer.interfaces.GeneticSearch`**: Provides a genetic algorithm-based optimizer.
- **:class:`~mloptimizer.interfaces.HyperparameterSpaceBuilder`**: Offers tools for defining the hyperparameter search space.

.. toctree::
:maxdepth: 2
:caption: Contents:

interfaces/genetic_search
interfaces/hyperspace_builder
11 changes: 11 additions & 0 deletions docs/api/mloptimizer.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
mloptimizer
===========

The `mloptimizer` package provides interfaces for building and optimizing machine learning models.
It includes tools for defining search spaces, managing optimization processes, and more.

.. toctree::
:maxdepth: 4
:caption: Contents:

mloptimizer.interfaces
70 changes: 51 additions & 19 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,46 +23,68 @@
'sphinx.ext.autodoc',
'sphinx.ext.viewcode',
'sphinx.ext.napoleon',
'sphinx.ext.autosectionlabel',
'sphinx.ext.autosummary',
'sphinx_gallery.gen_gallery',
'sphinx_mdinclude',
'sphinx.ext.coverage',
'sphinx.ext.mathjax',
'sphinx.ext.graphviz',
'sphinx.ext.intersphinx',
'autoapi.extension',
#'autoapi.extension',
'sphinx_favicon',
'sphinxcontrib.mermaid'
]

autosectionlabel_prefix_document = True
autosectionlabel_maxdepth = 2

intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
'numpy': ('https://numpy.org/doc/stable/', None),
}

templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']

autoapi_dirs = ['../mloptimizer']
autoapi_type = "python"
autoapi_options = [
"members",
"undoc-members",
"show-inheritance",
"show-module-summary",
"imported-members",
]
autodoc_typehints = "signature"
autoapi_ignore = ['*test*']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store',
'*/test/*']

# autoapi_dirs = ['../mloptimizer']
# autoapi_type = "python"
# autoapi_options = [
# "members",
# "undoc-members",
# "show-inheritance",
# "show-module-summary",
# "imported-members",
#]
#autodoc_typehints = "signature"
#autoapi_ignore = ['*test*']

# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'sphinx_book_theme'
html_theme = 'pydata_sphinx_theme'
# html_static_path = ['_static']

image_scrapers = ('matplotlib', plotly_sg_scraper,)

autodoc_default_flags = ['members']
autosummary_generate = True
autodoc_default_options = {
'members': True,
'undoc-members': True, # Include undocumented members
'show-inheritance': True, # Display class inheritance
'inherited-members': True # Document inherited members
}
autodoc_typehints_format = 'fully-qualified' # has to be a one of ('fully-qualified', 'short')
autodoc_inherit_docstrings = True

autosummary_generate = False
autoclass_content = 'both'

napoleon_google_docstring = True
napoleon_numpy_docstring = True

html_show_sourcelink = False
autodoc_inherit_docstrings = True
set_type_checking_flag = True

sphinx_gallery_conf = {
Expand All @@ -76,8 +98,18 @@
}

html_theme_options = {
"repository_url": "https://github.com/Caparrini/mloptimizer",
"use_repository_button": True,
"show_nav_level": 2, # Control the navigation levels displayed
"show_prev_next": False, # Hide previous/next links
"navigation_depth": 3, # Set navigation depth to control sidebar depth
"icon_links": [
{
"name": "GitHub", # The name that will appear on hover
"url": "https://github.com/Caparrini/mloptimizer", # Your repository URL
"icon": "fab fa-github-square", # FontAwesome icon for GitHub
"type": "fontawesome", # Use FontAwesome icons
}
],
"navbar_end": ["theme-switcher", "icon-links"], # Add the icon to the end of the navbar
}

html_logo = 'http://raw.githubusercontent.com/Caparrini/mloptimizer-static/main/logos/mloptimizer_banner_readme.png'
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Welcome to mloptimizer's documentation!
:maxdepth: 3
:caption: API reference:

autoapi/index
api/api_reference

.. toctree::
:maxdepth: 1
Expand Down
9 changes: 8 additions & 1 deletion mloptimizer/interfaces/api/hyperspace_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,19 @@ def set_fixed_params(self, fixed_params: dict):
return self

def build(self):
return HyperparameterSpace(fixed_hyperparams=self.fixed_hyperparams, evolvable_hyperparams=self.evolvable_hyperparams)
return HyperparameterSpace(fixed_hyperparams=self.fixed_hyperparams,
evolvable_hyperparams=self.evolvable_hyperparams)

def load_default_space(self, estimator_class):
"""Load a default hyperparameter space using the application service."""
return self.service.load_default_hyperparameter_space(estimator_class)

@staticmethod
def get_default_space(estimator_class):
"""Returns a default hyperparameter space using the application service."""
tmp_service = HyperparameterSpaceService()
return tmp_service.load_default_hyperparameter_space(estimator_class=estimator_class)

def save_space(self, hyperparam_space, file_path, overwrite=False):
"""Save the hyperparameter space using the application service."""
self.service.save_hyperparameter_space(hyperparam_space, file_path, overwrite)
3 changes: 2 additions & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ sphinx_mdinclude
sphinxcontrib-mermaid
tensorflow>=2.12.0
tqdm
xgboost>=1.7.3
xgboost>=1.7.3
hyperopt
3 changes: 2 additions & 1 deletion requirements_docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ six>=1.15.0
sphinx-autoapi
sphinx-favicon
sphinx-gallery==0.14.0
sphinx_book_theme
pydata-sphinx-heme
sphinx_mdinclude
sphinxcontrib-mermaid
sphinx-autodoc-typehints
tensorflow>=2.12.0
tqdm
xgboost>=1.7.3

0 comments on commit 2e526cf

Please sign in to comment.