Importance-Weighted Classifier

class libtlda.iw.ImportanceWeightedClassifier(loss_function='logistic', l2_regularization=None, weight_estimator='lr', smoothing=True, clip_max_value=-1, kernel_type='rbf', bandwidth=1)

Class of importance-weighted classifiers.

Methods contain different importance-weight estimators and different loss functions.

Examples

>>>> X = np.random.randn(10, 2)
>>>> y = np.vstack((-np.ones((5,)), np.ones((5,))))
>>>> Z = np.random.randn(10, 2)
>>>> clf = ImportanceWeightedClassifier()
>>>> clf.fit(X, y, Z)
>>>> u_pred = clf.predict(Z)

Methods

fit(X, y, Z) Fit/train an importance-weighted classifier.
get_params() Get classifier parameters.
get_weights() Get estimated importance weights.
is_trained() Check whether classifier is trained.
iwe_kernel_densities(X, Z) Estimate importance weights based on kernel density estimation.
iwe_kernel_mean_matching(X, Z) Estimate importance weights based on kernel mean matching.
iwe_logistic_discrimination(X, Z) Estimate importance weights based on logistic regression.
iwe_nearest_neighbours(X, Z) Estimate importance weights based on nearest-neighbours.
iwe_ratio_gaussians(X, Z) Estimate importance weights based on a ratio of Gaussian distributions.
predict(Z) Make predictions on new dataset.
predict_proba(Z) Compute posterior probabilities on new dataset.
fit(X, y, Z)

Fit/train an importance-weighted classifier.

Parameters:
X : array

source data (N samples by D features)

y : array

source labels (N samples by 1)

Z : array

target data (M samples by D features)

Returns:
None
get_params()

Get classifier parameters.

get_weights()

Get estimated importance weights.

is_trained()

Check whether classifier is trained.

iwe_kernel_densities(X, Z)

Estimate importance weights based on kernel density estimation.

Parameters:
X : array

source data (N samples by D features)

Z : array

target data (M samples by D features)

Returns:
array

importance weights (N samples by 1)

iwe_kernel_mean_matching(X, Z)

Estimate importance weights based on kernel mean matching.

Parameters:
X : array

source data (N samples by D features)

Z : array

target data (M samples by D features)

Returns:
iw : array

importance weights (N samples by 1)

iwe_logistic_discrimination(X, Z)

Estimate importance weights based on logistic regression.

Parameters:
X : array

source data (N samples by D features)

Z : array

target data (M samples by D features)

Returns:
array

importance weights (N samples by 1)

iwe_nearest_neighbours(X, Z)

Estimate importance weights based on nearest-neighbours.

Parameters:
X : array

source data (N samples by D features)

Z : array

target data (M samples by D features)

Returns:
iw : array

importance weights (N samples by 1)

iwe_ratio_gaussians(X, Z)

Estimate importance weights based on a ratio of Gaussian distributions.

Parameters:
X : array

source data (N samples by D features)

Z : array

target data (M samples by D features)

Returns:
iw : array

importance weights (N samples by 1)

predict(Z)

Make predictions on new dataset.

Parameters:
Z : array

new data set (M samples by D features)

Returns:
preds : array

label predictions (M samples by 1)

predict_proba(Z)

Compute posterior probabilities on new dataset.

Parameters:
Z : array

new data set (M samples by D features)

Returns:
probs : array

label predictions (M samples by K)