bqlearn.density_ratio.IPDR¶
- class bqlearn.density_ratio.IPDR(estimator, *, n_estimators=10, exploit_iterative_learning=False, window=1, pdr_estimator=None, method='probabilities')[source]¶
An Iterative Probabilistic Density Ratio Biquality Classifier.
An IDR using a Probabilistic Classifier [1] to reweigth untrusted examples [2].
- Parameters:
- estimatorobject
The estimator from which the IDR classifier is built. Support for sample weighting and probability prediction is required.
- n_estimatorsint, default=10
Maximum number of trained estimators on reweighted samples.
- exploit_iterative_learning: boolean, default=False
If the estimator supports iterative learning with warm_start, exploit it by computing new weights for every epoch when fitting estimator.
- window: int, default=1
Number of previous losses used to compute sample weights.
- pdr_estimatorobject, default=None
The base estimator from which the weights are estimated thanks to pdr. If
None, then the base estimator isLogisticRegression.- method: {‘odds’, ‘probabilites’}, default=’probabilites’
Use the odd ratios simplification to avoid the division when computing the ratio of conditional probabilities. This method is not adequate for estimators using a different link function than the logit.
- Attributes:
- estimator_classifier
The final fitted estimator.
- classes_ndarray of shape (n_classes,)
The classes labels.
- n_classes_int
The number of classes.
References
[1]Bickel, M. Bruckner, T. Scheffer, “Discriminative Learning for Differing Training and Test Distributions”, 2007
[2]Jiang, Lu, et al. “Mentornet: Learning data-driven curriculum for very deep neural networks on corrupted labels.” International conference on machine learning. PMLR, 2018.
Methods
Call decision function of the final_estimator.
fit(X, y[, sample_quality])Fit the reweighted model.
Get metadata routing of this object.
get_params([deep])Get parameters for this estimator.
predict(X)Predict the classes of X.
Predict log probability for each possible outcome.
Predict probability for each possible outcome.
score(X, y[, sample_weight])Return the mean accuracy on the given test data and labels.
set_fit_request(*[, sample_quality])Request metadata passed to the
fitmethod.set_params(**params)Set the parameters of this estimator.
set_score_request(*[, sample_weight])Request metadata passed to the
scoremethod.- decision_function(X)[source]¶
Call decision function of the final_estimator.
- Parameters:
- Xarray-like, shape (n_samples, n_features)
The input samples.
- Returns:
- yndarray, shape (n_samples,)
The predicted classes.
- fit(X, y, sample_quality=None)[source]¶
Fit the reweighted model.
- Parameters:
- X{array-like, sparse matrix} of shape (n_samples, n_features)
The training input samples. Sparse matrix can be CSC, CSR, COO, DOK, or LIL. COO, DOK, and LIL are converted to CSR.
- yarray-like of shape (n_samples,)
The target labels.
- sample_qualityarray-like, shape (n_samples,)
Sample qualities.
- Returns:
- selfobject
- get_metadata_routing()[source]¶
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
- routingMetadataRequest
A
MetadataRequestencapsulating routing information.
- 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.
- predict_log_proba(X)[source]¶
Predict log probability for each possible outcome.
- Parameters:
- Xarray-like, shape (n_samples, n_features)
The input samples.
- Returns:
- log_parray, shape (n_samples, n_classes)
Array with log prediction probabilities.
- predict_proba(X)[source]¶
Predict probability for each possible outcome.
- Parameters:
- Xarray-like, shape (n_samples, n_features)
The input samples.
- Returns:
- parray, shape (n_samples, n_classes)
The class probabilities of the input samples. The order of the classes corresponds to that in the attribute 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_fit_request(*, sample_quality: bool | None | str = '$UNCHANGED$') IPDR[source]¶
Request metadata passed to the
fitmethod.Note that this method is only relevant if
enable_metadata_routing=True(seesklearn.set_config()). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline. Otherwise it has no effect.- Parameters:
- sample_qualitystr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
sample_qualityparameter infit.
- Returns:
- selfobject
The updated object.
- 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.
- set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') IPDR[source]¶
Request metadata passed to the
scoremethod.Note that this method is only relevant if
enable_metadata_routing=True(seesklearn.set_config()). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.New in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
pipeline.Pipeline. Otherwise it has no effect.- Parameters:
- sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
sample_weightparameter inscore.
- Returns:
- selfobject
The updated object.