Skip to main content

Probabilistic Scoring List classifier

Project description

License Pip Paper

Probabilistic Scoring Lists

Probabilistic scoring lists are incremental models that evaluate one feature of the dataset at a time. PSLs can be seen as a extension to scoring systems in two ways:

  • they can be evaluated at any stage allowing to trade of model complexity and prediction speed.
  • they provide probablistic predictions instead of determnistic decisions for each possible score.

Scoring Systems are used as decision support for human experts in medical or law domains.

This implementation adheres to the sklearn-api.

Install

pip install scikit-psl

Usage

For examples have a look at the examples folder, but here is a simple example

from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split

from skpsl import ProbabilisticScoringList

# Generating synthetic data with continuous features and a binary target variable
X, y = make_classification(n_informative=10, random_state=42)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=.2, random_state=42)

psl = ProbabilisticScoringList({-1, 1, 2})
psl.fit(X_train, y_train)
print(f"Brier score: {psl.score(X_test, y_test):.4f}")
"""
Brier score: 0.2438  (lower is better)
"""

df = psl.inspect(5)
print(df.to_string(index=False, na_rep="-", justify="center", float_format=lambda x: f"{x:.2f}"))
"""
 Stage Threshold  Score  T = -2  T = -1  T = 0  T = 1  T = 2  T = 3  T = 4  T = 5
  0            -     -       -       -   0.51      -      -      -      -      - 
  1     >-2.4245  2.00       -       -   0.00      -   0.63      -      -      - 
  2     >-0.9625 -1.00       -    0.00   0.00   0.48   1.00      -      -      - 
  3      >0.4368 -1.00    0.00    0.00   0.12   0.79   1.00      -      -      - 
  4     >-0.9133  1.00    0.00    0.00   0.12   0.12   0.93   1.00      -      - 
  5      >2.4648  2.00    0.00    0.00   0.07   0.07   0.92   1.00   1.00   1.00 
"""

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

0.5.0 - 2023-11-16

Added

  • _ClassifierAtK
    • Sigmoid calibration additional to isotonic
  • PSL classifier
    • Make optimization loss configurable
    • Small searchspace_analyisis(·) function makes lookahead choice more informed

Fixed

  • Fixed lookahead search space and considering global loss for model-sequence evaluation

Changed

  • Updated dependencies and added black
  • Moved Binarizer to different module
  • Moved PSL hyperparameters to constructor

0.4.2 - 2023-11-09

Fixed

  • _ClassifierAtK
    • Expected entropy for stage 0 now also calculated wrt. base 2
    • Data with only 0 or 1 is now also interpret as binary data

0.4.1 - 2023-10-19

Fixed

  • Small import error

0.4.0 - 2023-10-17

Added

  • Add brute force threshold optimization method to find the global optimum, bisect optimizer remains default method

Changed

  • Restructured source files

0.3.1 - 2023-09-12

Fixed

  • PSL is now correctly handles when all instances belong to the negative class
  • #1 if the first feature is assigned a negative score, it is now assigned the most negative score

0.3.0 - 2023-08-10

Added

  • PSL classifier can now run with continuous data and optimally (wrt. expected entropy) select thresholds to binarize the data

Changed

  • Significantly improved optimum calculation for MinEntropyBinarizer (the same optimization algorithm is shared with the psls internal binarization algorithm)

0.2.0 - 2023-08-10

Added

  • PSL classifier
    • introduced parallelization
    • implemented l-step lookahead
    • simple inspect(·) method that creates a tabular representation of the model

0.1.0 - 2023-08-08

Added

  • Initial implementation of the PSL algorithm

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

scikit_psl-0.5.0.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scikit_psl-0.5.0-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file scikit_psl-0.5.0.tar.gz.

File metadata

  • Download URL: scikit_psl-0.5.0.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.5 Linux/6.5.9-1-MANJARO

File hashes

Hashes for scikit_psl-0.5.0.tar.gz
Algorithm Hash digest
SHA256 9c788f7ea417b8077d8f779ceb2324bb3250df70dfc5276cebb249071274e0ea
MD5 11362d64c7fd7b3769f3bf41c22bd25b
BLAKE2b-256 f3d1a431393739b976bd1ddf3b7f6d8db9c6fc6eb227d5b90a73f935a67d004b

See more details on using hashes here.

File details

Details for the file scikit_psl-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: scikit_psl-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.5 Linux/6.5.9-1-MANJARO

File hashes

Hashes for scikit_psl-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 44493519c44c9efc4c62c530aefd41b2edfda0351a05def06e8bf39ffb46075e
MD5 56fdfc4b11eaabdbf1d0e9a59e60ea38
BLAKE2b-256 4eba27e448f790efe7fddabe07c0ebb5c65a83fff3ca3b4ea25aa504a6dcc97c

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