-
Notifications
You must be signed in to change notification settings - Fork 0
Kernel Mean Matching
Steefano edited this page Dec 11, 2020
·
6 revisions
Kernel Mean Matching (KMM) is an algorithm first proposed by Huang et al. [1] for instance weighting in domain adaptation. The algorithm finds weights associated with the source domain data points in such a way that the Maximum Mean Discrepancy of source and target domains is minimized in a reproducing kernel Hilbert space.
class transfer.instance_weighting.KernelMeanMatching(B = 1000, epsilon = 0.1, kernel = "gaussian", gamma = None, coef0 = 1.0, degree = 3)
Parameter | Type | Description |
---|---|---|
B | float | Upper constraint on the weights. Acts as a form of regularization. |
epsilon | float | Allowed distance from the mean of the weights to one. |
kernel | string or callable | Kernel used. Can be a callable that takes two matrices of points and returns their kernel matrix or one of {"gaussian", "linear", "polynomial", "sigmoid", "laplacian"}. |
gamma | float or None | Coefficient of the dot product of points in the kernel. If None it defaults to 0 / n_features. |
coef0 | float | The coefficient term in the kernel when choosing "polynomial" or "sigmoid". It is ignored in other cases. |
degree | int | The degree of the kernel when choosing "polynomial". It is ignored in other cases. |
fit(Xs, Xt)
Fits the model to the given source and target domains' inputs by computing the source domain weights.
Parameter | Type | Description |
---|---|---|
Xs | array of shape (n_samples_s, n_features) | Source domain inputs. |
Xt | array of shape (n_samples_t, n_features) | Targrt domain inputs. |
Returns: self, fitted weighter.
fit_predict(Xs, Xt)
Fits the model to the given source and target domains' inputs and returns the computed weights.
Parameter | Type | Description |
---|---|---|
Xs | array of shape (n_samples_s, n_features) | Source domain inputs. |
Xt | array of shape (n_samples_t, n_features) | Targrt domain inputs. |
Returns: beta, array of shape (n_samples_s) containing the weights of the source domain's inputs.
weights_
Array of shape (n_samples_s) containing the weights of the source domain's inputs.
- J. Huang et al. Correcting sample selection bias by unlabeled data. 2006. https://papers.nips.cc/paper/2006/file/a2186aa7c086b46ad4e8bf81e2a3a19b-Paper.pdf