Skip to main content

Python package for software reliability analysis and modeling

Project description

pysrat

pysrat is a Python package for fitting and analysing NHPP (Non-Homogeneous Poisson Process) software reliability models. It provides a clean scikit-learn–style API (model.fit(data), params_, llf_, aic_) and high-performance EM core implementations exposed from C++ via pybind11.

Features

  • Scikit-learn–style estimators (model.fit(data), params_, llf_, aic_)
  • Fast EM updates implemented in C++ and exposed via pybind11
  • A collection of classical NHPP models and CF1 (canonical phase-type)
  • Plotting helpers for visualization (plot_mvf, plot_dmvf, plot_rate)
  • Multi-factor models (MFLogitNHPP, MFProbitNHPP, MFCloglogNHPP)
  • A Poisson regression–based framework (fit_pr_nhpp)

Installation

From source (recommended during development):

pip install pysrat

Requirements

  • Python ≥ 3.9
  • A C++20-capable compiler (required for some extension modules such as CF1)

Optional / developer tools

  • ninja (recommended build backend for faster CMake builds)
  • pytest for development and tests
  • Python headers and development toolchain for building native extensions

Quick start

import numpy as np
from pysrat.data.nhpp import NHPPData
from pysrat.nhpp.models import ExponentialNHPP
from pysrat.nhpp.plot import plot_mvf

# Create NHPP data from grouped intervals
data = NHPPData.from_intervals(time=[1, 1, 1, 1], fault=[0, 1, 0, 5])

# Fit model
model = ExponentialNHPP().fit(data)

print("Parameters:", model.params_)
print("Log-likelihood:", model.llf_)
print("AIC:", model.aic_)

# Plot mean value function
plot_mvf(data, model)

Working with data

pysrat accepts several NHPP data formats via pysrat.data.nhpp.NHPPData:

  • Interval/grouped data: NHPPData.from_intervals(time=..., fault=..., type=...)
  • Counts per interval: NHPPData.from_counts(fault=...)
  • Exact fault times: NHPPData.from_fault_times(times=..., te=... )

Available models

Common models are exported under pysrat.nhpp.models:

  • ExponentialNHPP
  • GammaNHPP
  • Pareto2NHPP
  • TruncatedNormalNHPP
  • LogNormalNHPP
  • TruncatedLogisticNHPP
  • LogLogisticNHPP
  • TruncatedExtremeValueMaxNHPP
  • LogExtremeValueMaxNHPP
  • TruncatedExtremeValueMinNHPP
  • LogExtremeValueMinNHPP
  • CanonicalPhaseTypeNHPP (CF1)

CF1 example

from pysrat.data.nhpp import NHPPData
from pysrat.nhpp.models import CanonicalPhaseTypeNHPP

data = NHPPData.from_intervals(time=[1, 2, 1.5], fault=[1, 0, 2], type=[0, 1, 0])
model = CanonicalPhaseTypeNHPP(3).fit(data)
print(model.params_)

Plotting

Use the plotting helpers from pysrat.nhpp.plot:

from pysrat.nhpp.plot import plot_mvf, plot_rate
plot_mvf(data, model)
plot_rate(data, model)

You can pass a dictionary of models to compare multiple MVFs:

models = {
    "Exp": ExponentialNHPP().fit(data),
    "Gamma": GammaNHPP().fit(data),
}
plot_mvf(data, models)

Model comparison

Compare models using aic_ or llf_:

from pysrat.nhpp.models import ExponentialNHPP, GammaNHPP
data = NHPPData.from_counts([0, 1, 0, 5])
m1 = ExponentialNHPP().fit(data)
m2 = GammaNHPP().fit(data)
best = min((m1, m2), key=lambda m: m.aic_)
print("Best model:", best.name)

PR-NHPP regression framework

fit_pr_nhpp fits module-wise NHPP models with a Poisson regression outer loop.

import numpy as np
from pysrat.data import SMetricsData
from pysrat.nhpp.regression import fit_pr_nhpp

