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(intervals=[1, 1, 1, 1], counts=[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(intervals=..., counts=..., on_boundary=...)
  • Counts per interval: NHPPData.from_intervals(counts=...)
  • Time data (without counts): NHPPData.from_intervals(intervals=..., on_boundary=...) or NHPPData.from_intervals(intervals=..., 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(intervals=[1, 2, 1.5], counts=[1, 0, 2], on_boundary=[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_intervals(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.6.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.6-cp313-cp313-win_amd64.whl (548.1 kB view details)

Uploaded CPython 3.13Windows x86-64

pysrat-0.2.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (605.6 kB view details)

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

pysrat-0.2.6-cp313-cp313-macosx_11_0_arm64.whl (497.1 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pysrat-0.2.6-cp313-cp313-macosx_10_13_x86_64.whl (568.7 kB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

pysrat-0.2.6-cp312-cp312-win_amd64.whl (548.1 kB view details)

Uploaded CPython 3.12Windows x86-64

pysrat-0.2.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (605.2 kB view details)

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

pysrat-0.2.6-cp312-cp312-macosx_11_0_arm64.whl (497.0 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pysrat-0.2.6-cp312-cp312-macosx_10_13_x86_64.whl (568.5 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

pysrat-0.2.6-cp311-cp311-win_amd64.whl (543.8 kB view details)

Uploaded CPython 3.11Windows x86-64

pysrat-0.2.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (603.7 kB view details)

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

pysrat-0.2.6-cp311-cp311-macosx_11_0_arm64.whl (492.5 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pysrat-0.2.6-cp311-cp311-macosx_10_9_x86_64.whl (562.9 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

pysrat-0.2.6-cp310-cp310-win_amd64.whl (542.1 kB view details)

Uploaded CPython 3.10Windows x86-64

pysrat-0.2.6-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (601.7 kB view details)

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

pysrat-0.2.6-cp310-cp310-macosx_11_0_arm64.whl (489.2 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pysrat-0.2.6-cp310-cp310-macosx_10_9_x86_64.whl (558.6 kB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

pysrat-0.2.6-cp39-cp39-win_amd64.whl (547.5 kB view details)

Uploaded CPython 3.9Windows x86-64

pysrat-0.2.6-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (599.7 kB view details)

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

pysrat-0.2.6-cp39-cp39-macosx_11_0_arm64.whl (489.5 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

pysrat-0.2.6-cp39-cp39-macosx_10_9_x86_64.whl (558.8 kB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: pysrat-0.2.6.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.6.tar.gz
Algorithm Hash digest
SHA256 ec044b6aa462b9dc49d005b64a77f01519c1377b6a366e7e9f8a5ae4671a003c
MD5 110fb5910046e4f07b1b351fdcbe177b
BLAKE2b-256 a1559c925f021b2eccd45d75903bd2865b2d0ce25b81e89c99977f65ec43144a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pysrat-0.2.6-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 548.1 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.6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 0e1363d47abfccd602d59ac26576d1bffbf220e36a035f8cbd203f1c1dda766b
MD5 37afe45be9cdc909a84b9277067d3701
BLAKE2b-256 6597507bf88f268993a1d60bb61f6d639ca8c4b17bd174796d3be4b125ce0c6f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 edd9b0c1c400f9f45b53091b42171e1229b7bd7ea82a2e40af29790c4ee8038e
MD5 b7a54fe9d4ed75e1dd6c63218721c817
BLAKE2b-256 e9b4bcc0e792f8b4a6577fcf4320b668cc751a3ece8798e5c2d52065039389c6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.6-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ea2017295d02563f8dc35e86d148c7d5162f6d88375b41eb855f2b84ccbc221d
MD5 cc42ef55726e07538c622cbee8291f65
BLAKE2b-256 9a4e9579032564ffb05d125fbfea4173c21708264d091651eaaacfc7b2c8360f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.6-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 565adbdf3e781882a77c7b514b02d54bb38d5dfebee27961b69772a8d1530c1f
MD5 947f8ba700b240a45518164513d60970
BLAKE2b-256 00096ee60f468fdb9bdb8a28062df0a3ec17836716f6db1b2253a435bb89af90

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pysrat-0.2.6-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 548.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.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 8de50c75bf5bc33e33ba32db5e2badc71e487a88b629c346596d80c79df14472
MD5 8cc7bc06afd310b9e73c30496937ddc4
BLAKE2b-256 cfabef7f227962ded890f5bdb9a05d4a1564b299ccdd4fa0af8488777f6a7775

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 071b62f977989c0d03570d2c6218626d5253b6e4d96de92bc6f77063c7fa084b
MD5 916fafa446414898814365d2fa68030d
BLAKE2b-256 8fc67d0ba8fec296bb3bfcc22292c3961cb75a9c3f80243463dfa283feae672f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.6-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7100c63083103aaefa8be0b3315a44bfe35fb2583a54cd5db3fc4d2db0efcaef
MD5 f2598edce9cdbe2a8fae626754f36909
BLAKE2b-256 3caba848e54ab46b90b89a91feddf2b85a376587bcc856b4f662dab513094744

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.6-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 c6e4bba3fb117cd32a2dc353368b69d92eae3549d59a1bfe56e479f451722103
MD5 8cece4a40995501ebc053664855010df
BLAKE2b-256 1a6bca121aefa4878067d0cb6a7ccff529c4188b2b3a3217fe19033f2a587659

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pysrat-0.2.6-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 543.8 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.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d7782c8d937ac9f6e08d227158f053878066db9a87d793abd6bc6524d9744001
MD5 8a701ed860ef243360e0195570137754
BLAKE2b-256 54353686f004b7f30fe7bf62ea4c01007198c55dbe32b6c274ca0d79caeea624

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2a0cae1aaf6fbfbd5be6bda28470cd428618a1cb68335d4ba02944a04d34ea89
MD5 588c9f4087923b2f32f25a948e80c700
BLAKE2b-256 a5eb408081ce0fd386aad84298faf5c5559d821f02bf8ed69402e7bedc4ce534

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.6-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4c19fb0e7fea072c33dc3551d880c0a3e62a28aa38f3dd4e7ff3c063fa264f25
MD5 43504257fd840d28f3767bc9a726a361
BLAKE2b-256 21a3699b9dd17fa8d7d2515c9760a657fcbfdf8da4dbfd27e883bf7492edddf8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.6-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c53afb40096856981d3eb4f92a6e1c569ef765b8518e61aba765464cd0845c5e
MD5 9f5a98f0db0f3832921617f6ff305178
BLAKE2b-256 85da18002d59bfdaa88ead8b8c5391992f094e0969277b61ce5d2dde95f513ef

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pysrat-0.2.6-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 542.1 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.6-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 bed27e3ee1ef0db0df8304c8c4c0b0264e480064ff0bc4cd3a2e2a6d2ad36d13
MD5 146bbefabeddb4d1601add807dcd2bfc
BLAKE2b-256 29fdfe91a531c7303a960a10ba964894d61f7acaeb1aa19124b9084609bc6146

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.6-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2f31df9e86a4c9e4d8335e2f5b2784aba25bbf6ae8003fdd58435581ee3dd0f0
MD5 c2a7d5a7d9a92f4252a2c2579cf20d95
BLAKE2b-256 5dbe917ad958a3c71c501a8fe28dba466812f72efb68ddc6377851af88b2cb1a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.6-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f7c0199d62c849429ba603f5c27ec82ae75dd7530bc1b7cf0856b48fdaca3d00
MD5 839c8edfad10d37fc3a2a831661d3121
BLAKE2b-256 2dc47edaa1a6ce1f030e78dd1db6a4904db40c6a245514bcf8e81122cdc1874b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.6-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 4c3815eec4c4f684a19d8f660dc252988a87329073cb36856ca049715b3e2538
MD5 f2d20aa7c5351feec21c97bdbef0fc1a
BLAKE2b-256 fdfa4cf52e40bb4a8835c36fe989939f5609aebd19b37656431fac801f9d3427

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pysrat-0.2.6-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 547.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.6-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 f28d7e9711460e3f7f08e3c033dc53c4a0ebaa2fde19a6586c7513823f8e4635
MD5 0faae51af51890f0ffcfe0b66e4d1112
BLAKE2b-256 c38cd70175ac201f0552fa866ea302b0ea2c2466a140e89dc0e665c2cc30813c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.6-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c5686a926d197493e0fb55ee99be0962f103e2813d5d681701450814c7803dda
MD5 d9acf92f2e0155729577d5c2695e44d0
BLAKE2b-256 79819e7253bc53a8de0edb039c7804a1734702f00f28db5985d59425cf2f442e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.6-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7a2879c02b1cec880ed70c5902fa714449c98cffcd6046a5f88f2e4a3051e896
MD5 ec2d7208acf4c780ac560de61d7374b2
BLAKE2b-256 e791b47969d80196a396791d56a9d0b1ead0c6fe56e0c85d9d3da04a7f03c9dc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.6-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 92ee489587d677256d8fa8a310712ee2ba08e923a613457ceeafe25484ecff5f
MD5 e4d5ffb0d0e7a63eed0675525ed5e2d9
BLAKE2b-256 ebfa67ca5ecd135cc900fa2a71e8f7de1272857a58d43ffe519a01bb17578701

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