Skip to main content

Predictable

Hatch project Ruff PyPI License: MIT pytest build Documentation Status

What is it?

A framework for actuarial modelling.

Installation

pip install predictable

Quick start example

A model.py file will be used to house the modelling logic which will be applied to each modelpoint.

# import the library
from predictable import CashFlow, DiscountFactors, Model, StaticCashFlow

# Create new model instance
model = Model()

# Add a premium component
model.add_component(
    CashFlow(
        input_array=[100], formula=lambda prev: prev * 1.05, label="premium"
    )
)

# Add a sum assured component
model.add_component(CashFlow(label="cover", input_array=[1_000_000]))

# Add an expense component
model.add_component(
    StaticCashFlow(
        input_array=[10, 10, 10, 10, 10],
        label="expense",
    )
)

# Add discounting component
model.add_component(DiscountFactors(interest_rate=0.05, label="V"))

# Project cashflows over term
# Results return a pandas df object
df = model.project(term=10)

# Perform linear combination style manipulations
# Discounting the components
components = ["premium", "cover", "expense"]
for component in components:
    df[f"V_{component}"] = df[component] * df["V"]


# Define reserving relationship
df["Reserve"] = df["V_cover"] + df["V_expense"] - df["V_premium"]

# Results get returned as a pandas dataframe
print(df)

Documentation

This project is documented using sphinx and the full documentation can be found at predictable.readthedocs.io.

Development & Contibutions

The following steps can be followed to set up a development environment.

  1. Clone the project:

    git clone https://github.com/RatulMaharaj/predictable.git
    cd predictable
    
  2. Install hatch

    pipx install hatch
    
  3. Enter the default environment (this will activate the default virtual environment and install the project in editable mode).

    hatch shell default
    

Testing

This project uses pytest for testing purposes. The tests can be found in the tests directory. Tests will run after every commit (locally) and on every push (using github actions) but can also be run manually using:

hatch run test

Linting

This project is linted using ruff and formatted with black. The linting and formatting can be run manually using:

hatch run lint
hatch run format

Editing the docs

The documentation for this project can be found in the docs directory. The documentation is built using sphinx and can be built locally using:

hatch run docs:make

You can then serve the documentation locally using:

hatch run docs:serve

License

MIT

Metadata

Release files for predictable 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for predictable 0.0.2
File Size Uploaded Provenance Actions
predictable-0.0.2.tar.gz 15.8 kB Without provenance Details for predictable-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for predictable 0.0.2
File Interpreter ABI Platform Actions
predictable-0.0.2-py3-none-any.whl Python 3 none any Details for predictable-0.0.2-py3-none-any.whl

Total release size: 30.4 kB

Release files / predictable-0.0.2.tar.gz

Download URL predictable-0.0.2.tar.gz
Size 15.8 kB
Tags Source
SHA-256 checksum
How to use checksums
3f33dd4672c4b56b2fb76d528b78508139ee8307a6ab88494d2faced6bad8ada
BLAKE2b-256 checksum
How to use checksums
7b4b6e99bf10f07c0d84236499bb5f11d0f7e220cfcac6d62fc0af37eaa4a6ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / predictable-0.0.2-py3-none-any.whl

Download URL predictable-0.0.2-py3-none-any.whl
Size 14.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
154d0dbc52769b76054ebae9daa11652bacbbac57ecd62800443d822ef4d562e
BLAKE2b-256 checksum
How to use checksums
3a0bd2098a69d61946d060604ac45c8f06ed749e2526e446d6fed518dafe050b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Security for predictable 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page