Skip to main content

Thereshold Picker for Binary Classifiers

Project description

ThresholdPicker

A Tool for Optimizing Model Threshold.

Model Threshold is for most models set to a default of 0.5. Inmany cases your model performance can be imporved by selecting another threshold. The Purpose of this project is to provide a tool for optimal Threshold picking.
This tool is designed to work only with Binary Calssifiers.

The tool currently supports the following scenarios:

1. Balance True-Positive and False-Positive rates for Maximal Return.
For Example:
If the value of each TP is 10$ and the cost of every FP is 2$ and your data has 20% True vs 80% False labels.
You can use this tool to optimize the threshold so that your model will return the maximal average income.
Usage Example:

from ThresholdPicker.utils import *
from ThresholdPicker.ThresholdPicker import ThresholdPicker as PRTC
# simulate model probabilities and labels
predicted_probas = np.arange(0, 1 ,.01)
labels = np.random.choice([0,1], num_bins)
prtc = PRTC()
threshold, _ = prtc.gen_optimal_return_threshold(predicted_probas,
                                                 labels,
                                                 true_pos_value=10,
                                                 false_pos_cost=2
                                                 ) 


2. Pick Threshold by Recall: in case you need to configure the model to return a specific recall score.
You can run the ThresholdPicker with a labeled Validation set and receive the threshold that would give the recall closest to the the one you specified. Usage Example:

threshold, _ = get_threshold(predicted_probas,
                             labels, target=target,
                             mode='recall', betta=1) 


3. Pick Threshold by Percision:
in case you need to configure the model to return a specific recall score.
You can run the ThresholdPicker with a labeled Validation set and receive the threshold that would give the recall closest to the the one you specified. Usage Example:

threshold, _ = get_threshold(predicted_probas,
                             labels, target=target,
                             mode='percision', betta=1) 


4. Pick Threshold by F-Score:
in case you need to configure the model to return a specific recall score.
You can run the ThresholdPicker with a labeled Validation set and receive the threshold that would give the recall closest to the the one you specified. Usage Example:

betta=1 # can peak any betta 
threshold, _ = get_threshold(predicted_probas,
                             labels, target=target,
                             mode='fscore', betta=betta)


5. Pick Threshold for maximal F-Score:
in progress

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

ThresholdPicker-0.0.5.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

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

ThresholdPicker-0.0.5-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file ThresholdPicker-0.0.5.tar.gz.

File metadata

  • Download URL: ThresholdPicker-0.0.5.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.5

File hashes

Hashes for ThresholdPicker-0.0.5.tar.gz
Algorithm Hash digest
SHA256 3298442a7e8a412fe214ae22481633bf08ea5399f154aa5fbcafed1be6bf3b8c
MD5 9d345eb2892233bd8c2c054b8d810e00
BLAKE2b-256 a5b996352036f502599bba2b1fec0769ce8adee532cf6d5d911d3c0f463b586a

See more details on using hashes here.

File details

Details for the file ThresholdPicker-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: ThresholdPicker-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.5

File hashes

Hashes for ThresholdPicker-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 c623361283ad8b52632189f286398c39cc5c5029cbf7a785f6ace90d55f1c1c3
MD5 9a6e32b6cbb4817f0fd9cce207a3d3dd
BLAKE2b-256 346c5252dbdc703aad1e30fc1a2df49c149479356bab8d6b0a391bdf89408856

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