Skip to main content

No project description provided

Project description

DeepBridge

Documentation Status CI PyPI version

DeepBridge is a comprehensive Python library for advanced machine learning model validation, distillation, and performance analysis. It provides powerful tools to manage experiments, validate models, create more efficient model versions, and conduct in-depth performance evaluations.

Installation

You can install DeepBridge using pip:

pip install deepbridge

Or install from source:

git clone https://github.com/DeepBridge-Validation/DeepBridge.git
cd deepbridge
pip install -e .

Key Features

Experiment Framework

  • Modular Architecture: Component-based design with specialized managers
  • Comprehensive Testing: Robustness, uncertainty, and resilience evaluation
  • Visualization System: Integrated visualization capabilities
  • Reporting Engine: Detailed HTML report generation

Model Validation

  • Multi-faceted Evaluation: Assess models across multiple dimensions
  • Alternative Model Comparison: Generate and compare different model types
  • Metrics Analysis: Comprehensive performance metrics
  • Visualization Tools: Interactive plots for model analysis

Model Distillation

  • Knowledge Distillation: Transfer knowledge from complex to simpler models
  • Surrogate Modeling: Create lightweight approximations of complex models
  • Hyperparameter Optimization: Automated tuning of student models
  • Distribution Matching: Ensure student models faithfully reproduce teacher distributions

Advanced Analytics

  • Robustness Testing: Evaluate model stability under perturbations
  • Uncertainty Quantification: Assess model confidence and calibration
  • Resilience Analysis: Test models under adverse conditions
  • Hyperparameter Importance: Identify critical hyperparameters

Architecture Overview

DeepBridge has been redesigned with a modular, component-based architecture:

┌─────────────────┐
│   Experiment    │
└───────┬─────────┘
        │
        ▼
┌─────────────────────────────────────────────────────────┐
│                                                         │
│  ┌───────────┐  ┌────────────┐  ┌──────────────┐        │
│  │DataManager│  │ModelManager│  │TestRunner    │        │
│  └───────────┘  └────────────┘  └──────────────┘        │
│                                                         │
│  ┌───────────┐  ┌─────────────┐  ┌───────────────┐      │
│  │ModelEval  │  │ReportGen    │  │VisualizationMgr│     │
│  └───────────┘  └─────────────┘  └───────────────┘      │
│                                                         │
└─────────────────────────────────────────────────────────┘

Key Components

  • Experiment: Central coordinator managing the experiment workflow
  • DataManager: Handles data preparation and splitting
  • ModelManager: Creates and manages models and distillation
  • TestRunner: Coordinates test execution across managers
  • ModelEvaluation: Calculates metrics and evaluates models
  • ReportGenerator: Creates HTML reports with results
  • VisualizationManager: Coordinates visualization creation

Quick Start

Comprehensive Experiment

from deepbridge.core.experiment import Experiment
from deepbridge.core.db_data import DBDataset

# Create dataset
dataset = DBDataset(
    data=df,
    target_column='target',
    features=features
)

# Initialize experiment with tests
experiment = Experiment(
    dataset=dataset,
    experiment_type='binary_classification',
    tests=['robustness', 'uncertainty']
)

# Train a distilled model
experiment.fit(
    student_model_type='random_forest',
    distillation_method='knowledge_distillation',
    temperature=2.0
)

# Run tests and generate visualizations
experiment.run_tests(config_name='medium')
robustness_plot = experiment.plot_robustness_comparison()

# Save comprehensive report
experiment.save_report('experiment_report.html')

Direct Model Distillation

from deepbridge.distillation.techniques.knowledge_distillation import KnowledgeDistillation

# Create distiller directly
distiller = KnowledgeDistillation(
    teacher_model=teacher_model,
    student_model_type='gbm',
    temperature=2.0,
    alpha=0.5
)

# Train the distilled model
distiller.fit(X_train, y_train)

# Make predictions
predictions = distiller.predict(X_test)

Automated Distillation

from deepbridge.auto_distiller import AutoDistiller
from deepbridge.db_data import DBDataset

# Create dataset with probabilities
dataset = DBDataset(
    data=df,
    target_column='target',
    features=features,
    prob_cols=['prob_class_0', 'prob_class_1']
)

# Run automated distillation
distiller = AutoDistiller(
    dataset=dataset,
    output_dir='results',
    test_size=0.2,
    n_trials=10
)
results = distiller.run(use_probabilities=True)

Command-Line Interface

# Create experiment
deepbridge validation create my_experiment --path ./experiments

# Train distilled model
deepbridge distill train gbm predictions.csv features.csv -s ./models

# Run robustness tests
deepbridge validation test robustness my_experiment --config medium

Documentation

Full documentation available at: DeepBridge Documentation

The documentation includes:

  • API Reference
  • Architecture Guides
  • Tutorial Notebooks
  • Examples

Requirements

  • Python 3.8+
  • Key Dependencies:
    • numpy
    • pandas
    • scikit-learn
    • xgboost
    • scipy
    • plotly
    • optuna

Contributing

We welcome contributions! Please see our contribution guidelines for details on how to submit pull requests, report issues, and contribute to the project.

  1. Fork the repository
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Open a Pull Request

Development Setup

# Clone the repository
git clone https://github.com/DeepBridge-Validation/DeepBridge.git
cd deepbridge

# Create virtual environment
python -m venv venv
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

Running Tests

pytest tests/

License

MIT License

Citation

If you use DeepBridge in your research, please cite:

@software{deepbridge2025,
  title = {DeepBridge: Advanced Model Validation and Distillation Library},
  author = {Gustavo Haase, Paulo Dourado},
  year = {2025},
  url = {https://github.com/DeepBridge-Validation/DeepBridge}
}

Contact

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

deepbridge-0.1.18.tar.gz (284.3 kB view details)

Uploaded Source

Built Distribution

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

deepbridge-0.1.18-py3-none-any.whl (375.2 kB view details)

Uploaded Python 3

File details

Details for the file deepbridge-0.1.18.tar.gz.

File metadata

  • Download URL: deepbridge-0.1.18.tar.gz
  • Upload date:
  • Size: 284.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.12.5 Linux/5.15.167.4-microsoft-standard-WSL2

File hashes

Hashes for deepbridge-0.1.18.tar.gz
Algorithm Hash digest
SHA256 2d4f640d322d591a1f860963f77baef37c0999589f5b296b7076ec31601b3625
MD5 7571226e62762a908c919e9d8e69e50c
BLAKE2b-256 954c4bacd9110073412d9a08ca9945cdc5ce0cdde15aa1693bc9101e25d29716

See more details on using hashes here.

File details

Details for the file deepbridge-0.1.18-py3-none-any.whl.

File metadata

  • Download URL: deepbridge-0.1.18-py3-none-any.whl
  • Upload date:
  • Size: 375.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.12.5 Linux/5.15.167.4-microsoft-standard-WSL2

File hashes

Hashes for deepbridge-0.1.18-py3-none-any.whl
Algorithm Hash digest
SHA256 15d9efc3acfd5f4ed7682167961e2ca97d835120093c3ac819a685d26352c922
MD5 44835dcdc22d97702793d83f05c0dcff
BLAKE2b-256 0daf9789c46217cb0e68d3190d6d0de1f0a77d21b7c821fb3a42a05c0337751b

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