FLAML


NameFLAML JSON
Version 0.3.6 PyPI version JSON
download
home_pagehttps://github.com/microsoft/FLAML
SummaryA fast and lightweight autoML system
upload_time2021-05-07 04:39:35
maintainer
docs_urlNone
authorMicrosoft Corporation
requires_python>=3.6
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![PyPI version](https://badge.fury.io/py/FLAML.svg)](https://badge.fury.io/py/FLAML)
[![Build](https://github.com/microsoft/FLAML/actions/workflows/python-package.yml/badge.svg)](https://github.com/microsoft/FLAML/actions/workflows/python-package.yml)
![Python Version](https://img.shields.io/badge/3.6%20%7C%203.7%20%7C%203.8-blue)
[![Downloads](https://pepy.tech/badge/flaml/month)](https://pepy.tech/project/flaml)
[![Join the chat at https://gitter.im/FLAMLer/community](https://badges.gitter.im/FLAMLer/community.svg)](https://gitter.im/FLAMLer/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

# FLAML - Fast and Lightweight AutoML

<p align="center">
    <img src="https://github.com/microsoft/FLAML/blob/main/docs/images/FLAML.png"  width=200>
    <br>
</p>

FLAML is a lightweight Python library that finds accurate machine
learning models automatically, efficiently and economically. It frees users from selecting
learners and hyperparameters for each learner. It is fast and economical. 
The simple and lightweight design makes it easy to extend, such as
adding customized learners or metrics. FLAML is powered by a new, [cost-effective
hyperparameter optimization](https://github.com/microsoft/FLAML/tree/main/flaml/tune)
and learner selection method invented by Microsoft Research.
FLAML leverages the structure of the search space to choose a search order optimized for both cost and error. For example, the system tends to propose cheap configurations at the beginning stage of the search,
but quickly moves to configurations with high model complexity and large sample size when needed in the later stage of the search. For another example, it favors cheap learners in the beginning but penalizes them later if the error improvement is slow. The cost-bounded search and cost-based prioritization make a big difference in the search efficiency under budget constraints.

## Installation

FLAML requires **Python version >= 3.6**. It can be installed from pip:

```bash
pip install flaml
```

To run the [`notebook example`](https://github.com/microsoft/FLAML/tree/main/notebook),
install flaml with the [notebook] option:

```bash
pip install flaml[notebook]
```

## Quickstart

* With three lines of code, you can start using this economical and fast
AutoML engine as a scikit-learn style estimator.
```python
from flaml import AutoML
automl = AutoML()
automl.fit(X_train, y_train, task="classification")
```

* You can restrict the learners and use FLAML as a fast hyperparameter tuning
tool for XGBoost, LightGBM, Random Forest etc. or a customized learner.
```python
automl.fit(X_train, y_train, task="classification", estimator_list=["lgbm"])
```

* You can also run generic ray-tune style hyperparameter tuning for a custom function.
```python
from flaml import tune
tune.run(train_with_config, config={…}, low_cost_partial_config={…}, time_budget_s=3600)
```

## Advantages

* For classification and regression tasks, find quality models with lower computational resources.
* Users can choose their desired customizability: minimal customization (computational resource budget), medium customization (e.g., scikit-style learner, search space and metric), full customization (arbitrary training and evaluation code).
* Allow human guidance in hyperparameter tuning to respect prior on certain subspaces but also able to explore other subspaces.

## Examples

A basic classification example.

```python
from flaml import AutoML
from sklearn.datasets import load_iris
# Initialize an AutoML instance
automl = AutoML()
# Specify automl goal and constraint
automl_settings = {
    "time_budget": 10,  # in seconds
    "metric": 'accuracy',
    "task": 'classification',
    "log_file_name": "test/iris.log",
}
X_train, y_train = load_iris(return_X_y=True)
# Train with labeled input data
automl.fit(X_train=X_train, y_train=y_train,
                        **automl_settings)
# Predict
print(automl.predict_proba(X_train))
# Export the best model
print(automl.model)
```

A basic regression example.

```python
from flaml import AutoML
from sklearn.datasets import load_boston
# Initialize an AutoML instance
automl = AutoML()
# Specify automl goal and constraint
automl_settings = {
    "time_budget": 10,  # in seconds
    "metric": 'r2',
    "task": 'regression',
    "log_file_name": "test/boston.log",
}
X_train, y_train = load_boston(return_X_y=True)
# Train with labeled input data
automl.fit(X_train=X_train, y_train=y_train,
                        **automl_settings)
# Predict
print(automl.predict(X_train))
# Export the best model
print(automl.model)
```

More examples can be found in [notebooks](https://github.com/microsoft/FLAML/tree/main/notebook/).

## Documentation

The API documentation is [here](https://microsoft.github.io/FLAML/).

Read more about the 
hyperparameter optimization methods
in FLAML [here](https://github.com/microsoft/FLAML/tree/main/flaml/tune). They can be used beyond the AutoML context. 
And they can be used in distributed HPO frameworks such as ray tune or nni.

For more technical details, please check our papers.

* [FLAML: A Fast and Lightweight AutoML Library](https://www.microsoft.com/en-us/research/publication/flaml-a-fast-and-lightweight-automl-library/). Chi Wang, Qingyun Wu, Markus Weimer, Erkang Zhu. MLSys, 2021.
```
@inproceedings{wang2021flaml,
    title={FLAML: A Fast and Lightweight AutoML Library},
    author={Chi Wang and Qingyun Wu and Markus Weimer and Erkang Zhu},
    year={2021},
    booktitle={MLSys},
}
```
* [Frugal Optimization for Cost-related Hyperparameters](https://arxiv.org/abs/2005.01571). Qingyun Wu, Chi Wang, Silu Huang. AAAI 2021.
* [Economical Hyperparameter Optimization With Blended Search Strategy](https://www.microsoft.com/en-us/research/publication/economical-hyperparameter-optimization-with-blended-search-strategy/). Chi Wang, Qingyun Wu, Silu Huang, Amin Saied. ICLR 2021.

## Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visit <https://cla.opensource.microsoft.com>.

If you are new to GitHub [here](https://help.github.com/categories/collaborating-with-issues-and-pull-requests/) is a detailed help source on getting involved with development on GitHub.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.

## Developing

### Setup:

```
git clone https://github.com/microsoft/FLAML.git
pip install -e .[test,notebook]
```

### Coverage
Any code you commit should generally not significantly impact coverage. To run all unit tests:
```
coverage run -m pytest test
```

If all the tests are passed, please also test run notebook/flaml_automl to make sure your commit does not break the notebook example.

## Authors

* Chi Wang
* Qingyun Wu

Contributors (alphabetical order): Sebastien Bubeck, Surajit Chaudhuri, Nadiia Chepurko, Ofer Dekel, Alex Deng, Anshuman Dutt, Nicolo Fusi, Jianfeng Gao, Johannes Gehrke, Silu Huang, Dongwoo Kim, Christian Konig, John Langford, Amin Saied, Neil Tenenholtz, Markus Weimer, Haozhe Zhang, Erkang Zhu.

## License

[MIT License](LICENSE)



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/microsoft/FLAML",
    "name": "FLAML",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "",
    "author": "Microsoft Corporation",
    "author_email": "hpo@microsoft.com",
    "download_url": "https://files.pythonhosted.org/packages/01/9d/40abcb03b48e056eb16076fc09cc0bba49975a99d5c20041885714800628/FLAML-0.3.6.tar.gz",
    "platform": "",
    "description": "[![PyPI version](https://badge.fury.io/py/FLAML.svg)](https://badge.fury.io/py/FLAML)\n[![Build](https://github.com/microsoft/FLAML/actions/workflows/python-package.yml/badge.svg)](https://github.com/microsoft/FLAML/actions/workflows/python-package.yml)\n![Python Version](https://img.shields.io/badge/3.6%20%7C%203.7%20%7C%203.8-blue)\n[![Downloads](https://pepy.tech/badge/flaml/month)](https://pepy.tech/project/flaml)\n[![Join the chat at https://gitter.im/FLAMLer/community](https://badges.gitter.im/FLAMLer/community.svg)](https://gitter.im/FLAMLer/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)\n\n# FLAML - Fast and Lightweight AutoML\n\n<p align=\"center\">\n    <img src=\"https://github.com/microsoft/FLAML/blob/main/docs/images/FLAML.png\"  width=200>\n    <br>\n</p>\n\nFLAML is a lightweight Python library that finds accurate machine\nlearning models automatically, efficiently and economically. It frees users from selecting\nlearners and hyperparameters for each learner. It is fast and economical. \nThe simple and lightweight design makes it easy to extend, such as\nadding customized learners or metrics. FLAML is powered by a new, [cost-effective\nhyperparameter optimization](https://github.com/microsoft/FLAML/tree/main/flaml/tune)\nand learner selection method invented by Microsoft Research.\nFLAML leverages the structure of the search space to choose a search order optimized for both cost and error. For example, the system tends to propose cheap configurations at the beginning stage of the search,\nbut quickly moves to configurations with high model complexity and large sample size when needed in the later stage of the search. For another example, it favors cheap learners in the beginning but penalizes them later if the error improvement is slow. The cost-bounded search and cost-based prioritization make a big difference in the search efficiency under budget constraints.\n\n## Installation\n\nFLAML requires **Python version >= 3.6**. It can be installed from pip:\n\n```bash\npip install flaml\n```\n\nTo run the [`notebook example`](https://github.com/microsoft/FLAML/tree/main/notebook),\ninstall flaml with the [notebook] option:\n\n```bash\npip install flaml[notebook]\n```\n\n## Quickstart\n\n* With three lines of code, you can start using this economical and fast\nAutoML engine as a scikit-learn style estimator.\n```python\nfrom flaml import AutoML\nautoml = AutoML()\nautoml.fit(X_train, y_train, task=\"classification\")\n```\n\n* You can restrict the learners and use FLAML as a fast hyperparameter tuning\ntool for XGBoost, LightGBM, Random Forest etc. or a customized learner.\n```python\nautoml.fit(X_train, y_train, task=\"classification\", estimator_list=[\"lgbm\"])\n```\n\n* You can also run generic ray-tune style hyperparameter tuning for a custom function.\n```python\nfrom flaml import tune\ntune.run(train_with_config, config={\u00e2\u20ac\u00a6}, low_cost_partial_config={\u00e2\u20ac\u00a6}, time_budget_s=3600)\n```\n\n## Advantages\n\n* For classification and regression tasks, find quality models with lower computational resources.\n* Users can choose their desired customizability: minimal customization (computational resource budget), medium customization (e.g., scikit-style learner, search space and metric), full customization (arbitrary training and evaluation code).\n* Allow human guidance in hyperparameter tuning to respect prior on certain subspaces but also able to explore other subspaces.\n\n## Examples\n\nA basic classification example.\n\n```python\nfrom flaml import AutoML\nfrom sklearn.datasets import load_iris\n# Initialize an AutoML instance\nautoml = AutoML()\n# Specify automl goal and constraint\nautoml_settings = {\n    \"time_budget\": 10,  # in seconds\n    \"metric\": 'accuracy',\n    \"task\": 'classification',\n    \"log_file_name\": \"test/iris.log\",\n}\nX_train, y_train = load_iris(return_X_y=True)\n# Train with labeled input data\nautoml.fit(X_train=X_train, y_train=y_train,\n                        **automl_settings)\n# Predict\nprint(automl.predict_proba(X_train))\n# Export the best model\nprint(automl.model)\n```\n\nA basic regression example.\n\n```python\nfrom flaml import AutoML\nfrom sklearn.datasets import load_boston\n# Initialize an AutoML instance\nautoml = AutoML()\n# Specify automl goal and constraint\nautoml_settings = {\n    \"time_budget\": 10,  # in seconds\n    \"metric\": 'r2',\n    \"task\": 'regression',\n    \"log_file_name\": \"test/boston.log\",\n}\nX_train, y_train = load_boston(return_X_y=True)\n# Train with labeled input data\nautoml.fit(X_train=X_train, y_train=y_train,\n                        **automl_settings)\n# Predict\nprint(automl.predict(X_train))\n# Export the best model\nprint(automl.model)\n```\n\nMore examples can be found in [notebooks](https://github.com/microsoft/FLAML/tree/main/notebook/).\n\n## Documentation\n\nThe API documentation is [here](https://microsoft.github.io/FLAML/).\n\nRead more about the \nhyperparameter optimization methods\nin FLAML [here](https://github.com/microsoft/FLAML/tree/main/flaml/tune). They can be used beyond the AutoML context. \nAnd they can be used in distributed HPO frameworks such as ray tune or nni.\n\nFor more technical details, please check our papers.\n\n* [FLAML: A Fast and Lightweight AutoML Library](https://www.microsoft.com/en-us/research/publication/flaml-a-fast-and-lightweight-automl-library/). Chi Wang, Qingyun Wu, Markus Weimer, Erkang Zhu. MLSys, 2021.\n```\n@inproceedings{wang2021flaml,\n    title={FLAML: A Fast and Lightweight AutoML Library},\n    author={Chi Wang and Qingyun Wu and Markus Weimer and Erkang Zhu},\n    year={2021},\n    booktitle={MLSys},\n}\n```\n* [Frugal Optimization for Cost-related Hyperparameters](https://arxiv.org/abs/2005.01571). Qingyun Wu, Chi Wang, Silu Huang. AAAI 2021.\n* [Economical Hyperparameter Optimization With Blended Search Strategy](https://www.microsoft.com/en-us/research/publication/economical-hyperparameter-optimization-with-blended-search-strategy/). Chi Wang, Qingyun Wu, Silu Huang, Amin Saied. ICLR 2021.\n\n## Contributing\n\nThis project welcomes contributions and suggestions. Most contributions require you to agree to a\nContributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us\nthe rights to use your contribution. For details, visit <https://cla.opensource.microsoft.com>.\n\nIf you are new to GitHub [here](https://help.github.com/categories/collaborating-with-issues-and-pull-requests/) is a detailed help source on getting involved with development on GitHub.\n\nWhen you submit a pull request, a CLA bot will automatically determine whether you need to provide\na CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions\nprovided by the bot. You will only need to do this once across all repos using our CLA.\n\nThis project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).\nFor more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or\ncontact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.\n\n## Developing\n\n### Setup:\n\n```\ngit clone https://github.com/microsoft/FLAML.git\npip install -e .[test,notebook]\n```\n\n### Coverage\nAny code you commit should generally not significantly impact coverage. To run all unit tests:\n```\ncoverage run -m pytest test\n```\n\nIf all the tests are passed, please also test run notebook/flaml_automl to make sure your commit does not break the notebook example.\n\n## Authors\n\n* Chi Wang\n* Qingyun Wu\n\nContributors (alphabetical order): Sebastien Bubeck, Surajit Chaudhuri, Nadiia Chepurko, Ofer Dekel, Alex Deng, Anshuman Dutt, Nicolo Fusi, Jianfeng Gao, Johannes Gehrke, Silu Huang, Dongwoo Kim, Christian Konig, John Langford, Amin Saied, Neil Tenenholtz, Markus Weimer, Haozhe Zhang, Erkang Zhu.\n\n## License\n\n[MIT License](LICENSE)\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A fast and lightweight autoML system",
    "version": "0.3.6",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "7504d18b1151263635316f69976dea02",
                "sha256": "7cd1813cdfe625f5355c362f1c8c817f095bae8b437ebebfdfb8145b61400137"
            },
            "downloads": -1,
            "filename": "FLAML-0.3.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7504d18b1151263635316f69976dea02",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 87031,
            "upload_time": "2021-05-07T04:39:32",
            "upload_time_iso_8601": "2021-05-07T04:39:32.711393Z",
            "url": "https://files.pythonhosted.org/packages/3c/78/401532fcea819e6c69c9621da18d342c9c7d2e37459e709c0cc2fdd8f8b0/FLAML-0.3.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "418b7691eaf5669e26c85bb9d9d6a50e",
                "sha256": "cc2d64c62372836ab6c9969b74cd28e7726133765fd5fca21ea846dd5433c335"
            },
            "downloads": -1,
            "filename": "FLAML-0.3.6.tar.gz",
            "has_sig": false,
            "md5_digest": "418b7691eaf5669e26c85bb9d9d6a50e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 67870,
            "upload_time": "2021-05-07T04:39:35",
            "upload_time_iso_8601": "2021-05-07T04:39:35.435332Z",
            "url": "https://files.pythonhosted.org/packages/01/9d/40abcb03b48e056eb16076fc09cc0bba49975a99d5c20041885714800628/FLAML-0.3.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-05-07 04:39:35",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": null,
    "github_project": "microsoft",
    "error": "Could not fetch GitHub repository",
    "lcname": "flaml"
}
        
Elapsed time: 0.31443s