Skip to main content

A unified framework for Gradient Boosting Models with SHAP analysis

Project description

GBM Framework

A unified framework for Gradient Boosting Models with SHAP analysis and system optimization.

Features

  • Support for multiple GBM implementations (XGBoost, LightGBM, CatBoost, Random Forest)
  • Automated hyperparameter optimization with hyperopt
  • Intelligent system resource detection and optimization
  • Standardized evaluation metrics and visualization
  • SHAP value integration for model explainability
  • Simple, consistent API for model training and evaluation

Installation

Basic installation:

pip install gbmframework

With specific boosting libraries:

pip install gbmframework[xgboost]    # With XGBoost
pip install gbmframework[lightgbm]   # With LightGBM
pip install gbmframework[catboost]   # With CatBoost
pip install gbmframework[hyperopt]   # With Hyperopt for optimization
pip install gbmframework[all]        # All dependencies

Quick Start

import numpy as np
import pandas as pd
from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split

# Import gbmframework components
from gbmframework.models import train_xgboost, train_lightgbm, train_catboost, train_random_forest
from gbmframework.optimizer import SystemOptimizer
from gbmframework.evaluation import evaluate_classification_model
from gbmframework.shap_utils import generate_shap_values, visualize_shap

# Load and split data
breast_cancer = load_breast_cancer()
X = pd.DataFrame(breast_cancer.data, columns=breast_cancer.feature_names)
y = breast_cancer.target
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Initialize system optimizer for efficient resource usage
optimizer = SystemOptimizer(enable_parallel=True, verbose=True)

# Train XGBoost model with hyperparameter optimization
result = train_xgboost(
    X_train, y_train, X_test, y_test,
    max_evals=10,  # Number of hyperopt trials
    optimizer=optimizer  # Pass the optimizer for resource management
)

# Access the best model and evaluate
model = result['model']
print(f"Best AUC: {result['best_score']:.4f}")

# Generate SHAP values for model interpretability
shap_result = generate_shap_values(
    model=model,
    X=X_test.iloc[:100],  # Use a subset for SHAP analysis
    algorithm_type='xgboost',
    optimizer=optimizer
)

# Visualize feature importance
visualize_shap(
    shap_result=shap_result,
    plot_type='bar',
    plot_title='XGBoost Feature Importance',
    optimizer=optimizer
)

# Clean up any resources
optimizer.cleanup()

Documentation

For more information, see the documentation or the examples directory.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gbmframework-0.1.0.tar.gz (19.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gbmframework-0.1.0-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

Details for the file gbmframework-0.1.0.tar.gz.

File metadata

  • Download URL: gbmframework-0.1.0.tar.gz
  • Upload date:
  • Size: 19.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for gbmframework-0.1.0.tar.gz
Algorithm Hash digest
SHA256 33031489fe9832b83ce7f05d4d0e817018adc6d5e0c3effc38b568da5f7367d1
MD5 3d123eaab0fbeb9ea32c2bd7e8fd2310
BLAKE2b-256 84f19279414df412047d81c402811768756d597aa9b819e771ae068ec35d4d70

See more details on using hashes here.

File details

Details for the file gbmframework-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: gbmframework-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for gbmframework-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e58f73d0dba92c19dc160451bf61869effd82c6b373defae959c17652d2c6ae9
MD5 56cd5b307e7b46097f78e71cca218353
BLAKE2b-256 dc07cb407ca974c1b3331e2b683bbba48edc8144abdb69df0bf8752b6f7f000b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page