# names must align with your model dictionary keys
sdata = SMetricsData(
    names=["mod_a", "mod_b", "mod_c"],
    metrics=np.array([[1.2, 0.3], [0.7, 1.0], [1.5, 0.4]], dtype=float),
    offset=np.log(np.array([1200.0, 900.0, 1500.0], dtype=float)),  # optional
)

fit = fit_pr_nhpp(models, sdata, reg="glm")

# You can also override offset at call-time (shape = number of modules)
fit2 = fit_pr_nhpp(models, sdata, reg="glm", offset=np.log(np.array([1.0, 2.0, 4.0])))

Examples

See the examples/ notebooks included in the repository for end-to-end workflows (basic fitting, comparison, CF1 usage and plotting):

  • examples/example1.ipynb — Exponential NHPP
  • examples/example2.ipynb — CF1 fitting and comparison
  • examples/example3.ipynb — Multi-factor models (MFLogitNHPP)
  • examples/example4.ipynb — Poisson regression–based NHPP fitting (fit_pr_nhpp)

Contributing

Contributions are welcome. Please open an issue describing the change or a PR with tests and documentation updates.

License

This project is distributed under the terms of the MIT License. See LICENSE.

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

pysrat-0.2.5.tar.gz (2.7 MB view details)

Uploaded Source

Built Distributions

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

pysrat-0.2.5-cp313-cp313-win_amd64.whl (520.9 kB view details)

Uploaded CPython 3.13Windows x86-64

