Skip to main content

Path Boost

Path Boost is a Python library for interpretable machine learning on graph-structured data. It implements the PathBoost and SequentialPathBoost algorithms, which iteratively construct features based on paths in graphs and use boosting to build predictive models. The library is designed for tasks where input data consists of collections of graphs (e.g., molecules, social networks) and supports variable importance analysis for interpretability.

Features

  • PathBoost: Ensemble learning over graph paths, partitioned by anchor nodes.
  • SequentialPathBoost: Boosting with path-based features, iteratively expanding the feature space.
  • Variable Importance: Quantifies the importance of paths/features in prediction.
  • Parallel Training: Supports multi-core training for large datasets.
  • Evaluation and Visualization: Built-in tools for error tracking and variable importance plotting.

Installation

Install from PyPI:

pip install path_boost

Usage Example

Below is a minimal example using the PathBoost model:

import numpy as np
import networkx as nx
from sklearn.model_selection import train_test_split
from path_boost import PathBoost
from path_boost.utils.datasets_for_examples.generate_example_dataset import generate_synthetic_graph_dataset




if __name__ == "__main__":

    # Generate synthetic dataset
    nx_graphs, y, true_paths, true_weights = generate_synthetic_graph_dataset()


    list_anchor_nodes_labels = [0, 1, 2]

    parameters_variable_importance: dict = {
        'criterion': 'absolute',
        'error_used': 'mse',
        'use_correlation': False,
        'normalize': True,
    }

    X_train, X_test, y_train, y_test = train_test_split(nx_graphs, y, test_size=0.25, random_state=42)

    eval_set = [(X_test, y_test)]

    path_boost = PathBoost(
        n_iter=50, # Reduced for quicker example run
        max_path_length=5,
        learning_rate=0.1,
        n_of_cores=1, # Set to >1 for parallel processing if desired
        verbose=True,
        parameters_variable_importance=parameters_variable_importance
    )

    # Fit the model
    # anchor_nodes_label_name must correspond to the feature storing node types ('feature_0')
    path_boost.fit(
        X=X_train,
        y=y_train,
        eval_set=eval_set,
        list_anchor_nodes_labels=list_anchor_nodes_labels,
        anchor_nodes_label_name="feature_0" # Node types are in 'feature_0'
    )
    
    print(f"Generated {len(nx_graphs)} graphs.")
    print(f"Example y values: {y[:5]}")
    print(f"True paths definitions: {true_paths}")
    print(f"True path weights: {true_weights}")

    path_boost.plot_training_and_eval_errors(skip_first_n_iterations=0, plot_eval_sets_error=True)
    if path_boost.parameters_variable_importance is not None and hasattr(path_boost, 'variable_importance_'):
        path_boost.plot_variable_importance(top_n_features=10)
    else:
        print("Variable importance not computed or available.")

    print("Example run finished.")

API Overview

PathBoost

  • fit(X, y, anchor_nodes_label_name, list_anchor_nodes_labels, eval_set=None)
  • predict(X)
  • predict_step_by_step(X)
  • evaluate(X, y)
  • plot_training_and_eval_errors(skip_first_n_iterations=True)
  • plot_variable_importance()
  • Attributes:
    • train_mse_: Training error (MSE) at each iteration
    • mse_eval_set_: Evaluation set error (MSE) at each iteration (if eval_set is provided)
    • variable_importance_: Variable/path importance scores (if enabled)
    • is_fitted_: Whether the model is fitted
    • models_list_: List of fitted SequentialPathBoost models (one per anchor node)
    • (Each SequentialPathBoost in models_list_ exposes the attributes below)

SequentialPathBoost

  • fit(X, y, list_anchor_nodes_labels, name_of_label_attribute, eval_set=None)
  • predict(X)
  • predict_step_by_step(X)
  • evaluate(X, y)
  • plot_training_and_eval_errors(skip_first_n_iterations=True)
  • plot_variable_importance()
  • Attributes:
    • train_mse_: Training error (MSE) at each iteration
    • train_mae_: Training MAE at each iteration
    • eval_sets_mse_: Evaluation set error (MSE) at each iteration (if eval_set is provided)
    • eval_sets_mae_: Evaluation set MAE at each iteration (if eval_set is provided)
    • variable_importance_: Variable/path importance scores (if enabled)
    • paths_selected_by_epb_: Set of selected paths during boosting
    • columns_names_: Names of EBM columns/features used
    • is_fitted_: Whether the model is fitted

Requirements

  • Python 3.10+
  • numpy
  • pandas
  • scikit-learn
  • networkx
  • matplotlib

(See requirements.txt for the full list.)

Citation

If you use this library in your research, please cite the corresponding paper (add citation here).

License

BSD 3-Clause License

Metadata

Release files for path-boost 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for path-boost 2.1.0
File Size Uploaded Provenance
path_boost-2.1.0.tar.gz 177.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for path-boost 2.1.0
File Interpreter ABI Platform
path_boost-2.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 239.4 kB

Release files / path_boost-2.1.0.tar.gz

Download URL path_boost-2.1.0.tar.gz
Size 177.7 kB
Tags Source
SHA-256 checksum
How to use checksums
65acc2dac849cef16c327d4da307efe0517dbcba1b6e8a4623aa7285ad09dc2a
BLAKE2b-256 checksum
How to use checksums
86e209c8bda4c70d4b3169271b6e74b92083948dde49da77c06e41a1ae468006
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.6

Release files / path_boost-2.1.0-py3-none-any.whl

Download URL path_boost-2.1.0-py3-none-any.whl
Size 61.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9780ead44306cf4753091051b169d55419f70c1864fc42804758d182d66e4f16
BLAKE2b-256 checksum
How to use checksums
8b00f479524af1e336106b5dffbfb31f0bc7aa3bdf4f1757e13e9a0364f9f516
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.6

Security for path-boost 2.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page