MMD_RKHS#
- class mlquantify.matching.MMD_RKHS(kernel='rbf', gamma=None, degree=3, coef0=0.0, solver='slsqp')[source]#
Maximum Mean Discrepancy in RKHS (MMD-RKHS) quantifier.
Estimates class prevalences by minimising the squared distance between the kernel mean embedding of the test sample and the mixture of class-conditional kernel mean embeddings in a reproducing kernel Hilbert space.
- Parameters:
- kernelstr, default=’rbf’
Kernel function to use. One of
'rbf','linear','poly','sigmoid','cosine'.- gammafloat or None, default=None
Kernel coefficient for
'rbf','poly', and'sigmoid'.- degreeint, default=3
Polynomial degree for the
'poly'kernel.- coef0float, default=0.0
Independent term for
'poly'and'sigmoid'kernels.- solverstr, default=’slsqp’
Optimization solver.
- Attributes:
- classes_ndarray of shape (n_classes,)
Class labels seen during
fit.
References
References
[1]Zhang, K., Schölkopf, B., Muandet, K., & Wang, Z. (2013). Domain Adaptation under Target and Conditional Shift. ICML, pp. 819–827.
Examples
>>> from mlquantify.matching import MMD_RKHS >>> from sklearn.datasets import make_classification >>> X, y = make_classification(n_samples=200, random_state=42) >>> q = MMD_RKHS().fit(X, y) >>> q.predict(X) {0: 0.49, 1: 0.51}
- get_distance(dist_train, dist_test, distance='hellinger')[source]#
Compute a distance between two normalized representations.
- 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.
- set_fit_request(*, sample_weight: bool | None | str = '$UNCHANGED$') MMD_RKHS[source]#
Configure whether metadata should be requested to be passed to the
fitmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config). Please check the 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.Added in version 1.3.
- Parameters:
- sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
sample_weightparameter 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.