Package: knnp 2.0.0

Daniel Bastarrica Lacalle

knnp: Time Series Prediction using K-Nearest Neighbors Algorithm (Parallel)

Two main functionalities are provided. One of them is predicting values with k-nearest neighbors algorithm and the other is optimizing the parameters k and d of the algorithm. These are carried out in parallel using multiple threads.

Authors:Daniel Bastarrica Lacalle [aut, cre], Javier Berdecio Trigueros [aut], Javier Arroyo Gallardo [aut], Albert Meco Alias [aut]

knnp_2.0.0.tar.gz
knnp_2.0.0.zip(r-4.5)knnp_2.0.0.zip(r-4.4)knnp_2.0.0.zip(r-4.3)
knnp_2.0.0.tgz(r-4.4-any)knnp_2.0.0.tgz(r-4.3-any)
knnp_2.0.0.tar.gz(r-4.5-noble)knnp_2.0.0.tar.gz(r-4.4-noble)
knnp_2.0.0.tgz(r-4.4-emscripten)knnp_2.0.0.tgz(r-4.3-emscripten)
knnp.pdf |knnp.html
knnp/json (API)
NEWS

# Install 'knnp' in R:
install.packages('knnp', repos = c('https://grasia.r-universe.dev', 'https://cloud.r-project.org'))

Peer review:

Bug tracker:https://github.com/grasia/knnp/issues

On CRAN:

knearest-neighbor-algorithmparalleltime-series-forecasting

2.70 score 1 stars 8 scripts 150 downloads 4 exports 52 dependencies

Last updated 5 years agofrom:cf16fd8a8b. Checks:OK: 1 ERROR: 6. Indexed: yes.

TargetResultDate
Doc / VignettesOKNov 13 2024
R-4.5-winERRORNov 13 2024
R-4.5-linuxERRORNov 13 2024
R-4.4-winERRORNov 13 2024
R-4.4-macERRORNov 13 2024
R-4.3-winERRORNov 13 2024
R-4.3-macERRORNov 13 2024

Exports:knnknn_forecastknn_param_searchknn_past

Dependencies:clicodetoolscolorspacecurldoParallelfansifarverforeachforecastfracdiffgenericsggplot2gluegtableisobanditeratorsjsonlitelabelinglatticelifecyclelmtestmagrittrMASSMatrixmgcvmunsellnlmennetparallelDistpillarpkgconfigplyrquadprogquantmodR6RColorBrewerRcppRcppArmadilloRcppParallelrlangscalestibbletimeDatetseriesTTRurcautf8vctrsviridisLitewithrxtszoo

Readme and manuals

Help Manual

Help pageTopics
Generic function to make a prediction for a time series. If a knn model is provided as the first argument, knn_forecast will be directly called. If single values are provided as k and d as no parameter search can be perfomed, knn_forecast will be called automatically. If no values are provided for k and/or d, values 1 to 50 will be used by default.knn
Creates a matrix to be used for calculating distances. The most recent 'element' is put in the first row of the matrix, the second most recent 'element' in the second row and so on. Therefore, the oldest 'element' is put in the last row.knn_elements
Predicts next value of the time series using k-nearest neighbors algorithm.knn_forecast
Searches for the optimal values of k and d for a given time series. First, values corresponding to instants from initial + 1 to the last one are predicted. The first value predicted, which corresponds to instant initial + 1, is calculated using instants from 1 to instant initial; the second value predicted, which corresponds to instant initial + 2, is predicted using instants from 1 to instant initial + 1; and so on until last value, which corresponds to instant n (length of the given time series), is predicted using instants from 1 to instant n - 1. Finally, the error is evaluated between the predicted values and the real values of the series. This version of the optimization function uses a parallelized distances calculation function, and the computation of the predicted values is done parallelizing by the number of d's.knn_param_search
Predicts values of the time series using k-nearest neighbors algorithm. Values corresponding to instants from initial + 1 to the last one are predicted. The first value predicted, which corresponds to instant initial + 1, is calculated using instants from 1 to instant initial; the second value predicted, which corresponds to instant initial + 2, is predicted using instants from 1 to instant initial + 1; and so on until the last value, which corresponds to instant n (length of the time series), is predicted using instants from 1 to instant n - 1.knn_past