kmm | R Documentation |
Kernel mean matching approach to density ratio estimation
kmm(
df_numerator,
df_denominator,
scale = "numerator",
constrained = FALSE,
nsigma = 10,
sigma_quantile = NULL,
sigma = NULL,
ncenters = 200,
centers = NULL,
cv = TRUE,
nfold = 5,
parallel = FALSE,
nthreads = NULL,
progressbar = TRUE,
osqp_settings = NULL,
cluster = NULL
)
df_numerator |
|
df_denominator |
|
scale |
|
constrained |
|
nsigma |
Integer indicating the number of sigma values (bandwidth parameter of the Gaussian kernel gram matrix) to use in cross-validation. |
sigma_quantile |
|
sigma |
|
ncenters |
Maximum number of Gaussian centers in the kernel gram matrix. Defaults to all numerator samples. |
centers |
Option to specify the Gaussian samples manually. |
cv |
Logical indicating whether or not to do cross-validation |
nfold |
Number of cross-validation folds used in order to calculate the
optimal |
parallel |
logical indicating whether to use parallel processing in the cross-validation scheme. |
nthreads |
|
progressbar |
Logical indicating whether or not to display a progressbar. |
osqp_settings |
Optional: settings to pass to the |
cluster |
Optional: a cluster object to use for parallel processing,
see |
kmm
-object, containing all information to calculate the
density ratio using optimal sigma and optimal weights.
Huang, J., Smola, A. J., Gretton, A., Borgwardt, K. M., & Schölkopf, B. (2006). Correcting sample selection bias by unlabeled data. In Advances in Neural Information Processing Systems, edited by B. Schölkopf, J. Platt and T. Hoffman. Available from https://proceedings.neurips.cc/paper/2006/hash/a2186aa7c086b46ad4e8bf81e2a3a19b-Abstract.html.
set.seed(123)
# Fit model
dr <- kmm(numerator_small, denominator_small)
# Inspect model object
dr
# Obtain summary of model object
summary(dr)
# Plot model object
plot(dr)
# Plot density ratio for each variable individually
plot_univariate(dr)
# Plot density ratio for each pair of variables
plot_bivariate(dr)
# Predict density ratio and inspect first 6 predictions
head(predict(dr))
# Fit model with custom parameters
kmm(numerator_small, denominator_small,
nsigma = 5, ncenters = 100, nfold = 10,
constrained = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.