ts_knn {daltoolbox} | R Documentation |
knn time series prediction
Description
Creates a prediction object that uses the K-Nearest Neighbors (knn) method for time series regression
Usage
ts_knn(preprocess = NA, input_size = NA, k = NA)
Arguments
preprocess |
normalization |
input_size |
input size for machine learning model |
k |
number of k neighbors |
Value
a ts_knn
object.
Examples
data(sin_data)
ts <- ts_data(sin_data$y, 10)
ts_head(ts, 3)
samp <- ts_sample(ts, test_size = 5)
io_train <- ts_projection(samp$train)
io_test <- ts_projection(samp$test)
model <- ts_knn(ts_norm_gminmax(), input_size=4, k=3)
model <- fit(model, x=io_train$input, y=io_train$output)
prediction <- predict(model, x=io_test$input[1,], steps_ahead=5)
prediction <- as.vector(prediction)
output <- as.vector(io_test$output)
ev_test <- evaluate(model, output, prediction)
ev_test
[Package daltoolbox version 1.0.767 Index]