Skip to content
Back to formatted view

Raw Message

Message-ID: <61B1A61B4F4AD711B3450008C791F6FA01BA1FF0@clearwater.unn.ac.uk>
Date: 2004-02-23T12:49:19Z
From: Qin Liu
Subject: outputs of KNN prediction

Hello there:

I got 13 variables in my training/target set, the first 12 variables are
mixture of numerical and categorical variables. The last one is the one I
need
to predict, and it is a numerical variable.

>train<-read.table("train.txt")
>test<-read.table("test.txt")
>cl<-factor(train[,13])
>pred<-knn(train, test, clk=3, prob=TRUE)
>pred
I got output on the screen as following

 8.10832229  8.831127635 7.592870288 8.521782644 6.376726948 6.914730893
 9.71534911  8.658171785 6.104793232 7.247080585 6.298949247 5.105945474
 7.508238775 7.65396918  8.831127635 7.912056888 6.381816017 7.211556733

 276 levels ............

Then I tried to calculate a formula:(actual-pred)/actual, which includes
pred
values. However, I cannot do this even I convert the factors in pred to
vectors. Can anybody help??

Thank you very much indeed,

Qin