Skip to main content

DOI

NSPPK graph logo

NSPPK

Neighbourhood Subgraph Pairwise Pathway Kernel (NSPPK) turns labeled NetworkX graphs into fixed-width feature vectors for graph-level prediction, node-level analysis, and scikit-learn workflows.

Read the documentation · Getting started · API reference

Install

NSPPK requires Python 3.10 or newer. Install the latest release from PyPI:

python -m pip install nsppk

Your first graph features

Pass NSPPK a list of NetworkX Graph, DiGraph, MultiGraph, or MultiDiGraph objects. Each graph becomes one sample. For directed inputs, distances and neighborhoods use the undirected projection while hashes retain arc direction. Parallel edges and self-loops contribute individually. Node and edge labels can be any hashable values; a missing label is treated as 0.

import networkx as nx
from nsppk import NSPPK


def make_graph(node_labels):
    graph = nx.Graph()
    graph.add_nodes_from(
        (node_id, {"label": label})
        for node_id, label in enumerate(node_labels)
    )
    graph.add_edges_from(
        (u, v, {"label": "bond"})
        for u, v in [(0, 1), (1, 2)]
    )
    return graph


graphs = [
    make_graph(["C", "O", "C"]),
    make_graph(["C", "N", "C"]),
    make_graph(["O", "C", "O"]),
]

encoder = NSPPK(nbits=8, dense=False, parallel=False)
X = encoder.fit_transform(graphs)
print(X.shape)  # (3, 256): one row per graph

With nbits=8 and no continuous node attributes, this example produces 256 structural features per graph. dense=False returns a SciPy sparse matrix; the default dense=True returns a NumPy array. For the default discrete-label setup, you can also call encoder.transform(graphs) directly.

Choose what you need

  • Graph features: NSPPK returns one feature row per graph, as shown above.
  • Node features: NodeNSPPK returns one node-by-feature matrix per graph. Rows follow each graph’s graph.nodes() iteration order.
  • Edge features: EdgeNSPPK returns one edge-by-feature matrix per graph. Rows follow NetworkX edge iteration order; multigraph rows retain each keyed edge, and directed rows include the ordered arc pattern.
  • Prediction: NSPPKClassifier and NSPPKRegressor wrap graph vectorization with a scikit-learn estimator, with partial_fit and source streaming when the selected estimator supports incremental updates.
  • Tuning: NSPPKClassifier.tune() and NSPPKRegressor.tune() search encoder settings with optional Bayesian optimization support. Install it with python -m pip install 'nsppk[tuning]'; see the tuning guide.

See the getting-started guide for runnable examples of node features and prediction, and the API reference for parameters and output details.

Read graphs from files

The core install supports NetworkX graphs. Optional input formats require extra dependencies:

  • SMILES and SDF: python -m pip install rdkit
  • PyTorch Geometric files: install PyTorch for your platform, then python -m pip install torch_geometric. See the PyTorch installation guide and PyG installation guide for compatible platform and accelerator commands.

See graph loading and streaming for supported formats and examples. These optional packages are not installed with NSPPK.

Documentation and examples

Runnable notebooks are in notebooks/: Demo.ipynb covers graph features, Graph Types Vectorization Demo.ipynb compares multigraph, directed, and undirected inputs, Importance Demo.ipynb covers explanations, and Streaming Benchmark.ipynb covers loading and streaming. Other notebooks benchmark molecular graphs and supervised learning; some require optional packages. See IO.md for reader requirements.

Develop from a checkout

From the repository root, install NSPPK in editable mode:

python -m pip install -e ".[docs]"

Citation

The repository’s Zenodo DOI is 10.5281/zenodo.14261713.

Metadata

Release files for nsppk 3.5.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 nsppk 3.5.0
File Size Uploaded Provenance Actions
nsppk-3.5.0.tar.gz 62.0 kB With provenance Details for nsppk-3.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nsppk 3.5.0
File Interpreter ABI Platform Actions
nsppk-3.5.0-py3-none-any.whl Python 3 none any Details for nsppk-3.5.0-py3-none-any.whl

Total release size: 111.3 kB

Release files / nsppk-3.5.0.tar.gz

Download URL nsppk-3.5.0.tar.gz
Size 62.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f82634169039b4787e5ee14a691cfcd9c641b0ab00b995cbf235648da28358be
BLAKE2b-256 checksum
How to use checksums
6c103deadff70422db6f6d0b122d174d0e3fb4955a27511317f4e2ff2b33e736
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / nsppk-3.5.0-py3-none-any.whl

Download URL nsppk-3.5.0-py3-none-any.whl
Size 49.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bfed354f0d42099acf4257124b7c7fa705430c4fd1a776d21ef9d479cfd7f9a0
BLAKE2b-256 checksum
How to use checksums
7bc9be79cc5285ba6ef33a91964e7c98f595aa82c03b49e5c517758aa33ae34b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Security for nsppk 3.5.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for nsppk-3.5.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

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.

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