A fast library for automated machine learning and tuning
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Enhanced versions of popular machine learning estimators with optimized hyperparameters and intelligent hyperparameter suggestion functions. The default module provides pre-tuned estimators and utilities for automatic hyperparameter configuration.
Pre-configured versions of popular scikit-learn estimators with optimized hyperparameters based on FLAML's research and extensive testing.
class ExtraTreesClassifier:
"""Enhanced ExtraTreesClassifier with optimized hyperparameters."""
def __init__(self, n_estimators=100, **kwargs): ...
def fit(self, X, y, **kwargs): ...
def predict(self, X): ...
def predict_proba(self, X): ...
class ExtraTreesRegressor:
"""Enhanced ExtraTreesRegressor with optimized hyperparameters."""
def __init__(self, n_estimators=100, **kwargs): ...
def fit(self, X, y, **kwargs): ...
def predict(self, X): ...
class LGBMClassifier:
"""Enhanced LightGBM classifier with optimized hyperparameters."""
def __init__(self, n_estimators=100, **kwargs): ...
def fit(self, X, y, **kwargs): ...
def predict(self, X): ...
def predict_proba(self, X): ...
class LGBMRegressor:
"""Enhanced LightGBM regressor with optimized hyperparameters."""
def __init__(self, n_estimators=100, **kwargs): ...
def fit(self, X, y, **kwargs): ...
def predict(self, X): ...
class RandomForestClassifier:
"""Enhanced RandomForest classifier with optimized hyperparameters."""
def __init__(self, n_estimators=100, **kwargs): ...
def fit(self, X, y, **kwargs): ...
def predict(self, X): ...
def predict_proba(self, X): ...
class RandomForestRegressor:
"""Enhanced RandomForest regressor with optimized hyperparameters."""
def __init__(self, n_estimators=100, **kwargs): ...
def fit(self, X, y, **kwargs): ...
def predict(self, X): ...
class XGBClassifier:
"""Enhanced XGBoost classifier with optimized hyperparameters."""
def __init__(self, n_estimators=100, **kwargs): ...
def fit(self, X, y, **kwargs): ...
def predict(self, X): ...
def predict_proba(self, X): ...
class XGBRegressor:
"""Enhanced XGBoost regressor with optimized hyperparameters."""
def __init__(self, n_estimators=100, **kwargs): ...
def fit(self, X, y, **kwargs): ...
def predict(self, X): ...Function for enhancing existing estimators with FLAML's optimized hyperparameters.
def flamlize_estimator(estimator_class, task="classification", **kwargs):
"""
Enhance an estimator class with FLAML's optimized hyperparameters.
Args:
estimator_class: Scikit-learn compatible estimator class
task (str): Task type - 'classification' or 'regression'
**kwargs: Additional parameters
Returns:
Enhanced estimator class with optimized hyperparameters
"""Intelligent hyperparameter suggestion based on dataset characteristics and meta-learning.
def suggest_hyperparams(estimator_name, X, y, task="classification"):
"""
Suggest hyperparameters for an estimator based on dataset characteristics.
Args:
estimator_name (str): Name of the estimator
X: Training features
y: Training target
task (str): Task type - 'classification' or 'regression'
Returns:
dict: Suggested hyperparameters
"""
def suggest_config(estimator_name, X, y, task="classification", time_budget=60):
"""
Suggest configuration including hyperparameters and training settings.
Args:
estimator_name (str): Name of the estimator
X: Training features
y: Training target
task (str): Task type
time_budget (float): Available time budget in seconds
Returns:
dict: Suggested configuration
"""
def suggest_learner(X, y, task="classification"):
"""
Suggest the best learner for given dataset characteristics.
Args:
X: Training features
y: Training target
task (str): Task type - 'classification' or 'regression'
Returns:
str: Recommended learner name
"""
def preprocess_and_suggest_hyperparams(X, y, task, estimator_name, time_budget=60):
"""
Preprocess data and suggest hyperparameters.
Args:
X: Training features
y: Training target
task (str): Task type
estimator_name (str): Name of the estimator
time_budget (float): Available time budget
Returns:
tuple: (preprocessed_X, preprocessed_y, suggested_hyperparams)
"""
def meta_feature(X, y, task="classification"):
"""
Extract meta-features from dataset for hyperparameter suggestion.
Args:
X: Training features
y: Training target
task (str): Task type
Returns:
dict: Meta-features of the dataset
"""from flaml.default import LGBMRegressor, XGBClassifier
import pandas as pd
from sklearn.model_selection import train_test_split
# Load your data
X, y = load_data() # your dataset
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)
# Use enhanced LightGBM regressor with optimized hyperparameters
regressor = LGBMRegressor()
regressor.fit(X_train, y_train)
predictions = regressor.predict(X_test)
# Use enhanced XGBoost classifier
classifier = XGBClassifier()
classifier.fit(X_train, y_train)
probabilities = classifier.predict_proba(X_test)from flaml.default import suggest_hyperparams, suggest_learner
# Get hyperparameter suggestions
suggested_params = suggest_hyperparams("lgbm", X_train, y_train, task="regression")
print(f"Suggested hyperparameters: {suggested_params}")
# Get learner recommendation
best_learner = suggest_learner(X_train, y_train, task="classification")
print(f"Recommended learner: {best_learner}")Install with Tessl CLI
npx tessl i tessl/pypi-flaml