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
Release history Release notifications | RSS feed
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.2.0.tar.gz
(19.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gbmframework-0.2.0.tar.gz.
File metadata
- Download URL: gbmframework-0.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b10f9c6c3999547ab9c94667dcab662f6f7b3f9ec51a74518c6662c55556eebc
|
|
| MD5 |
128a24dd11320dfb041e5f47fbc119c2
|
|
| BLAKE2b-256 |
9d65972c295e2ec851a4b0b9c9bce0c35ab8506aaeae34523e9259d5ae5c902d
|
File details
Details for the file gbmframework-0.2.0-py3-none-any.whl.
File metadata
- Download URL: gbmframework-0.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8d9e85d00498023704cba7fe560111fdbcd99565e87b3de8535d3482a1235ad
|
|
| MD5 |
8408d78ec795934500361f5e50d508d8
|
|
| BLAKE2b-256 |
d1bb890e8a1ff38dd9a64b428ccef3ed33df7bcb22ea646557a3d4548c45cd41
|