KNN.multioutput: KNN.multioutput

View source: R/mstep.R

KNN.multioutputR Documentation

KNN.multioutput

Description

Multioutput KNN

Arguments

X:

training input [N,n]

Y:

training output [N,m]

X.ts:

test input [N.ts,n]

k:

min number of neighbours

dist:

type of distance: euclidean, cosine

F:

forgetting factor

C:

integer parameter which sets the maximum number of neighbours (Ck)

wta:

if TRUE a winner-takes-all strategy is used; otherwise a weigthed combination is done on the basis of the l-o-o error

Reg:

number (>1) of null terms to regularise the mean

Details

KNN.multioutput

Multioutput KNN which perform a locally constant model with weighted combination of local model on the basis of leave-one-out error. A tricube kernel is used to weight the distances.

Value

vector of N.ts predictions

Author(s)

Gianluca Bontempi Gianluca.Bontempi@ulb.be

References

Bontempi G. Ben Taieb S. Conditionally dependent strategies for multiple-step-ahead prediction in local learning, International Journal of Forecasting Volume 27, Issue 3, July–September 2011, Pages 689–699

https://tinyurl.com/sfmlh

Examples

## Multi-step ahead time series forecasting
require(gbcode)
t=seq(0,200,by=0.1)
N<-length(t)
H<-50 ## horizon prediction
TS<-sin(t)
TS.tr=TS[1:(N-H)]
N.tr<-length(TS.tr)
TS.ts<-TS[(N-H+1):N]
TS.tr=array(TS.tr,c(length(TS.tr),1))
E=MakeEmbedded(TS.tr,n=3,delay=0,hor=H,1)
X<-E$inp
Y<-E$out
N<-NROW(X)
Y.cont<-KNN.multioutput(X,Y,rev(TS.tr[(N.tr-H):N.tr]))
plot(t[(N-H+1):N],TS.ts)
lines(t[(N-H+1):N],Y.cont)

gbonte/gbcode documentation built on Feb. 27, 2024, 7:38 a.m.