pmm | R Documentation |
For each value in the prediction vector xtest
, one of the closest k
values in the prediction vector xtrain
is randomly chosen and its observed
value in ytrain
is returned.
pmm(xtrain, xtest, ytrain, k = 1L, seed = NULL)
xtrain |
Vector with predicted values in the training data. Can be of type logical, numeric, character, or factor. |
xtest |
Vector as |
ytrain |
Vector of the observed values in the training data. Must be of same
length as |
k |
Number of nearest neighbours to sample from. |
seed |
Integer random seed. |
Vector of the same length as xtest
with values from xtrain
.
pmm(xtrain = c(0.2, 0.2, 0.8), xtest = 0.3, ytrain = c(0, 0, 1)) # 0
pmm(xtrain = c(TRUE, FALSE, TRUE), xtest = FALSE, ytrain = c(2, 0, 1)) # 0
pmm(xtrain = c(0.2, 0.8), xtest = 0.3, ytrain = c("A", "B"), k = 2) # "A" or "B"
pmm(xtrain = c("A", "A", "B"), xtest = "A", ytrain = c(2, 2, 4), k = 2) # 2
pmm(xtrain = factor(c("A", "B")), xtest = factor("C"), ytrain = 1:2) # 2
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.