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

Uploaded CPython 3.13Windows x86-64

pysrat-0.2.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (544.0 kB view details)

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

pysrat-0.2.4-cp313-cp313-macosx_11_0_arm64.whl (447.5 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pysrat-0.2.4-cp313-cp313-macosx_10_13_x86_64.whl (491.5 kB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

pysrat-0.2.4-cp312-cp312-win_amd64.whl (475.1 kB view details)

Uploaded CPython 3.12Windows x86-64

pysrat-0.2.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (543.6 kB view details)

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

pysrat-0.2.4-cp312-cp312-macosx_11_0_arm64.whl (447.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pysrat-0.2.4-cp312-cp312-macosx_10_13_x86_64.whl (491.3 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

pysrat-0.2.4-cp311-cp311-win_amd64.whl (471.5 kB view details)

Uploaded CPython 3.11Windows x86-64

pysrat-0.2.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (542.8 kB view details)

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

pysrat-0.2.4-cp311-cp311-macosx_11_0_arm64.whl (443.2 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pysrat-0.2.4-cp311-cp311-macosx_10_9_x86_64.whl (486.6 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

pysrat-0.2.4-cp310-cp310-win_amd64.whl (469.7 kB view details)

Uploaded CPython 3.10Windows x86-64

pysrat-0.2.4-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (540.9 kB view details)

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

pysrat-0.2.4-cp310-cp310-macosx_11_0_arm64.whl (439.9 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pysrat-0.2.4-cp310-cp310-macosx_10_9_x86_64.whl (482.4 kB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

pysrat-0.2.4-cp39-cp39-win_amd64.whl (474.6 kB view details)

Uploaded CPython 3.9Windows x86-64

pysrat-0.2.4-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (541.1 kB view details)

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

pysrat-0.2.4-cp39-cp39-macosx_11_0_arm64.whl (440.2 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

pysrat-0.2.4-cp39-cp39-macosx_10_9_x86_64.whl (482.7 kB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: pysrat-0.2.4.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.4.tar.gz
Algorithm Hash digest
SHA256 738ea8dc0aa94203501b9c63cbb59e1d05bfc97ec6de72c2bd3ecdab16f10141
MD5 59c2718c8b32a98bb439fe6e454c5bc0
BLAKE2b-256 6077a38835d3b8952238977ac43f5a3be3d5c50832a5555f59020a613f640f30

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pysrat-0.2.4-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 475.2 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.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 3434621b22a8b6bb226768b345e85447081a6e857c06b217ddae259f3416dc47
MD5 665848f18db0ca0a88d002c11322ff04
BLAKE2b-256 944388eed2365322e4f3b24b38d88decb87cafa7f32985c4a7d1aedc86de42a7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4af2911578ec7f6ef79e2d05f8dcc6be3ad292d225bf79b4bbaac0ab01cd37b8
MD5 797cf8d22b112ab85b20cfa073808343
BLAKE2b-256 57661e2dfb8131be55ca72acad223c1ac8f2fd4135642ac01a8e26b2380b1452

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8ffe5f26f585480c452ad8d521d52d6ab8bce9398353ef1335a136dd940e5967
MD5 ed6c3ff59335d3f8c66a64e0f63c5806
BLAKE2b-256 ab76d2df0b5b764c333d1d2aa3027403f7b0743918f39247d58a60bd6b9102f3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.4-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 3931636d4ec9826ee36467ab5eecb0e3599a3a479fe89399bf9a40238abd7846
MD5 45c411e886e1553e0fba349c758c9aa6
BLAKE2b-256 17334b1c23c103d9965d29ee291c2bc3aade98f62da17e31882664d732048eb8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pysrat-0.2.4-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 475.1 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.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 319eb50c5a82289d962ec70f38cb3614f5b77ad91dfcd3c2658540ece88e7985
MD5 70d23f8eced2005076310b4c5d93aa14
BLAKE2b-256 497b754d881dc2e18a2a60130c382859917cc767b84a4963ac88fa76701ecc9f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6f1c2df3e7b2818a332c5196136d1ece9866785b954184fa4043e77fec645c82
MD5 9fb7b8a505b1ba7bd6056cd424a48096
BLAKE2b-256 f10fc7f734dc59f7c71a99f82f3506b438a76cc334de0373fe6986c720cdc61c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9232f7b343bf7db715032f12a48d8da8369b1b2086c9be753e9c1a7819d0f9e1
MD5 a043553b07a730b03d23db95533ce6a2
BLAKE2b-256 8c9114ccf3e360b8d56f900a59bfa688c3bdd3cc506c2a94bd5428dedceca8b3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.4-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 3f0604aca82df9aee5e169aeff0ba749acc385ce985c7191f785395e87eb0659
MD5 3dc6dcae06487a851dc96a7514195e26
BLAKE2b-256 8227395e5cbdd9dfd707d5ad1475028441f365465823b21cbe9a2139c401994d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pysrat-0.2.4-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 471.5 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.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 8f0c458f9e4606af1f68dd60d3243a08cdc09d0545ba9bc09f8c309ed5309ea9
MD5 1d20c47fffe24b6478885daec341f1c9
BLAKE2b-256 574c91028d6eb4214342c3efb2a55de10dfd9e0005fb3a85d28d402ca381cfd2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 15074b895a5343859a53698393b9a06944644f3f5a336865b25ab0acf689e60c
MD5 3f0b130ba98369b970c1416ee878d17d
BLAKE2b-256 d831cff63b496c89f1535bcbcc49c52af5992d7d88c50cebc4ee3ff443074a50

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 55fd2f7e48d89f14403a16b2a27be3286e549d4344c2a20b48a4c61042f2b41f
MD5 be272d7d3a47696a42f5bf4dee26692e
BLAKE2b-256 4ec7e8c28e30be749395ebaf86600c6a9708e3172edca362eec3cd8e694b5664

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.4-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 2edd16d175ab20ee0755c24b44ec6863421f7b2f43e2342bf91f85b37ac38d73
MD5 c1f2c2a30a2b161404a9b2b386cc35c3
BLAKE2b-256 c5ee9827852651bb55371cade4297be871cb887439dbd12455563b5265ce8a4d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pysrat-0.2.4-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 469.7 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.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 454f6e7019d52fa015f916cf3aaa95784905e5fc6b0b349c0f7b164e587329f3
MD5 db2c60949cd46a114626238765d19e33
BLAKE2b-256 b4ea2377de4cfdeefe2d6e364081392010b952b4480a88c16982dcd515ba18db

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.4-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 80d1f53d53c9670da32e6806de6ab68b44012b6a0059c43f39c36a18a2228e82
MD5 88e0721c7fcf8829d7cf259fcf2be24a
BLAKE2b-256 f8553be95f07803de19a9a127eedbeeedbeec8227623c496262d3e9d05ab5afd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7dbf613aa0f70bc0f7938a942a2729c40b2be48d3bfed05e6fc1b2f06efb015a
MD5 ffae2a6ae367d0ff22ed90095f5881b0
BLAKE2b-256 194df651b803ebb85e8a79499b40d2fcec320cd6cf42720cc7da503ca024a5b9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.4-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 542af1d8483a81a71dfb100d291879dd59439293f14f0b1c58998222230773f0
MD5 90d3a38adcd2f1622c7a2e8107c17930
BLAKE2b-256 546606399207b10a1ba2b5758aea1aff2f6b37b506cee355dbaf925bcd04d645

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pysrat-0.2.4-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 474.6 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.4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 f82ce746998eba5083434f9039b4fc316b8dffeddfe9d62ab0858c562d960331
MD5 631510f5bead95ba22f2886c4435977b
BLAKE2b-256 1982d122926fbef43e954c23b0fb8f46ba156fcb8e396e31fd39dd0dfe8a9c2f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.4-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a40623b1bf885aebc529b70e84ffcb2f8839fa868df8576c94d09d7a06af7161
MD5 d19e92d46ae3274b600f08d5098af9ae
BLAKE2b-256 e439758e34cf0e11adb1bb7bcf634d0ea389fa5855123a0ca5743dfba19d833e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.4-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 84fd483c5bee9a348f8d1c4403ef192a4430465e4733eef7bbe1650423e02f56
MD5 da8ea7ecdd33045e71bf9b49a5aa65a3
BLAKE2b-256 5085f52847338c3aa658b32d28ce84136e734e0f90f2e9706edf12d22b2a9865

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.4-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 968e17749d5ae4ee28b6283e649bdfc58c5eecfcac0aa4efeaff908cfe9dc3af
MD5 a018928444360e0dc55dc8bb13ca016d
BLAKE2b-256 37ea7f0e0d5df548ef272d1254fba13caa7b9c781a9f50cf808339faf63f7012

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