knn |
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_elements |
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_forecast |
Predicts next value of the time series using k-nearest neighbors algorithm. |
knn_param_search |
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_past |
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. |