Description Usage Arguments Details Value Author(s) Examples
Interfaces to kknn
functions that can be used
in a pipeline implemented by magrittr
.
1 2 3 |
data |
data frame, tibble, list, ... |
... |
Other arguments passed to the corresponding interfaced function. |
Interfaces call their corresponding interfaced function.
Object returned by interfaced function.
Roberto Bertolusso
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | ## Not run:
library(intubate)
library(magrittr)
library(kknn)
## ntbt_train.kknn: Training kknn
## ntbt_cv.kknn:
data(miete)
## Original function to interface
train.kknn(nmqm ~ wfl + bjkat + zh, data = miete,
kmax = 25, kernel = c("rectangular", "triangular", "epanechnikov",
"gaussian", "rank", "optimal"))
cv.kknn(nmqm ~ wfl + bjkat + zh, data = miete)
## The interface puts data as first parameter
ntbt_train.kknn(miete, nmqm ~ wfl + bjkat + zh,
kmax = 25, kernel = c("rectangular", "triangular", "epanechnikov",
"gaussian", "rank", "optimal"))
ntbt_cv.kknn(miete, nmqm ~ wfl + bjkat + zh)
## so it can be used easily in a pipeline.
miete %>%
ntbt_train.kknn(nmqm ~ wfl + bjkat + zh,
kmax = 25, kernel = c("rectangular", "triangular", "epanechnikov",
"gaussian", "rank", "optimal"))
miete %>%
ntbt_cv.kknn(nmqm ~ wfl + bjkat + zh)
## ntbt_kknn: Weighted k-Nearest Neighbor Classifier
m <- dim(iris)[1]
val <- sample(1:m, size = round(m/3), replace = FALSE, prob = rep(1/m, m))
iris.learn <- iris[-val,]
iris.valid <- iris[val,]
## Original function to interface
kknn(Species ~ ., iris.learn, iris.valid, distance = 1, kernel = "triangular")
## The interface puts data as first parameter
ntbt_kknn(iris.learn, Species ~ ., iris.valid, distance = 1, kernel = "triangular")
## so it can be used easily in a pipeline.
iris.learn %>%
ntbt_kknn(Species ~ ., iris.valid, distance = 1, kernel = "triangular")
## NOTE: there is (in your face) cheating! We should be able to supply
## both iris.learn and iris.valid. It should be possible with intuBags.
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.