Feature-Level Domain-Adaptive Classifier¶
-
class
libtlda.flda.
FeatureLevelDomainAdaptiveClassifier
(l2=0.0, loss='logistic', transfer_model='blankout', max_iter=100, tolerance=1e-05, verbose=True)¶ Class of feature-level domain-adaptive classifiers.
Reference: Kouw, Krijthe, Loog & Van der Maaten (2016). Feature-level domain adaptation. JMLR.
Methods contain training and prediction functions.
Methods
fit
(X, y, Z)Fit/train a robust bias-aware classifier. flda_log_grad
(theta, X, y, E, V[, l2])Compute gradient with respect to theta for flda-log. flda_log_loss
(theta, X, y, E, V[, l2])Compute average loss for flda-log. get_params
()Get classifier parameters. is_trained
()Check whether classifier is trained. mle_transfer_dist
(X, Z[, dist])Maximum likelihood estimation of transfer model parameters. moments_transfer_model
(X, iota[, dist])Moments of the transfer model. predict
(Z_)Make predictions on new dataset. -
fit
(X, y, Z)¶ Fit/train a robust bias-aware 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
-
flda_log_grad
(theta, X, y, E, V, l2=0.0)¶ Compute gradient with respect to theta for flda-log.
Parameters: - theta : array
classifier parameters (D features by 1)
- X : array
source data set (N samples by D features)
- y : array
label vector (N samples by 1)
- E : array
expected value with respect to transfer model (N samples by D features)
- V : array
variance with respect to transfer model (D features by D features by N samples)
- l2 : float
regularization parameter (def: 0.0)
Returns: - dR : array
Value of gradient.
-
flda_log_loss
(theta, X, y, E, V, l2=0.0)¶ Compute average loss for flda-log.
Parameters: - theta : array
classifier parameters (D features by 1)
- X : array
source data set (N samples by D features)
- y : array
label vector (N samples by 1)
- E : array
expected value with respect to transfer model (N samples by D features)
- V : array
variance with respect to transfer model (D features by D features by N samples)
- l2 : float
regularization parameter (def: 0.0)
Returns: - dL : array
Value of loss function.
-
get_params
()¶ Get classifier parameters.
-
is_trained
()¶ Check whether classifier is trained.
-
mle_transfer_dist
(X, Z, dist='blankout')¶ Maximum likelihood estimation of transfer model parameters.
Parameters: - X : array
source data set (N samples by D features)
- Z : array
target data set (M samples by D features)
- dist : str
distribution of transfer model, options are ‘blankout’ or ‘dropout’ (def: ‘blankout’)
Returns: - iota : array
estimated transfer model parameters (D features by 1)
-
moments_transfer_model
(X, iota, dist='blankout')¶ Moments of the transfer model.
Parameters: - X : array
data set (N samples by D features)
- iota : array
transfer model parameters (D samples by 1)
- dist : str
transfer model, options are ‘dropout’ and ‘blankout’ (def: ‘blankout’)
Returns: - E : array
expected value of transfer model (N samples by D feautures)
- V : array
variance of transfer model (D features by D features by N samples)
-
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)
-