{"id":5933,"library":"flaml","title":"FLAML: A Fast Library for Automated Machine Learning and Tuning","description":"FLAML (Fast Library for Automated Machine Learning) is an open-source Python library developed by Microsoft for efficient automation of machine learning and AI operations. It streamlines tasks such as model selection and hyperparameter optimization, and supports a wide range of models including classical machine learning algorithms, deep neural networks, and large language models. Currently at version 2.5.0, FLAML maintains an active development cycle, regularly releasing updates that include expanded Python version compatibility (e.g., Python 3.13 support), performance enhancements, and comprehensive documentation improvements.","status":"active","version":"2.5.0","language":"en","source_language":"en","source_url":"https://github.com/microsoft/FLAML","tags":["machine learning","automl","hyperparameter tuning","mlops","llm","classification","regression","time series"],"install":[{"cmd":"pip install flaml","lang":"bash","label":"Base Installation"},{"cmd":"pip install \"flaml[automl]\"","lang":"bash","label":"With core AutoML dependencies (recommended)"}],"dependencies":[{"reason":"FLAML requires Python version >= 3.10 and < 3.14.","package":"python","optional":false},{"reason":"Often a core dependency for ML tasks, implicitly required by some FLAML functionalities or when installing `flaml[automl]`.","package":"scikit-learn","optional":true},{"reason":"Commonly used default estimator within FLAML's AutoML and for Zero-shot AutoML.","package":"lightgbm","optional":true},{"reason":"Commonly used default estimator within FLAML's AutoML and for Zero-shot AutoML.","package":"xgboost","optional":true}],"imports":[{"symbol":"AutoML","correct":"from flaml import AutoML"},{"note":"Used for generic hyperparameter tuning of user-defined functions.","symbol":"tune","correct":"from flaml import tune"},{"note":"For Zero-shot AutoML, enabling automatic hyperparameter selection for LightGBM with existing API.","symbol":"LGBMRegressor","correct":"from flaml.default import LGBMRegressor"},{"note":"The `autogen` module has been moved to its own dedicated `autogen` library. Install it separately (`pip install autogen`) and import directly.","wrong":"from flaml import autogen","symbol":"autogen","correct":"import autogen"}],"quickstart":{"code":"from flaml import AutoML\nfrom sklearn.datasets import load_iris\nfrom sklearn.model_selection import train_test_split\n\n# Load a sample dataset\nX, y = load_iris(return_X_y=True)\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)\n\n# Initialize AutoML\nautoml = AutoML()\n\n# Define settings for AutoML\nautoml_settings = {\n    \"time_budget\": 10,  # in seconds\n    \"metric\": \"accuracy\",\n    \"task\": \"classification\",\n    \"log_file_name\": \"flaml_iris.log\", # Optional: logs will be saved here\n}\n\n# Train the AutoML model\nprint(\"Starting AutoML training...\")\nautoml.fit(X_train=X_train, y_train=y_train, **automl_settings)\nprint(\"AutoML training finished.\")\n\n# Best model details\nprint(f\"Best estimator: {automl.model.estimator}\")\nprint(f\"Best metric: {automl.best_result['accuracy']}\")\n\n# Make predictions\npredictions = automl.predict(X_test)\nprint(f\"Sample predictions: {predictions[:5]}\")","lang":"python","description":"This quickstart demonstrates how to perform a basic classification task using FLAML's AutoML functionality. It loads the Iris dataset, splits it into training and testing sets, initializes an `AutoML` instance, and trains a model within a specified time budget. The best model and its performance metric are then printed, followed by sample predictions."},"warnings":[{"fix":"Ensure your Python environment is version 3.10 or newer (e.g., 3.10, 3.11, 3.12, 3.13) and less than 3.14. Upgrade your Python installation if necessary.","message":"FLAML's Python version requirements have become stricter. As of version 2.5.0, it requires Python >= 3.10 and < 3.14. Using older Python versions will result in installation failures or runtime errors.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Install the `autogen` library separately (`pip install autogen`) and import directly from `autogen` (e.g., `from autogen import ...`).","message":"The `autogen` module, previously bundled with FLAML, has been moved to its own independent `autogen` library. Attempting to import `flaml.autogen` will fail.","severity":"breaking","affected_versions":">=2.0.0 (exact version of removal not specified, but affected latest versions)"},{"fix":"Ensure `ray` is installed as version 2 or higher (`pip install ray[tune]`). If explicitly using `tune.report`, use `from flaml import tune; tune.report(...)` or `from ray import tune; tune.report(...)` consistently within your training functions.","message":"When integrating with Ray Tune, the import path for `tune.report` might cause issues if not updated for `ray>=2`. Older `ray` versions or inconsistent imports can lead to errors.","severity":"gotcha","affected_versions":">=2.3.4 (when using Ray Tune)"},{"fix":"Provide a `low_cost_partial_config` argument to `tune.run` that specifies hyperparameter values corresponding to low training costs. Refer to FLAML's documentation for examples.","message":"When using `flaml.tune.run` for hyperparameter optimization, a warning might appear regarding missing 'low_cost_partial_config'. This parameter is crucial for cost-frugal search, and omitting it can lead to less efficient tuning.","severity":"gotcha","affected_versions":">=2.2.0 (when using `flaml.tune.run`)"},{"fix":"Explicitly set `log_file_name` in your `automl_settings` to a known writable and accessible path within the environment, such as `/tmp/your_custom_log.log` on Linux-based systems or cloud environments.","message":"In specific deployment environments (e.g., Snowflake Snowpark), the default log file path set in `automl_settings` might not be writable or accessible, causing failures. The path `iris.log` in the quickstart is relative to the current working directory, which might not be appropriate in sandboxed environments.","severity":"gotcha","affected_versions":"All versions (when deployed in constrained environments)"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}