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 (pr_nhpp_fit)

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)

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 (pr_nhpp_fit)

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

Uploaded CPython 3.13Windows x86-64

pysrat-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (571.1 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

pysrat-0.2.0-cp313-cp313-macosx_11_0_arm64.whl (440.1 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pysrat-0.2.0-cp313-cp313-macosx_10_13_x86_64.whl (486.1 kB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

pysrat-0.2.0-cp312-cp312-win_amd64.whl (468.7 kB view details)

Uploaded CPython 3.12Windows x86-64

pysrat-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (570.7 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

pysrat-0.2.0-cp312-cp312-macosx_11_0_arm64.whl (440.0 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pysrat-0.2.0-cp312-cp312-macosx_10_13_x86_64.whl (485.9 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

pysrat-0.2.0-cp311-cp311-win_amd64.whl (465.2 kB view details)

Uploaded CPython 3.11Windows x86-64

pysrat-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (564.8 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

pysrat-0.2.0-cp311-cp311-macosx_11_0_arm64.whl (435.6 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pysrat-0.2.0-cp311-cp311-macosx_10_9_x86_64.whl (480.3 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

pysrat-0.2.0-cp310-cp310-win_amd64.whl (463.2 kB view details)

Uploaded CPython 3.10Windows x86-64

pysrat-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (562.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

pysrat-0.2.0-cp310-cp310-macosx_11_0_arm64.whl (432.4 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pysrat-0.2.0-cp310-cp310-macosx_10_9_x86_64.whl (476.2 kB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

pysrat-0.2.0-cp39-cp39-win_amd64.whl (468.3 kB view details)

Uploaded CPython 3.9Windows x86-64

pysrat-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (563.1 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

pysrat-0.2.0-cp39-cp39-macosx_11_0_arm64.whl (432.8 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

pysrat-0.2.0-cp39-cp39-macosx_10_9_x86_64.whl (476.5 kB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: pysrat-0.2.0.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.0.tar.gz
Algorithm Hash digest
SHA256 d850e7c477bb89000f67c7d1e887f2e1da18ff897e3b70594b53f8e30cc023ef
MD5 3eab38fd36e773831a2f87c98f5b3c0d
BLAKE2b-256 731bcccbae9338b629c22d9b8636570aadfb15063c7c4c161067fbd7c969ba12

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pysrat-0.2.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 468.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.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 8c4a63a1098669f707a291f0d19a9c97fba9eefb36319360300252f2afc3f8d4
MD5 91921e0fae14d51cde9326306df2642f
BLAKE2b-256 3093f3f5bdf2bda2f602dcf3eb537a9547daecd508e578df701f078473e80a59

See more details on using hashes here.

File details

Details for the file pysrat-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pysrat-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 599c58bc46b3b12ec4c5b7d3c6e4471c29b2e582ccb9f44e24ca34517b041558
MD5 a419def74192d2af94844efa36c90f95
BLAKE2b-256 d997f058621206507303077b1c86a0ad7353b3b3cd5b858927ea5848d6f8153f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 41ed40a96712a770294b698164c1626bd3ffb5ade8833416da3db10947b6f030
MD5 98b5303a4979039ac79c3f3b6f426822
BLAKE2b-256 d5a60c2624195cf0bf97235e3ac0c6d056a78b46a5675d2f64ba70a3f0777d85

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.0-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 99a0fced54fd48c55fb938da6f431d285fa63a7b8a405a8496da1f3a01142bd5
MD5 508d59d7138c297cb9c4e8eb841fac05
BLAKE2b-256 26112a0520de33f6a3fdb853ffa7ca5f8fa07bd3e247a09f163717d23c12ed5e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pysrat-0.2.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 468.7 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.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 724744e3fe4cef8e1f3eb8fa91cf55f68338b2e1002a9f2ca3b2f683643adb53
MD5 f44c853bc04eb6e22297f94618d9afdf
BLAKE2b-256 010f83c16d303ffafb8eed5c478ab780e016dc5e0c33a7ef09b51eb45ba3e064

See more details on using hashes here.

File details

Details for the file pysrat-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pysrat-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a71a9139c54f23e2a424c03531f286c1286d651ae91a6c65adc03f476e727774
MD5 8875259b999bfcae51b340ae794012a9
BLAKE2b-256 f11b3c988d27832893cf0dd54539fac9748c419bd9058bb91c6f826c1e284bc1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 84b09e01fa69b1f99cf0f666ff0d84fc0f97841035bea44423e146427d1d0df6
MD5 8b6b18de793b1641e82ee669fc82fb84
BLAKE2b-256 ebdbb00df159ffd3dbceedd65fc7b5a57a8c83eb349c4bd913236ee5d797e85d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.0-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 f59ace13cee6d3724871f0b1b1fd594b0abbc0917577f4a195dac20cb9e633a1
MD5 8ed35220565a0e4af532303834a1d09a
BLAKE2b-256 0d2d28c1d36d48943e4c628e2823b433fc01c6d688011175a9bebc619b84d40e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pysrat-0.2.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 465.2 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.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 663e991e88074531dfb2263481afd17b4c407d7c53e09e4456f310eea2774c83
MD5 da05bca415ae3c9754d3e3eed80f8201
BLAKE2b-256 218a96c509a52876d49dcb8a7ddc102cff41700eba1cd51375c2169286465d9f

See more details on using hashes here.

File details

Details for the file pysrat-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pysrat-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5933c3246d122e60f390137e1976c43ea5b6e6c976f4171f8ef7be99d35f9b58
MD5 bf8c37a767abbce5eee483f1bd67eb6b
BLAKE2b-256 1135b5daf6ea1a531f2344a930c3feda0bf9c79074da524127ae02b05ef63ae0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 76d57034511b7004bc7ae6a746d187f03b548ffba4f8982d61cfd166f862f9d7
MD5 a07d355abec3a49ddbe79924cced71eb
BLAKE2b-256 898b3ec4293886a255afe2d2a9a5c51832d121f2de40dad1c4201cef19750893

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 35faa32da44ec5f309a7e7a351ecd12f034960d7ebaa0850c97331b29d53117f
MD5 0df49fdd170013dc0d4ee06b6ea5887e
BLAKE2b-256 bf02e7a14433496752c85b7e312d7143024e210e83e7d6cf7b544786d500d81e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pysrat-0.2.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 463.2 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.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c99cba6795d59adc63e7f8082540ddcbb84eff568435140b125dd7dff8ed417a
MD5 8b33c60f1b89361d257e51cfaadd15d3
BLAKE2b-256 fc986f9179705855640a4d729f33d2f9b93483ed5b30e34f0c324fb38f056ef3

See more details on using hashes here.

File details

Details for the file pysrat-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pysrat-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ff08c8b8bf105a681aa4f61378edd1bc089f21faf839f5429a96b74204a7e123
MD5 9a7e72f82c8f672a65ab1f3137e7492e
BLAKE2b-256 3c7be9b90b6965b67c4e7c01cf58a55f53da0e0fa575e782d4282da73a1c387d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fc9410841ab93d750c7eb44a7a726360d93ee0e19a57ac709a5bb44206c08ef0
MD5 98f87e91a62c0ee6dc7479e157191525
BLAKE2b-256 8c5c0e03e8e6d147e843c283f7bcd0e3bb64306a3521aefce91ad6701509e7ad

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f2dcfc7166c6cf6db7673199d3c808910a7ca07688b88b161abad89152cdb52a
MD5 ad9c3bace500e91c2d702e8f84b77ad0
BLAKE2b-256 49bf0db442ad81edb9d57408c2f5c0814de7b20fcf3f5b92db1b9a975ecf4a57

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pysrat-0.2.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 468.3 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.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 051f6ad204ae7d93ba4f07bc0fcb41c5f231779da9e2c772fb6f2c2fb5de8c94
MD5 8fdf9718aa4bc44778833ae8813bc624
BLAKE2b-256 0de6c53c7e00158a43d08332d4eb25e4d5e84ceb00293e41a73c586f2c184104

See more details on using hashes here.

File details

Details for the file pysrat-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pysrat-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 eb5374c1b2e93a694276ccbc3721ec74faa78f1e077d1f5ae973a0987048492e
MD5 6409479ac6b544d7d9b435e172333278
BLAKE2b-256 12f796de82f63d46296e713012e50eaffbd7c00e7267dadba2bcb387d8825b74

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 57083c2a5ca0a464e757d805b39989f4af9d22bb7c72fddb59954789feed70c9
MD5 22e23627b711aa899f9641367edfffb1
BLAKE2b-256 6b82d5157b6b2c2550c3bc0a51bb1ba1d198abaf01bd4cb4c4c6ac150fd58129

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pysrat-0.2.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 4d0df1161fe72c8fc4b8c98c34c6fbc9b7e55067f4ecabfe8dcbbea26dcce3f4
MD5 442e12edf42bed16564e315db9ad74ee
BLAKE2b-256 ca337d40365fdd57c50427c1a967fbc9597f61afee47ee0f6a2589abd84d4fa0

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