Skip to main content

Patient Rule Induction Method for Python

Project description

Patient Rule Induction Method for Python

This module implements the Patient Rule Induction Method (PRIM) for scenario discovery in Python. This is a standalone version of the PRIM algorithm implemented in the EMA Workbench by Jan Kwakkel, which is based on the sdtoolkit R package developed by RAND Corporation. All credit goes to Jan Kwakkel for developing the original code. This standalone version of PRIM was created and maintained by David Hadka.

Licensed under the GNU General Public License, version 3 or later.

Test and Publish PyPI PyPI

Installation

To install the latest PRIM release, run the following command:

    pip install prim

To install the latest development version of PRIM, run the following commands:

    pip install -U build setuptools
    git clone https://github.com/Project-Platypus/PRIM.git
    cd PRIM
    python -m build
    python -m pip install --editable .

Usage

Below shows the interactive use of the PRIM module for finding the first box. In this example, we are interested in cases where the response is greater than 0.5 (as indicated by the threshold and threshold_type arguments). After creating the Prim object, we invoke find_box() to find the first box containing cases of interest followed by box.show_tradeoff() to display the tradeoff between coverage and density for each peeling/pasting trajectory.

    import prim
    import pandas as pd
    import matplotlib.pyplot as plt

    df = pd.DataFrame(np.random.rand(1000, 3), columns=["x1", "x2", "x3"])
    response = df["x1"]*df["x2"] + 0.2*df["x3"]
    
    p = prim.Prim(df, response, threshold=0.5, threshold_type=">")
    
    box = p.find_box()
    box.show_tradeoff()
    
    plt.show()

You can interact with the tradeoff plot by hovering the mouse over points to view the stats, as shown below.

Tradeoff plot

Clicking a point shows additional details in a separate window.

Details view

This module extends EMA Workbench's support for categorical data by allowing the categorical data to be plotted in the pairwise scatter plot:

Categorical data

Also note the Prev / Next buttons on this window allowing navigation to adjacent peeling trajectories without having to return to the tradeoff plot.

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

prim-1.0.0.tar.gz (60.4 kB view details)

Uploaded Source

Built Distribution

PRIM-1.0.0-py3-none-any.whl (55.7 kB view details)

Uploaded Python 3

File details

Details for the file prim-1.0.0.tar.gz.

File metadata

  • Download URL: prim-1.0.0.tar.gz
  • Upload date:
  • Size: 60.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for prim-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1b0be0860cfe23966493bbe901976054882e1edb4dd15bbf556311490ddc9620
MD5 3dcfb072a0751d7d613205c72f69e78e
BLAKE2b-256 ca6f445620585de19c2554d7d313e56fa0737a2de9e3e3b3c472ae63c76c644d

See more details on using hashes here.

File details

Details for the file PRIM-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: PRIM-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 55.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for PRIM-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d43094feae47d3bac9b337935f5c2ccfddcf9003b36d493bd53f5928ccc45209
MD5 056ca8395ac8bf78fc43fd0da738bffc
BLAKE2b-256 2d3493bf57da77dbf54460891e0e243824e7d916e94b0907d0512395799bed00

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page