Skip to content

Commit

Permalink
Merge pull request #37 from rodrigo-arenas/0.6.Xdev
Browse files Browse the repository at this point in the history
[PR] Installation dependencies
  • Loading branch information
rodrigo-arenas committed Jun 25, 2021
2 parents a0f5256 + 6de32a8 commit 3e24181
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 16 deletions.
5 changes: 5 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ It's advised to install sklearn-genetic using a virtual env, inside the env use:

pip install sklearn-genetic-opt

If you want to get all the features, including plotting and mlflow logging capabilities,
install all the extra packages::

pip install sklearn-genetic-opt[all]

Example
#######

Expand Down
18 changes: 16 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ It's advised to install sklearn-genetic using a virtual env, inside the env use:

pip install sklearn-genetic-opt

Or install with the extra packages to get the full functionalities::

pip install sklearn-genetic-opt[all]

.. |PythonMinVersion| replace:: 3.7
.. |ScikitLearnMinVersion| replace:: 0.21.3
.. |NumPyMinVersion| replace:: 1.14.5
Expand All @@ -34,9 +38,15 @@ sklearn-genetic-opt requires:
- Python (>= |PythonMinVersion|)
- scikit-learn (>= |ScikitLearnMinVersion|)
- NumPy (>= |NumPyMinVersion|)
- Seaborn (>= |SeabornMinVersion|)
- DEAP (>= |DEAPMinVersion|)

extra requirements:

These requirements are necessary to use the
:mod:`~sklearn_genetic.plots` and :class:`~sklearn_genetic.mlflow.MLflowConfig` modules

- MLflow (>= |MLflowMinVersion|)
- Seaborn (>= |SeabornMinVersion|)

.. toctree::
:maxdepth: 2
Expand All @@ -48,7 +58,6 @@ sklearn-genetic-opt requires:
tutorials/custom_callback
tutorials/understand_cv
tutorials/mlflow
release_notes

.. toctree::
:maxdepth: 2
Expand All @@ -60,6 +69,11 @@ sklearn-genetic-opt requires:
notebooks/Digits_decision_tree.ipynb
notebooks/MLflow_logger.ipynb

.. toctree::
:maxdepth: 2
:caption: Release Notes

release_notes

.. toctree::
:maxdepth: 2
Expand Down
9 changes: 9 additions & 0 deletions docs/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,21 @@ Features:
* Added support for extra methods coming from scikit-learn's BaseSearchCV, it is
still partial support, missing properties like `cv_results_`, `best_index_` and `multimetric_`.

^^^^^^^^^^^^
API Changes:
^^^^^^^^^^^^

* The modules :mod:`~sklearn_genetic.plots` and :class:`~sklearn_genetic.mlflow.MLflowConfig`
now requires an explicit installation of seaborn and mlflow, now those
are optionally installed using ``pip install sklearn-genetic-opt[all].``

^^^^^
Docs:
^^^^^

* Edited all demos to be in the jupyter notebook format.
* Added embedded jupyter notebooks examples
* The modules of the package now have a summary of their classes/functions in the docs

What's new in 0.5.0
-------------------
Expand Down
12 changes: 8 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,19 @@
"Documentation": "https://sklearn-genetic-opt.readthedocs.io/en/stable/",
"Source Code": "https://github.com/rodrigo-arenas/Sklearn-genetic-opt",
},
packages=find_packages(include=["sklearn_genetic", "sklearn_genetic.*"]),
packages=find_packages(
include=["sklearn_genetic", "sklearn_genetic.*"], exclude=["*tests*"]
),
install_requires=[
"scikit-learn>=0.21.3",
"numpy>=1.14.5",
"seaborn>=0.9.0",
"deap>=1.3.1",
"pydantic>=1.8.2",
"mlflow>=1.17.0",
],
extras_require={
"mlflow": ["mlflow>=1.17.0"],
"seaborn": ["seaborn>=0.9.0"],
"all": ["mlflow>=1.17.0", "seaborn>=0.9.0"],
},
python_requires=">=3.7",
include_package_data=True,
)
7 changes: 2 additions & 5 deletions sklearn_genetic/__init__.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
from .genetic_search import GASearchCV
from .plots import plot_fitness_evolution, plot_search_space

from .callbacks import (
ThresholdStopping,
ConsecutiveStopping,
DeltaThreshold,
LogbookSaver,
)
from .mlflow import MLflowConfig


from ._version import __version__

__all__ = [
"GASearchCV",
"plot_fitness_evolution",
"plot_search_space",
"ThresholdStopping",
"ConsecutiveStopping",
"DeltaThreshold",
"LogbookSaver",
"MLflowConfig",
"__version__",
]
9 changes: 8 additions & 1 deletion sklearn_genetic/mlflow.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import mlflow
import logging

# Check if mlflow is installed as an extra requirement
try:
import mlflow
except ModuleNotFoundError: # noqa
logger = logging.getLogger(__name__) # noqa
logger.error("MLflow not found, pip install mlflow to use MLflowConfig") # noqa


class MLflowConfig:
Expand Down
12 changes: 10 additions & 2 deletions sklearn_genetic/plots.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import seaborn as sns
import logging

# Check if seaborn is installed as an extra requirement
try:
import seaborn as sns
except ModuleNotFoundError: # noqa
logger = logging.getLogger(__name__) # noqa
logger.error(
"seaborn not found, pip install seaborn to use plots functions"
) # noqa

from .utils import logbook_to_pandas
from .parameters import Metrics


"""
This module contains some useful function to explore the results of the optimization routines
"""
Expand Down
4 changes: 2 additions & 2 deletions sklearn_genetic/tests/test_genetic_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ def test_expected_ga_results():
("eaSimple", ThresholdStopping(threshold=0.01)),
("eaMuPlusLambda", ThresholdStopping(threshold=0.01)),
("eaMuCommaLambda", ThresholdStopping(threshold=0.01)),
("eaSimple", TimerStopping(total_seconds=5)),
("eaMuPlusLambda", TimerStopping(total_seconds=5)),
("eaSimple", TimerStopping(total_seconds=0.5)),
("eaMuPlusLambda", TimerStopping(total_seconds=2)),
("eaMuCommaLambda", TimerStopping(total_seconds=5)),
("eaSimple", ConsecutiveStopping(generations=5, metric="fitness")),
("eaMuPlusLambda", ConsecutiveStopping(generations=5, metric="fitness")),
Expand Down

0 comments on commit 3e24181

Please sign in to comment.