pysrat-0.2.5-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (586.8 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pysrat-0.2.5-cp313-cp313-macosx_11_0_arm64.whl (479.4 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pysrat-0.2.5-cp313-cp313-macosx_10_13_x86_64.whl (540.6 kB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

pysrat-0.2.5-cp312-cp312-win_amd64.whl (520.8 kB view details)

Uploaded CPython 3.12Windows x86-64

pysrat-0.2.5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (586.4 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pysrat-0.2.5-cp312-cp312-macosx_11_0_arm64.whl (479.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pysrat-0.2.5-cp312-cp312-macosx_10_13_x86_64.whl (540.4 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

pysrat-0.2.5-cp311-cp311-win_amd64.whl (515.7 kB view details)

Uploaded CPython 3.11Windows x86-64

pysrat-0.2.5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (586.0 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pysrat-0.2.5-cp311-cp311-macosx_11_0_arm64.whl (474.8 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pysrat-0.2.5-cp311-cp311-macosx_10_9_x86_64.whl (535.1 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

pysrat-0.2.5-cp310-cp310-win_amd64.whl (514.0 kB view details)

Uploaded CPython 3.10Windows x86-64

pysrat-0.2.5-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (583.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pysrat-0.2.5-cp310-cp310-macosx_11_0_arm64.whl (471.6 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pysrat-0.2.5-cp310-cp310-macosx_10_9_x86_64.whl (530.9 kB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

pysrat-0.2.5-cp39-cp39-win_amd64.whl (520.5 kB view details)

Uploaded CPython 3.9Windows x86-64

pysrat-0.2.5-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (583.3 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pysrat-0.2.5-cp39-cp39-macosx_11_0_arm64.whl (471.9 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

pysrat-0.2.5-cp39-cp39-macosx_10_9_x86_64.whl (531.1 kB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

File details

Details for the file pysrat-0.2.5.tar.gz.

File metadata

  • Download URL: pysrat-0.2.5.tar.gz
  • Upload date:
  • Size: 2.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pysrat-0.2.5.tar.gz
Algorithm Hash digest
SHA256 59995dde0c7f473757a0f2682e30bf88dcb9903faed154f5f7aeb3d8edc60f08
MD5 b0f85b1438e69f458f41053b001bd37b
BLAKE2b-256 b69cd33812996864926423abd523c9066c1b8329c6232783736138e9b0370365

See more details on using hashes here.

File details

Details for the file pysrat-0.2.5-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: pysrat-0.2.5-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 520.9 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pysrat-0.2.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 af9cf19ce4336eb11f03f7c33fe7eb7653d647b6c59ae101d9d54be891a3ec7d
MD5 e1118ec19541e7b3c58f3af5a92c22a0
BLAKE2b-256 088bc39def70b753491ff42f588f10eaf14ec08345702cbdf0781d4b4a0ac6b3

See more details on using hashes here.

File details

Details for the file pysrat-0.2.5-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pysrat-0.2.5-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 14eefd0e5d981b1ff49a57446577c49ac5ef73f51fd5a327f5c5fa71889e6fce
MD5 a590d032664353dd2401760cd97e7802
BLAKE2b-256 7e83a342196de55cf903a29b329e767d0b8d62c8d5affdf82df0958880fbb40e

See more details on using hashes here.

File details

Details for the file pysrat-0.2.5-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pysrat-0.2.5-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 44be7c672e00e0aec50c9b944355a3004437e93c42f0d17ebbf3c46d2af83aec
MD5 e5a892ea593f9790e9e9814f6de38b00
BLAKE2b-256 2a7c6754f99e4f6581eb1dc73e247cbddc453234b79e3b140d2b1678a17bf9d1

See more details on using hashes here.

File details

Details for the file pysrat-0.2.5-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for pysrat-0.2.5-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 0d50adcae3c9a78b9c0e5389220b4b604f776015318cec625b47fea4ea440045
MD5 ee12c24d86bbdad433c82aaf938bc989
BLAKE2b-256 9a043845c46132c1761b42a7900f75f43679903897c19a9725700aca24cdea63

See more details on using hashes here.

File details

Details for the file pysrat-0.2.5-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: pysrat-0.2.5-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 520.8 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pysrat-0.2.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 929e9ed337f2b987e85f8fefe05c73b45b4cb97df2b04a3471e4da07eb203374
MD5 82f1f00e590b2b939eee24ef8dec2d41
BLAKE2b-256 f6d2a5fbb7d8ccc8218b6e4c47f22f564847cbc64693f6c6cea58a8aa5291669

See more details on using hashes here.

File details

Details for the file pysrat-0.2.5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pysrat-0.2.5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fc07777efe0c6893085be31d46756bbd25dd6073b119f34090aa3e6e1cead4c5
MD5 9404d1bac5959a6e77f75994c7360acb
BLAKE2b-256 1223a8c8b5362d998fcb8fa8cb0a63f1557053be570331a108378b680e69d9d7

See more details on using hashes here.

File details

Details for the file pysrat-0.2.5-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pysrat-0.2.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e1c8b8d5f00de0ce646176b9a465bdfc3cdbc6bda1c53515111ccea773a43bad
MD5 63e8e38b535fb083caaae409875366ed
BLAKE2b-256 c86cd15b537ea5d3388106a14a35c6946933ecde6bc4a1349fdf5c18a94da0ae

See more details on using hashes here.

File details

Details for the file pysrat-0.2.5-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for pysrat-0.2.5-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 77783d610ece9f4e0cde0fc55b65d5e409b4d072cc494695b6f4034f0d9bf97d
MD5 919c6d450cc74420239bb0276dcc9256
BLAKE2b-256 cb80cd2bbed3beda6420a615cb2a015f06229dcd7f376a915507579809b36dd2

See more details on using hashes here.

File details

Details for the file pysrat-0.2.5-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pysrat-0.2.5-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 515.7 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pysrat-0.2.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 31d8fadd0241c7db90e86a76af6567534eb4fa165ccfec35f1b926417e149383
MD5 164544d1564a01e8dea13b048ee55ec0
BLAKE2b-256 ef2a4a8ce253ad84f9c01ec78741c8b18b8b3ac6f1582043f6dc1b74e1105616

See more details on using hashes here.

File details

Details for the file pysrat-0.2.5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pysrat-0.2.5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ee8412d5fc0b54c1feca6d37824e0fa0a22f3ef49d19982e179d7eb154571496
MD5 2c4fa33e1e20540410e8985d9f2c6232
BLAKE2b-256 a5665fc78a4c58ef474967b4b7b5ae01c0b1e2235de2283470d72497f64888ce

See more details on using hashes here.

File details

Details for the file pysrat-0.2.5-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pysrat-0.2.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7a2ae9a82ebb0dfccff176eed692df3e4b1aac3f2c1f6a4cc77f834af2ae05f8
MD5 f66ae619f7623e383a631ddf1e586c1b
BLAKE2b-256 a67d495ad672e709fd9b35f4d2bf877535912be6155af487359162156ca50d94

See more details on using hashes here.

File details

Details for the file pysrat-0.2.5-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pysrat-0.2.5-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 31e699c89058f0fdb0b4f4b922b618d7f8c523a25437b0cbad6ed7de63feab09
MD5 c31dad2e78311096330c651d921c0175
BLAKE2b-256 e7c88e1f4de6c347ee91e62ed2b52f70483064caddbcf3aeee87360a0ee3876f

See more details on using hashes here.

File details

Details for the file pysrat-0.2.5-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: pysrat-0.2.5-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 514.0 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pysrat-0.2.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 4d041212ccdb6a61f21c03fca86d136e5d2cda109840d58828a25873b919a10d
MD5 45cb9406e12a8c7dabb14433b78f3937
BLAKE2b-256 4b8505347e9df37e235781e7a1448e1fa91721687c420bb92776ebb17d1c688e

See more details on using hashes here.

File details

Details for the file pysrat-0.2.5-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pysrat-0.2.5-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5a8b0cb5a994e6bc770f1a1741f20dc08d131b297f230fe7ee192dbadd5ab654
MD5 da0bf1241bf0775d9b6e35ef3dbb5150
BLAKE2b-256 77a76411d3bc5b4e873523c9d732a7c5d57576f47c68060cb321d97c35025a2f

See more details on using hashes here.

File details

Details for the file pysrat-0.2.5-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pysrat-0.2.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 20e0ae64a8652974545a78ff825d2a2abca6eda0b2077e0e437b08348c3753ee
MD5 c604c62073ecdbfdd178bde1e91de7b9
BLAKE2b-256 50f1702ac843efdbb2d37a1b590633ef2581749e61b110637612cdb84915e26a

See more details on using hashes here.

File details

Details for the file pysrat-0.2.5-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pysrat-0.2.5-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 9bd95e2caf5e83f964338d25ed6bf8895d05392ce0cb14bb284ec2863b6fdc97
MD5 ddd8c1759356e0adb3f8a51c771b1298
BLAKE2b-256 723780ce08d9d5ab78fb709a855198353b348a090250ae3abc006e1aba1ec9b6

See more details on using hashes here.

File details

Details for the file pysrat-0.2.5-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: pysrat-0.2.5-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 520.5 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pysrat-0.2.5-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 627ce07072560ea38a8a25ddd3a5a8df1747f3b57a7ca8b2819f2f25310a33eb
MD5 b47090f823e6d751c77f583b3c4b3477
BLAKE2b-256 607b0077ce02ce1c2a84c54ab23b2b575d6f01f515857d855a5f08ae27ef6ec7

See more details on using hashes here.

File details

Details for the file pysrat-0.2.5-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pysrat-0.2.5-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1d28fc7cefeedb72e1e65bc8cbe5ddb8863c764422ad27072c46bf112e7f25f9
MD5 9cff2f69977ab6574ef93253ed5bf531
BLAKE2b-256 fec6f25a5459eb05a567f3d2bc2ebaa80a712749736be27145ddf74d7db72058

See more details on using hashes here.

File details

Details for the file pysrat-0.2.5-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pysrat-0.2.5-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 88bd897426b4a04e2531034baf03853e3845aababaf4c507b437f4f3141ee74c
MD5 618306e29a51b75e34a98155d27277c1
BLAKE2b-256 bca0e3adb0ecb7304f624a41105c5853c82c50eecbaa30917557f2941835de7c

See more details on using hashes here.

File details

Details for the file pysrat-0.2.5-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pysrat-0.2.5-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 2c4f55ced879657307d75c09078f2f83380f57e58c02f2effafc25ad72fafb78
MD5 b5fc70dca3e0f6468d7efaaba8cd5891
BLAKE2b-256 a390d05de56c9a017f6a240c5132829f7f1969cd58258363d8cb7fdcd76b3153

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