Machine learning with a reject option
Project description
scikit-fallback is a scikit-learn-compatible Python package for machine learning with a reject option.
👩💻 Usage
To allow your probabilistic pipeline to fallback—i.e., abstain from predictions—you can
wrap it with a skfb
rejector. Training a rejector means both fitting your model and
learning to accept or reject predictions. Evaluation of a rejector depends
on fallback mode (inference with or without fallback labels) and measures the ability
of the rejector to both accept correct predictions and reject ambiguous ones.
For example, skfb.estimators.ThresholdFallbackClassifierCV
fits the base estimator and then
finds the best confidence threshold via cross-validation. If fallback_mode == "store"
, then the
rejector returns skfb.core.array.FBNDArray
of predictions and a sparse fallback-mask property,
which lets us summarize the accuracy of both predictions and rejections.
from skfb.estimators import ThresholdFallbackClassifierCV
from sklearn.linear_model import LogisticRegressionCV
rejector = ThresholdFallbackClassifierCV(
LogisticRegressionCV(cv=4, random_state=0),
thresholds=10,
ambiguity_threshold=0.05,
cv=5,
fallback_label=-1,
fallback_mode="store",
)
rejector.fit(X_train, y_train) # Train base estimator and learn best threshold
rejector.score(X_test, y_test) # Compute acceptance-correctness accuracy score
And for more motivation and information on usage, please visit our documentation and refer to the Medium series on machine learning with a reject option.
🏗 Installation
scikit-fallback
requires:
- Python (>=3.9,<3.13)
- scikit-learn (>=1.0)
- numpy
- scipy
- matplotlib (>=3.0) (optional)
and along with the requirements can be installed via pip
:
pip install -U scikit-fallback
📚 Examples
See the examples/
directory for various applications of fallback estimators
and scorers to scikit-learn-compatible pipelines.
🔗 References
- Hendrickx, K., Perini, L., Van der Plas, D. et al. Machine learning with a reject option: a survey. Mach Learn 113, 3073–3110 (2024). https://doi.org/10.1007/s10994-024-06534-x
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file scikit_fallback-0.1.1.post0.tar.gz
.
File metadata
- Download URL: scikit_fallback-0.1.1.post0.tar.gz
- Upload date:
- Size: 37.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f589a1e2d21c10ee91b793e517d71fe64e0d086112b6c0f9e0d5f01fd90732a5 |
|
MD5 | 46effbde3f7223d3c9431e774106a58e |
|
BLAKE2b-256 | 505137c7174bade4fb1aafa0dcdd48b6db9e14aa874e213242b880e8405a1c91 |
File details
Details for the file scikit_fallback-0.1.1.post0-py3-none-any.whl
.
File metadata
- Download URL: scikit_fallback-0.1.1.post0-py3-none-any.whl
- Upload date:
- Size: 37.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6dce670080e0f65d6f11559ed9289c21a96911a564dd96bdad06658cc833da61 |
|
MD5 | 58e49e5a2cbc493a92fa904e574cdba6 |
|
BLAKE2b-256 | 681f5cee04ce69ac623fa3b654c1c733f899cbbad0f63f0612d082f0a73934d6 |