skada.KLIEPReweightAdapter

class skada.KLIEPReweightAdapter(gamma, cv=5, n_centers=100, tol=1e-06, max_iter=1000, random_state=None)[source]

Kullback-Leibler Importance Estimation Procedure (KLIEPReweight).

The idea of KLIEPReweight is to find an importance estimate w(x) such that the Kullback-Leibler (KL) divergence between the source input density p_source(x) to its estimate p_target(x) = w(x)p_source(x) is minimized.

See [3] for details.

Parameters:
gammafloat or array like

Parameters for the kernels. If array like, compute the likelihood cross validation to choose the best parameters for the RBF kernel. If float, solve the optimization for the given kernel parameter.

cvint, cross-validation generator or an iterable, default=5

Determines the cross-validation splitting strategy. If it is an int it is the number of folds for the cross validation.

n_centersint, default=100

Number of kernel centers defining their number.

tolfloat, default=1e-6

Tolerance for the stopping criterion in the optimization.

max_iterint, default=1000

Number of maximum iteration before stopping the optimization.

random_stateint, RandomState instance or None, default=None

Determines random number generation for dataset creation. Pass an int for reproducible output across multiple function calls.

References

[3]

Masashi Sugiyama et. al. Direct Importance Estimation with Model Selection and Its Application to Covariate Shift Adaptation. In NeurIPS, 2007.

Attributes:
`best_gamma_`float

The best gamma parameter for the RBF kernel chosen with the likelihood cross validation if several parameters are given as input.

`alpha_`float

Solution of the optimization problem.

`centers_`list

List of the target data taken as centers for the kernels.

fit(X, y=None, sample_domain=None, **kwargs)[source]

Fit adaptation parameters.

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

The source data.

yarray-like, shape (n_samples,)

The source labels.

sample_domainarray-like, shape (n_samples,)

The domain labels (same as sample_domain).

Returns:
selfobject

Returns self.

set_fit_request(*, sample_domain: bool | None | str = '$UNCHANGED$') KLIEPReweightAdapter

Request metadata passed to the fit 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 fit 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 fit.

  • 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.

Added 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. Otherwise it has no effect.

Parameters:
sample_domainstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for sample_domain parameter in fit.

Returns:
selfobject

The updated object.

set_transform_request(*, allow_source: bool | None | str = '$UNCHANGED$', sample_domain: bool | None | str = '$UNCHANGED$') KLIEPReweightAdapter

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.

Added 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. Otherwise it has no effect.

Parameters:
allow_sourcestr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for allow_source parameter in transform.

sample_domainstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for sample_domain parameter in transform.

Returns:
selfobject

The updated object.