bqlearn.plugin.PluginCorrection¶
- class bqlearn.plugin.PluginCorrection(estimator, *, prefit=False, transition_matrix='iterative', quantile=0.97, n_iter=100, noise_free_prior=0.0)[source]¶
A Noise Corrected Plug-in Classifier.
PluginCorrection [1] learns a classifier on noisy data and uses a noise transition matrix \(\mathbf{T}\) at prediction time (plug-in) to correct the classifier.
\[\forall x \in \mathcal{X}, f_T(x)=(\mathbf{T}^{t})^{-1}\cdot f_U(x)\]- Parameters:
- estimatorestimator object
An estimator object implementing fit and predict_proba.
- prefitbool, default=False
Whether a prefit model is expected to be passed into the constructor directly or not. If True, estimator must be a fitted estimator. If False, estimator is fitted by calling fit.
- transition_matrix{‘iterative’, ‘anchor’, ‘gold’, ‘confusion’} or array-like of shape (n_classes, n_classes), default=’iterative’
Algorithm to estimate the transition matrix. ‘gold’ and ‘confusion’ are only available on biquality data.
- quantilefloat, default=0.97
Quantile used to select the anchor points. Only used when transition_matrix=’anchor’ or transition_matrix=’iterative’.
- n_iterint, default=100
Number of iteratives to compute the transition matrix. Only used when transition_matrix=’iterative’.
- noise_free_priorfloat, default=0.0
Factor for the convex combination between the estimated transition_matrix and the identity matrix to lower the condition number of the estimated transition matrix. It’s equivalent to take a more conservative noise-free prior.
- random_stateint or RandomState, default=None
Controls the random seed given at base_estimator. Pass an int for reproducible output across multiple function calls.
- Attributes:
- estimator_classifier
The fitted estimator.
- transition_matrix_: ndarray of shape (n_classes, n_classes)
Estimated transition matrix between untrusted and untrusted labels.
- classes_ndarray of shape (n_classes,)
The classes labels.
- n_classes_int
The number of classes.
- n_features_in_int
Number of features seen during fit. Only defined if the underlying estimator exposes such an attribute when fit.
- feature_names_in_ndarray of shape (n_features_in_,)
Names of features seen during fit. Only defined if the underlying estimator exposes such an attribute when fit.
References
[1]Zhang, J. Lee, and S. Agarwal. “Learning from noisy labels with no change to the training process.”, ICML, 2021.
Methods
Noise-corrected plug-in of predicted probabilites from estimator.
fit(X, y[, sample_quality])Fit the noise corrected plug-in classification model.
get_params([deep])Get parameters for this estimator.
predict(X)Predict the classes of X.
score(X, y[, sample_weight])Return the mean accuracy on the given test data and labels.
set_params(**params)Set the parameters of this estimator.
- decision_function(X)[source]¶
Noise-corrected plug-in of predicted probabilites from estimator.
For binary classification, the score is the margin between the two classes.
- Parameters:
- Xarray-like, shape (n_samples, n_features)
The input samples.
- Returns:
- yndarray, shape (n_samples, n_classes)
The predicted classes.
- fit(X, y, sample_quality=None)[source]¶
Fit the noise corrected plug-in classification model.
- Parameters:
- Xarray-like of shape (n_samples, n_features)
The samples.
- yarray-like of shape (n_samples,)
The targets.
- sample_qualityarray-like, shape (n_samples,)
Per-sample qualities.
- Returns:
- selfobject
Returns self.
- get_params(deep=True)[source]¶
Get parameters for this estimator.
- Parameters:
- deepbool, default=True
If True, will return the parameters for this estimator and contained subobjects that are estimators.
- Returns:
- paramsdict
Parameter names mapped to their values.
- predict(X)[source]¶
Predict the classes of X.
- Parameters:
- Xarray-like, shape (n_samples, n_features)
The input samples.
- Returns:
- yndarray, shape (n_samples,)
The predicted classes.
- score(X, y, sample_weight=None)[source]¶
Return the mean accuracy on the given test data and labels.
In multi-label classification, this is the subset accuracy which is a harsh metric since you require for each sample that each label set be correctly predicted.
- Parameters:
- Xarray-like of shape (n_samples, n_features)
Test samples.
- yarray-like of shape (n_samples,) or (n_samples, n_outputs)
True labels for X.
- sample_weightarray-like of shape (n_samples,), default=None
Sample weights.
- Returns:
- scorefloat
Mean accuracy of
self.predict(X)w.r.t. y.
- set_params(**params)[source]¶
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as
Pipeline). The latter have parameters of the form<component>__<parameter>so that it’s possible to update each component of a nested object.- Parameters:
- **paramsdict
Estimator parameters.
- Returns:
- selfestimator instance
Estimator instance.