bqlearn.ea.EasyADAPT

class bqlearn.ea.EasyADAPT[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.

Attributes:
n_features_in_int

Number of features seen during fit.

feature_names_in_ndarray of shape (n_features_in_,)

Names of features seen during fit.

References

[1]

Daumé III, Hal. “Frustratingly Easy Domain Adaptation.” Proceedings of the 45th Annual Meeting of the Association of Computational Linguistics. 2007.

Methods

fit(X[, y])

Fit the augmented model.

fit_transform(X[, y, sample_quality])

Fit to data, then transform it.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

set_output(*[, transform])

Set output container.

set_params(**params)

Set the parameters of this estimator.

set_transform_request(*[, sample_quality])

Request metadata passed to the transform method.

transform(X[, sample_quality])

Augment the input dataset according to sample_quality.

get_feature_names_out

fit(X, y=None)[source]

Fit the augmented model.

Parameters:
Xarray-like of shape (n_samples, n_features)

The samples.

yNone
Returns:
selfobject

Returns self.

fit_transform(X, y=None, sample_quality=None)[source]

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters:
Xarray-like of shape (n_samples, n_features)

Input samples.

yarray-like of shape (n_samples,) or (n_samples, n_outputs), default=None

Target values (None for unsupervised transformations).

**fit_paramsdict

Additional fit parameters.

Returns:
X_newndarray array of shape (n_samples, n_features_new)

Transformed array.

get_metadata_routing()[source]

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Returns:
routingMetadataRequest

A MetadataRequest encapsulating 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.

set_output(*, transform=None)[source]

Set output container.

See Introducing the set_output API for an example on how to use the API.

Parameters:
transform{“default”, “pandas”}, default=None

Configure output of transform and fit_transform.

  • “default”: Default output format of a transformer

  • “pandas”: DataFrame output

  • None: Transform configuration is unchanged

Returns:
selfestimator instance

Estimator instance.

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_transform_request(*, sample_quality: bool | None | str = '$UNCHANGED$') EasyADAPT[source]

Request metadata passed to the transform method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to transform if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to transform.

  • 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_quality parameter in transform.

Returns:
selfobject

The updated object.

transform(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.