lazypredict

repository·dev·Indexed 25 days ago

https://github.com/shankarpandala/lazypredict

A library designed to quickly build and compare multiple basic machine learning models without manual parameter tuning. It supports classification via LazyClassifier, regression via LazyRegressor, and time series forecasting via LazyForecaster. The library includes features for categorical encoding, GPU acceleration for supported models (such as XGBoost, LightGBM, and CatBoost), MLflow integration for tracking metrics, and support for Intel Extension for Scikit-learn.

Tokens
27K
Snippets
64
Records
166
Agent score
84%

What's inside lazypredict

  1. Overview of Lazy Predict Task Classes

    dev

    Lazy Predict provides specialized classes for different machine learning tasks:

    TaskClassModels
    ClassificationLazyClassifier40+ scikit-learn classifiers + XGBoost, LightGBM, CatBoost, cuML
    RegressionLazyRegressor40+ scikit-learn regressors + XGBoost, LightGBM, CatBoost, cuML
    Time SeriesLazyForecaster20+ statistical, ML, deep learning, and foundation models
    DistributedLazySparkClassifier / LazySparkRegressorPySpark MLlib models
  2. Overview of LazyPredict

    dev
    LazyPredict is a Python library designed for rapid, zero-configuration benchmarking of machine learning and time series forecasting models. It allows users to automatically fit and evaluate over 40 classification and regression models, as well as 26+ time series forecasting models, returning a ranked comparison table of performance metrics. It is intended for the exploratory analysis and baseline establishment phases of the machine learning workflow, helping to identify promising model families before committing to intensive hyperparameter tuning.
  3. Planned API improvements in v0.4.0

    dev

    Future versions (v0.4.0+) are planned to introduce the following features:

    • Simplified Fit API: Support for fit(X, y) without requiring test data.
    • Model Serialization: Support for saving and loading trained models.
    • Advanced Resource Controls: New parameters for max_models, n_jobs (to avoid hardcoded -1), and memory_limit to better manage system resources during training.
  4. Compute Feature Importance (Explainability)

    dev

    Install explainability extras to use SHAP or InterpretML:

    • pip install lazypredict[explain] (for SHAP)
    • pip install lazypredict[interpret] (for InterpretML/EBM)

    Permutation Importance

    Use explain_permutation to compute importance for all models in a dictionary.

    SHAP Values

    Use explain_shap for a single model from your model dictionary.

    from lazypredict.explainability import explain_permutation, explain_shap
    
    # Permutation Importance
    importance_df = explain_permutation(
        models=model_dict,
        X_test=X_test,
        y_test=y_test,
        n_repeats=10,
        random_state=42,
    )
    
    # SHAP Values
    shap_df = explain_shap(
        model=model_dict["RandomForestRegressor"],
        X_test=X_test,
        feature_names=feature_names,
    )
  5. Use Local Foundation Model Weights for Time Series

    dev

    When using LazyForecaster, you can avoid downloading weights from Hugging Face by providing a local path to the model weights via the foundation_model_path parameter. This is useful for air-gapped or offline environments.

    from lazypredict.TimeSeriesForecasting import LazyForecaster
    
    # Use local weights
    fcst = LazyForecaster(
        verbose=0,
        ignore_warnings=True,
        foundation_model_path="/path/to/timesfm-2.5-200m-pytorch",
    )
    scores, predictions = fcst.fit(y_train, y_test)
  6. Configure LazyPredict logging

    dev

    Control the output of the lazypredict logger using the standard Python logging module.

    import logging
    
    # Show info-level messages from all models
    logging.getLogger("lazypredict").setLevel(logging.INFO)
    
    # Suppress everything
    logging.getLogger("lazypredict").setLevel(logging.ERROR)
    
    # Log to file
    handler = logging.FileHandler("lazypredict.log")
    logging.getLogger("lazypredict").addHandler(handler)
  7. Configure Branch Protection Rules

    dev

    To ensure code quality, apply the following branch protection rules in GitHub Settings:

    For master branch:

    • Require pull request reviews (minimum 1 reviewer).
    • Require status checks to pass: lint, test-fast, and test-full.
    • Require branches to be up to date.
    • Do not allow bypassing.

    For dev branch:

    • Require status checks to pass: lint and test-fast.
    • Allow bypassing for maintainers.
  8. Configure Categorical Encoding Strategies

    dev

    Lazy Predict supports several encoding strategies via the categorical_encoder parameter.

    • 'onehot': Default strategy.
    • 'ordinal': Useful for ordered features or reducing feature dimensionality.
    • 'target': Requires the category-encoders package.
    • 'binary': Efficient for high-cardinality features; requires category-encoders package.

    To use target or binary encoding, install the dependency:

    pip install category-encoders