bqlearn.ea.EasyADAPT¶
- class bqlearn.ea.EasyADAPT(estimator)[source]¶
A Frustratingly Easy approach to Domain Adaptation.
EasyADAPT [1] creates an augmented input space \(\tilde{\mathcal{X}} = \mathcal{X}^3\) with two different mapping for untrusted and trusted samples, \(\Psi_U:\mathcal{X}\mapsto \tilde{\mathcal{X}}\) and \(\Psi_T:\mathcal{X}\mapsto \tilde{\mathcal{X}}\).
- ..math::
forall mathbf{x} in mathcal{X}, Psi_U(mathbf{x})=<mathbf{x}, mathbf{x}, mathbf{0}>
- ..math::
forall mathbf{x} in mathcal{X}, Psi_T(mathbf{x})=<mathbf{x}, mathbf{0}, mathbf{x}>
This augmented domain \(\tilde{\mathcal{X}}\) allow for the classifier to learn different relation between the features and the target differently for the untrusted, trusted and general domain.
- Parameters:
- estimatorestimator object
An estimator object.
- Attributes:
- estimator_classifier
The fitted estimator.
- classes_ndarray of shape (n_classes,)
The classes labels.
- n_classes_int
The number of classes. Only defined if the underlying estimator exposes such an attribute when fit.
- 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]Daumé III, Hal. “Frustratingly Easy Domain Adaptation.” Proceedings of the 45th Annual Meeting of the Association of Computational Linguistics. 2007.
Methods
augment(X[, sample_quality])Augment the input dataset according to sample_quality.
Call decision function of the estimator on the augmented dataset.
fit(X, y[, sample_quality])Fit the augmented model.
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_params(**params)Set the parameters of this estimator.
- augment(X, sample_quality=None)[source]¶
Augment the input dataset according to sample_quality.
- Parameters:
- Xarray-like of shape (n_samples, n_features)
The samples.
- sample_qualityarray-like, shape (n_samples,)
Per-sample qualities.
- Returns:
- X_augarray-like of shape (n_samples, 3 * n_features)
Returns the augmented samples.
- decision_function(X)[source]¶
Call decision function of the estimator on the augmented dataset.
- 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 augmented 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.
- 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_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.