
[](https://mloptimizer.readthedocs.io/en/master/?badge=master)
[](https://badge.fury.io/py/mloptimizer)
[](https://pypi.python.org/pypi/mloptimizer/)
[](https://github.com/Caparrini/mloptimizer/actions/workflows/CI.yml)
[](https://app.codecov.io/gh/Caparrini/mloptimizer)
[](https://www.buymeacoffee.com/caparrini)
**mloptimizer** is a Python library for optimizing hyperparameters of machine learning algorithms using genetic algorithms.
With mloptimizer, you can find the optimal set of hyperparameters for a given machine learning model and dataset, which can significantly improve the performance of the model.
The library supports several popular machine learning algorithms, including decision trees, random forests, and gradient boosting classifiers.
The genetic algorithm used in mloptimizer provides an efficient and flexible approach to search for the optimal hyperparameters in a large search space.
## Features
- Easy to use
- DEAP-based genetic algorithm ready to use with several machine learning algorithms
- Adaptable to use with any machine learning algorithm that complies with the Scikit-Learn API
- Default hyperparameter ranges
- Default score functions for evaluating the performance of the model
- Reproducibility of results
## Advanced Features
- Extensible with more machine learning algorithms that comply with the Scikit-Learn API
- Customizable hyperparameter ranges
- Customizable score functions
- Optional mlflow compatibility for tracking the optimization process
## Installation
It is recommended to create a virtual environment using the `venv` package.
To learn more about how to use `venv`,
check out the official Python documentation at
https://docs.python.org/3/library/venv.html.
```bash
# Create the virtual environment
python -m venv myenv
# Activate the virtual environment
source myenv/bin/activate
```
To install `mloptimizer`, run:
```bash
pip install mloptimizer
```
You can get more information about the package installation at https://pypi.org/project/mloptimizer/.
### Quickstart
Here's a simple example of how to optimize hyperparameters in a decision tree classifier using the iris dataset:
```python
from mloptimizer.interfaces import GeneticSearch, HyperparameterSpaceBuilder
from sklearn.tree import DecisionTreeClassifier
from sklearn.datasets import load_iris
# 1) Load the dataset and get the features and target
X, y = load_iris(return_X_y=True)
# 2) Define the hyperparameter space (a default space is provided for some algorithms)
hyperparameter_space = HyperparameterSpaceBuilder.get_default_space(DecisionTreeClassifier)
# 3) Create the optimizer and optimize the classifier
# - 10 generations starting with a population of 10 individuals, other parameters are set to default
opt = GeneticSearch(estimator_class=DecisionTreeClassifier,
hyperparam_space=hyperparameter_space,
genetic_params_dict={"generations": 5, "population_size": 5}
)
# 4) Optimize the classifier, the optimization returns the best estimator found in the optimization process
opt.fit(X, y)
print(opt.best_estimator_)
```
Other algorithms can be used, such as `RandomForestClassifier` or `XGBClassifier` which have a
default hyperparameter space defined in the library.
Even if the algorithm is not included in the default hyperparameter space, you can define your own hyperparameter space
following the documentation.
More details in the [documentation](http://mloptimizer.readthedocs.io/).
## Examples
Examples can be found in [examples](https://mloptimizer.readthedocs.io/en/master/auto_examples/index.html) on readthedocs.io.
## Dependencies
The following dependencies are used in `mloptimizer`:
* [Deap](https://github.com/DEAP/deap) - Genetic Algorithms
* [XGBoost](https://github.com/dmlc/xgboost) - Gradient boosting classifier
* [Scikit-Learn](https://github.com/scikit-learn/scikit-learn) - Machine learning algorithms and utilities
Optional:
* [Keras](https://keras.io) - Deep learning library
* [mlflow](https://mlflow.org) - Tracking the optimization process
## Documentation
The documentation for `mloptimizer` can be found in the project's [wiki](http://mloptimizer.readthedocs.io/)
with examples, classes and methods reference.
## Authors
* **Antonio Caparrini** - *Author* - [caparrini](https://github.com/caparrini)
* **Javier Arroyo Gallardo** - *Author* - [javiag](https://github.com/javiag)
## Analytics

## License
This project is licensed under the [MIT License](LICENSE).
Raw data
{
"_id": null,
"home_page": "https://github.com/Caparrini/mloptimizer",
"name": "mloptimizer",
"maintainer": null,
"docs_url": null,
"requires_python": "<3.12,>=3.9",
"maintainer_email": null,
"keywords": "xgboost, genetic, deap",
"author": "Antonio Caparrini L\u00f3pez, Javier Arroyo Gallardo",
"author_email": "acaparri@ucm.es",
"download_url": "https://files.pythonhosted.org/packages/68/be/4bd8cfa19788a521ef3e63fc2a02767ec697e86f69946c2bf432acfd8bf8/mloptimizer-0.9.0.3.tar.gz",
"platform": null,
"description": "\n\n[](https://mloptimizer.readthedocs.io/en/master/?badge=master)\n[](https://badge.fury.io/py/mloptimizer)\n[](https://pypi.python.org/pypi/mloptimizer/)\n[](https://github.com/Caparrini/mloptimizer/actions/workflows/CI.yml)\n[](https://app.codecov.io/gh/Caparrini/mloptimizer)\n[](https://www.buymeacoffee.com/caparrini)\n\n\n\n**mloptimizer** is a Python library for optimizing hyperparameters of machine learning algorithms using genetic algorithms. \nWith mloptimizer, you can find the optimal set of hyperparameters for a given machine learning model and dataset, which can significantly improve the performance of the model. \nThe library supports several popular machine learning algorithms, including decision trees, random forests, and gradient boosting classifiers. \nThe genetic algorithm used in mloptimizer provides an efficient and flexible approach to search for the optimal hyperparameters in a large search space.\n\n## Features\n- Easy to use\n- DEAP-based genetic algorithm ready to use with several machine learning algorithms\n- Adaptable to use with any machine learning algorithm that complies with the Scikit-Learn API\n- Default hyperparameter ranges\n- Default score functions for evaluating the performance of the model\n- Reproducibility of results\n\n## Advanced Features\n- Extensible with more machine learning algorithms that comply with the Scikit-Learn API\n- Customizable hyperparameter ranges\n- Customizable score functions\n- Optional mlflow compatibility for tracking the optimization process\n\n## Installation\n\nIt is recommended to create a virtual environment using the `venv` package. \nTo learn more about how to use `venv`, \ncheck out the official Python documentation at \nhttps://docs.python.org/3/library/venv.html.\n\n```bash\n# Create the virtual environment\npython -m venv myenv\n# Activate the virtual environment\nsource myenv/bin/activate\n```\n\nTo install `mloptimizer`, run:\n\n```bash\npip install mloptimizer\n```\n\nYou can get more information about the package installation at https://pypi.org/project/mloptimizer/.\n\n\n### Quickstart\n\nHere's a simple example of how to optimize hyperparameters in a decision tree classifier using the iris dataset:\n\n```python\nfrom mloptimizer.interfaces import GeneticSearch, HyperparameterSpaceBuilder\nfrom sklearn.tree import DecisionTreeClassifier\nfrom sklearn.datasets import load_iris\n\n# 1) Load the dataset and get the features and target\nX, y = load_iris(return_X_y=True)\n\n# 2) Define the hyperparameter space (a default space is provided for some algorithms)\nhyperparameter_space = HyperparameterSpaceBuilder.get_default_space(DecisionTreeClassifier)\n\n# 3) Create the optimizer and optimize the classifier\n# - 10 generations starting with a population of 10 individuals, other parameters are set to default\n\nopt = GeneticSearch(estimator_class=DecisionTreeClassifier,\n hyperparam_space=hyperparameter_space,\n genetic_params_dict={\"generations\": 5, \"population_size\": 5}\n )\n\n# 4) Optimize the classifier, the optimization returns the best estimator found in the optimization process\nopt.fit(X, y)\n\nprint(opt.best_estimator_)\n```\nOther algorithms can be used, such as `RandomForestClassifier` or `XGBClassifier` which have a \ndefault hyperparameter space defined in the library.\nEven if the algorithm is not included in the default hyperparameter space, you can define your own hyperparameter space\nfollowing the documentation.\n\n\nMore details in the [documentation](http://mloptimizer.readthedocs.io/).\n\n## Examples\n\nExamples can be found in [examples](https://mloptimizer.readthedocs.io/en/master/auto_examples/index.html) on readthedocs.io.\n\n## Dependencies\n\nThe following dependencies are used in `mloptimizer`:\n\n* [Deap](https://github.com/DEAP/deap) - Genetic Algorithms\n* [XGBoost](https://github.com/dmlc/xgboost) - Gradient boosting classifier\n* [Scikit-Learn](https://github.com/scikit-learn/scikit-learn) - Machine learning algorithms and utilities\n\nOptional:\n* [Keras](https://keras.io) - Deep learning library\n* [mlflow](https://mlflow.org) - Tracking the optimization process\n\n## Documentation\n\nThe documentation for `mloptimizer` can be found in the project's [wiki](http://mloptimizer.readthedocs.io/)\nwith examples, classes and methods reference.\n\n\n## Authors\n\n* **Antonio Caparrini** - *Author* - [caparrini](https://github.com/caparrini)\n* **Javier Arroyo Gallardo** - *Author* - [javiag](https://github.com/javiag)\n\n## Analytics\n\n\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n",
"bugtrack_url": null,
"license": null,
"summary": "mloptimizer is a Python library for optimizing hyperparameters of machine learning algorithms using genetic algorithms.",
"version": "0.9.0.3",
"project_urls": {
"Homepage": "https://github.com/Caparrini/mloptimizer",
"Source": "https://github.com/Caparrini/mloptimizer"
},
"split_keywords": [
"xgboost",
" genetic",
" deap"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "07b17d85cbf72401c20ec651aac178fdb8f41fc9905599fe86a150d9b3830265",
"md5": "cc65dbe43032f6fee1d3df32e1ff7a5c",
"sha256": "8a9ce579e909615640deef8ab3a9f1dd0993ca950815374fe382866351638b64"
},
"downloads": -1,
"filename": "mloptimizer-0.9.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "cc65dbe43032f6fee1d3df32e1ff7a5c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<3.12,>=3.9",
"size": 65996,
"upload_time": "2024-11-07T20:57:50",
"upload_time_iso_8601": "2024-11-07T20:57:50.501096Z",
"url": "https://files.pythonhosted.org/packages/07/b1/7d85cbf72401c20ec651aac178fdb8f41fc9905599fe86a150d9b3830265/mloptimizer-0.9.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "68be4bd8cfa19788a521ef3e63fc2a02767ec697e86f69946c2bf432acfd8bf8",
"md5": "4837a5f656da98ef92f45e52984e3fee",
"sha256": "84e27355a8792f4b98639b4a345afabeaedd908f14f8541082a6e79bc8cae530"
},
"downloads": -1,
"filename": "mloptimizer-0.9.0.3.tar.gz",
"has_sig": false,
"md5_digest": "4837a5f656da98ef92f45e52984e3fee",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<3.12,>=3.9",
"size": 49231,
"upload_time": "2024-11-07T20:57:52",
"upload_time_iso_8601": "2024-11-07T20:57:52.273670Z",
"url": "https://files.pythonhosted.org/packages/68/be/4bd8cfa19788a521ef3e63fc2a02767ec697e86f69946c2bf432acfd8bf8/mloptimizer-0.9.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-07 20:57:52",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Caparrini",
"github_project": "mloptimizer",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "catboost",
"specs": [
[
">=",
"1.1.1"
]
]
},
{
"name": "deap",
"specs": [
[
">=",
"1.3.3"
]
]
},
{
"name": "joblib",
"specs": [
[
">=",
"1.2.0"
]
]
},
{
"name": "kaleido",
"specs": []
},
{
"name": "numpy",
"specs": []
},
{
"name": "pandas",
"specs": [
[
">=",
"1.5.3"
]
]
},
{
"name": "plotly",
"specs": [
[
">=",
"5.15.0"
]
]
},
{
"name": "python-dateutil",
"specs": [
[
">=",
"2.8.1"
]
]
},
{
"name": "pytz",
"specs": [
[
">=",
"2022.7.1"
]
]
},
{
"name": "scikit-learn",
"specs": [
[
">=",
"1.2.1"
]
]
},
{
"name": "scipy",
"specs": [
[
">=",
"1.10.0"
]
]
},
{
"name": "seaborn",
"specs": [
[
"==",
"0.12.2"
]
]
},
{
"name": "six",
"specs": [
[
">=",
"1.15.0"
]
]
},
{
"name": "tqdm",
"specs": []
},
{
"name": "xgboost",
"specs": [
[
">=",
"1.7.3"
]
]
}
],
"lcname": "mloptimizer"
}