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.3.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.3-cp313-cp313-win_amd64.whl (469.8 kB view details)

Uploaded CPython 3.13Windows x86-64

pysrat-0.2.3-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (534.9 kB view details)

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

pysrat-0.2.3-cp313-cp313-macosx_11_0_arm64.whl (441.2 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pysrat-0.2.3-cp313-cp313-macosx_10_13_x86_64.whl (487.1 kB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

pysrat-0.2.3-cp312-cp312-win_amd64.whl (469.8 kB view details)

Uploaded CPython 3.12Windows x86-64

pysrat-0.2.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (534.4 kB view details)

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

pysrat-0.2.3-cp312-cp312-macosx_11_0_arm64.whl (441.1 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pysrat-0.2.3-cp312-cp312-macosx_10_13_x86_64.whl (487.0 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

pysrat-0.2.3-cp311-cp311-win_amd64.whl (466.1 kB view details)

Uploaded CPython 3.11Windows x86-64

pysrat-0.2.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (533.0 kB view details)

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

pysrat-0.2.3-cp311-cp311-macosx_11_0_arm64.whl (436.7 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pysrat-0.2.3-cp311-cp311-macosx_10_9_x86_64.whl (481.4 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

pysrat-0.2.3-cp310-cp310-win_amd64.whl (464.3 kB view details)

Uploaded CPython 3.10Windows x86-64

pysrat-0.2.3-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (530.7 kB view details)

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

pysrat-0.2.3-cp310-cp310-macosx_11_0_arm64.whl (433.5 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pysrat-0.2.3-cp310-cp310-macosx_10_9_x86_64.whl (477.2 kB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

pysrat-0.2.3-cp39-cp39-win_amd64.whl (469.4 kB view details)

Uploaded CPython 3.9Windows x86-64

pysrat-0.2.3-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (530.7 kB view details)

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

pysrat-0.2.3-cp39-cp39-macosx_11_0_arm64.whl (433.8 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

pysrat-0.2.3-cp39-cp39-macosx_10_9_x86_64.whl (477.5 kB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: pysrat-0.2.3.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.3.tar.gz
Algorithm Hash digest
SHA256 4ea2e1a141db9419c62c97af66c18d59d5ccbcfd69102ce1327afc3cb93c7a5c
MD5 831b8b10f57aa2ca46a4508a377c8391
BLAKE2b-256 8c438d72620da7b75664c8abf58b31ed6924615cdb306e2af6d6bffc77fc214b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pysrat-0.2.3-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 469.8 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.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 eceaec064a2ba8c3b0bfb3b505a08d7751c8c057c5d41fb3943e920f43599d86
MD5 844bc7093de69658908721e5476bd80e
BLAKE2b-256 82056ac772550f84199ad92a1d7a998c0659258c5627fea0797e18f5e76329cc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.3-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5007a8d90e0f6d9bd3531af68ee99b68a59e114810aab6e978ce50db67f786b2
MD5 a2b1984030848443e0617a01b22fc7f5
BLAKE2b-256 c7924b8d283056773d1858c7c4e594feffd4300b4382144034929814fd0985c0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c4f3dbb0726585dd0095ddfc3e641ba7a87c4835f01cfbbdf8d2c101a2bd3a5c
MD5 f5e8acef303240bbc53f08bfce0ac1bf
BLAKE2b-256 607681d730d919114839d284178e9376d842a2cfe76989af3e62cd83a2d8d614

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.3-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 e83280a4d67f7453bfa5cc3292cbe03e76e8ed455e49bafe95416decb37ef0fd
MD5 e3c52b491d54ce5a26e149983d10d9a0
BLAKE2b-256 7dcb282038a762496e5e77db4bf8e15f51d1e552f8c482def2b59d8681ffe34a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pysrat-0.2.3-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 469.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.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 eaa905850c987019b4b3482231b5c114163bf4df4091b8a43499c44b01ff992a
MD5 c946f885c9fd508bbf43a7951409d757
BLAKE2b-256 cafbfa313dd7f5190a9f9b91ccac3ee45aea382239cb04d19d9ee61c3ffeeae9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 defa17b50b303a2288a574784569ef873381566fd89009e73e369be3973a19e7
MD5 a3515651e722c6f7092b4d8d9f02024c
BLAKE2b-256 71b99d01c9583fe8393eb81e695fdcf06abd66a0a8cb41ebb39cae6d5cdc1a91

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 78e260caf41756365ad9ac58e9e1c1051690dd8a719dcefd63c79dc231e5361e
MD5 b041ea23d22f127179af96e56037b79a
BLAKE2b-256 72c6a3e1336d0eee416ec4ed15e6422ba7a20f4f5d945b8bcdda3b58658b571d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.3-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 e246ca65c36e6d87519ad44625ade73f53577d2208410228e01a484598613022
MD5 74cd6ffafdac512e973732da0dbe3c04
BLAKE2b-256 9a357c07d3316ee31b354bef846fcd519fa5d4fa565d96446f494262c3c53128

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pysrat-0.2.3-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 466.1 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.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 667c5cd2080077260c1f318766a3ecfecbf8348cb7b96644f15322aaf2a53385
MD5 42c7bacedc5afaf13746cbcd2f72e027
BLAKE2b-256 53babde1b9dd25764a11b2642e6014ec55338586397554da257ae1ea19baaea4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 498d06cd4732f8ba24e9a83046b28c1167a39c07de619cbe0a7a3270b21dabd7
MD5 2553130ebb8f1a5f34463f1acf9530e4
BLAKE2b-256 f76985d5ccf5902807ad2156346a649796c0507973a74d539c22b1ef44ef8330

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 aad5fbd6dac6c58214097b48ef01e9f0cfde3424bec8fde35d0a8b402ef81dfb
MD5 14006d47c681a762d0ad481f6327ea75
BLAKE2b-256 775103ed6a81d0b943c2e2c666645c557536a2a1efff0854c2f0c48e26bee33b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.3-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 76bfebff70d783fe896701f29d7e99fe3b41ec57a98ad0cf2d024c413ab4004c
MD5 62f652b8faeb261b4e76bbd631a9e3c9
BLAKE2b-256 576a0561ea849816a8746866ddb31058f3bcec748161cf1b6f33bc1ded3b54e4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pysrat-0.2.3-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 464.3 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.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 5593962dc787c46022ebf3f211ff0dc17a2f2ad10141565d6f958bd28e18e09c
MD5 400e09cf544384ceb171a3325a00d4b0
BLAKE2b-256 b4859c57f39d8e818f06b194ca943ff1bfad8e9776efe5c09f0bead4466c214d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.3-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a97b6ca61d3b5836abfe2b04f4a1440e1edb7a45aee460ad6e195fd3c5fc80fd
MD5 45eafb91f7638ce3a088dd8dc2b7e98e
BLAKE2b-256 80bdf3588bb9a60482af4f94078ac74af94f3576948ad74a0509bf04bd253d9b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7af8b077ae3fcdc7327e8bae045f71be4c35c616fe72952ab7244fba9d046a0a
MD5 7e506fc94472c49a9425076b64295d7b
BLAKE2b-256 dafcc3be727e9669caf25a35fd92993c76bbee54da057a426afb011b8f0bbf1c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.3-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 cff42847b5b8c887121c9aaf8dcfee60065e4c877a8c39fd2fe5d67eea8f2186
MD5 b6fe09682f613c1b3e88b9efdcfffc68
BLAKE2b-256 71e44262ba1a96ef5d6bff76cd8ca6de6c578dc1c6387b81368dfc711f5d7ba7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pysrat-0.2.3-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 469.4 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.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 e1ae974275af196a0a46a03324f9b76a1be01c2d21161bd0e2eb3482b2d3d126
MD5 dae9aaa65ba9e041858d09bb3ce8c142
BLAKE2b-256 22fc434739ffeff8cffc89ee025baf25daa9db18b3f3d0a220e00d8c5828851a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.3-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3d65cc322e9fa4332c566f56947e95c38efac0bb5daf99abf19ca733e0ca8584
MD5 4b574c3fa8344b963853ea72bfbe8b61
BLAKE2b-256 bcee3239a8aa51c3f921d045407d19f29cca786a162b9eb112f8fa446e0dc506

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.3-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d0f1fdca7238266e4aba0b4766a03b754bb99931b098c26235f9ffa9219e97c2
MD5 2fb43da76fc5b9c96e9aadce3b7a263c
BLAKE2b-256 bd0d52b4527491cf968352ec52835bc2e943bdbe502607fbb1fc8d371a9f12a9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.3-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 7670a8b72d887b4394e2e557f3878e70bff7e3bddb1a0f92f4657adfd66d2576
MD5 942ed14030c78cf729fe4a61612e79c9
BLAKE2b-256 5663e836782830d994d7075147f75e25e1ca9f82d284a44913e159e49cbb5447

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