i want to use the power of Kohonen package in knime. I used the iris data for example . for learner node i used this code
DF <- data.frame(a=R[1:4],stringsAsFactors = TRUE)
R<-xyf(data = x,Y=classvec2classmat(R$"class"),grid=somgrid(5,4,"hexagonal"))
for a predictor
R<-cbind(RDATA, predict(RMODEL, type="class")
but i found this error
package 'kohonen' was built under R version 2.13.2
> R<-cbind(RDATA, predict(RMODEL, type="class")
+ write.csv(R, "E:/tempknime/R-outDataTempFile-4552160382749656245.csv", row.names = TRUE);
Error: unexpected symbol in:
"R<-cbind(RDATA, predict(RMODEL, type="class")
Can anyone help me?
hm, there is a bracket missing.
R<-cbind(RDATA, predict(RMODEL, type="class"))
but i found this new error
Error in data.frame(prediction = c("Iris-setosa", "Iris-setosa", "Iris-setosa", :
arguments imply differing number of rows: 150, 20
Calls: cbind ... as.data.frame -> as.data.frame.list -> eval -> eval -> data.frame
i need to post the simple workflow or anyone found and overcome this error ?
thanks in adance for any help
there are two issues in your code:
First, you use diferent data for training the model and for making prediction, this is the same problem as described here:
Second, the R Predictor expects as output a vector of predicted values. The predict() method from kohonen package returns a more complicated object, which R Predictor cannot cast into vector. You have to extract predicted values by yourself.
The correct code for your R Predictor is:
DF <- data.frame(a=RDATA[1:4],stringsAsFactors = TRUE)
This should work.
Thanks for your help, but i found the errors in my code . and for overcome what you noted i partitioned the set in 50% train and test.
For the code :
In the learner
model <- xyf(scale(x),y,grid = somgrid(5, 5, "rectangular"),rlen=300)
Is extremly important to set factor,
for the predictor
this wokrs good, and the scorer node is about 93% of accurancy.
In my hand the R learner/predicrtor nodes works well. maybe you forgot to set the path for exe.
thnaks for your help