diff --git a/docs/api/api_reference.rst b/docs/api/api_reference.rst new file mode 100644 index 0000000..8ab843d --- /dev/null +++ b/docs/api/api_reference.rst @@ -0,0 +1,8 @@ +API reference +============= + +.. toctree:: + :maxdepth: 4 + + mloptimizer + diff --git a/docs/api/interfaces/genetic_search.rst b/docs/api/interfaces/genetic_search.rst new file mode 100644 index 0000000..3592158 --- /dev/null +++ b/docs/api/interfaces/genetic_search.rst @@ -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__ + + diff --git a/docs/api/interfaces/hyperspace_builder.rst b/docs/api/interfaces/hyperspace_builder.rst new file mode 100644 index 0000000..2d5bfab --- /dev/null +++ b/docs/api/interfaces/hyperspace_builder.rst @@ -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: \ No newline at end of file diff --git a/docs/api/mloptimizer.interfaces.rst b/docs/api/mloptimizer.interfaces.rst new file mode 100644 index 0000000..48eb6de --- /dev/null +++ b/docs/api/mloptimizer.interfaces.rst @@ -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 diff --git a/docs/api/mloptimizer.rst b/docs/api/mloptimizer.rst new file mode 100644 index 0000000..ea90052 --- /dev/null +++ b/docs/api/mloptimizer.rst @@ -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 diff --git a/docs/conf.py b/docs/conf.py index 5af9fd8..7ac02c8 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -23,6 +23,7 @@ 'sphinx.ext.autodoc', 'sphinx.ext.viewcode', 'sphinx.ext.napoleon', + 'sphinx.ext.autosectionlabel', 'sphinx.ext.autosummary', 'sphinx_gallery.gen_gallery', 'sphinx_mdinclude', @@ -30,39 +31,60 @@ '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 = { @@ -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' diff --git a/docs/index.rst b/docs/index.rst index 588f043..99795eb 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -28,7 +28,7 @@ Welcome to mloptimizer's documentation! :maxdepth: 3 :caption: API reference: - autoapi/index + api/api_reference .. toctree:: :maxdepth: 1 diff --git a/mloptimizer/interfaces/api/hyperspace_builder.py b/mloptimizer/interfaces/api/hyperspace_builder.py index d2dad6a..7aeb2f8 100644 --- a/mloptimizer/interfaces/api/hyperspace_builder.py +++ b/mloptimizer/interfaces/api/hyperspace_builder.py @@ -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) \ No newline at end of file diff --git a/requirements_dev.txt b/requirements_dev.txt index 24c4b68..2e5c0c9 100755 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -23,4 +23,5 @@ sphinx_mdinclude sphinxcontrib-mermaid tensorflow>=2.12.0 tqdm -xgboost>=1.7.3 \ No newline at end of file +xgboost>=1.7.3 +hyperopt \ No newline at end of file diff --git a/requirements_docs.txt b/requirements_docs.txt index feb8dc0..f109755 100644 --- a/requirements_docs.txt +++ b/requirements_docs.txt @@ -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 \ No newline at end of file