Don't Blindly Trust Your Labels
Project description
doubtlab
A lab for bad labels.
This repository contains general tricks that may help you find bad, or noisy, labels in your dataset. The hope is that this repository makes it easier for folks to quickly check their own datasets before they invest too much time and compute on gridsearch.
Install
You can install the tool via pip.
python -m pip install doubtlab
Quickstart
Doubtlab allows you to define "reasons" for a row of data to deserve another look. These reasons can form a pipeline which can be used to retreive a sorted list of examples worth checking again.
from sklearn.datasets import load_iris
from sklearn.linear_model import LogisticRegression
from doubtlab.ensemble import DoubtEnsemble
from doubtlab.reason import ProbaReason, WrongPredictionReason
# Let's say we have some dataset/model already
X, y = load_iris(return_X_y=True)
model = LogisticRegression(max_iter=1_000)
model.fit(X, y)
# Next we can add reasons for doubt. In this case we're saying
# that examples deserve another look if the associated proba values
# are low or if the model output doesn't match the associated label.
reasons = {
'proba': ProbaReason(model=model),
'wrong_pred': WrongPredictionReason(model=model)
}
# Pass these reasons to a doubtlab instance.
doubt = DoubtEnsemble(**reasons)
# Get the ordered indices of examples worth checking again
indices = doubt.get_indices(X, y)
# Get dataframe with "reason"-ing behind the sorting
predicates = doubt.get_predicates(X, y)
Features
The library implemented many "reasons" for doubt.
General Reasons
RandomReason
: assign doubt randomly, just for sureOutlierReason
: assign doubt when the model declares a row an outlier
Classification Reasons
ProbaReason
: assign doubt when a models' confidence-values are low for any labelWrongPredictionReason
: assign doubt when a model cannot predict the listed labelLongConfidenceReason
: assign doubt when a wrong label gains too much confidenceShortConfidenceReason
: assign doubt when the correct label gains too little confidenceDisagreeReason
: assign doubt when two models disagree on a predictionCleanLabReason
: assign doubt according to cleanlab
Regression Reasons
AbsoluteDifferenceReason
: assign doubt when the absolute difference is too highRelativeDifferenceReason
: assign doubt when the relative difference is too high
Feedback
It is early days for the project. The project should be plenty useful as-is, but we prefer to be honest. Feedback and anekdotes are very welcome!
Related Projects
- The cleanlab project was an inspiration for this one. They have a great heuristic for bad label detection but I wanted to have a library that implements many. Be sure to check out their work on the labelerrors.com project.
- My employer, Rasa, has always had a focus on data quality. Some of that attitude is bound to have seeped in here. Be sure to check the Conversation Driven Development approach and Rasa X if you're working on virtual assistants.
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
Hashes for doubtlab-0.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67ad02a8075b9d1dd21239d92995e502af172b307e1d77c87fb76b51efd703f6 |
|
MD5 | 1545fd2597071d0f8bacf09ee73130c9 |
|
BLAKE2b-256 | ab687277ee6688e308ab60569f5921aa050472f84f503897f7298ac87657a823 |