Skip to content
Prev 361803 / 398506 Next

Y in Kohonen xyf function

Hi again!

According to '?xyf', the function is expecting following parameters:

(1) data = a matrix, with each row representing an object.

So, please ensure that your data is a matrix

(2) Y = property that is to be modelled. In case of classification, Y is 
a matrix of zeros, with exactly one '1' in each row indicating the 
class. For prediction of continuous properties, Y is a vector. A 
combination is possible, too, but one then should take care of 
appropriate scaling.

Once again, no data frame here, but a scaled vector or a matrix.

Your could try following steps (I assume 'df' to be you data frame):

--- snip ---
set.seed(7)
training <- sample(nrow(df), 120)
Xtraining <- scale(df[training,])
Xtest <- scale(df[-training,],
                center = attr(Xtraining, "scaled:center"),
                scale = attr(Xtraining, "scaled:scale"))

xyf.df <- xyf(Xtraining,
               factor(df.classes[training]),
               grid = somgrid(5, 5, "hexagonal"))

--- snip ---

Let us know - with output, please - what happens. The point is, if this 
works, then you could try in experimenting the parameter 
'factor(df.classes[training]'. It seems to, that also here you need a 
matrix or a list as a base, not a data frame.

This might also be of interest for your: 
https://www.jstatsoft.org/article/view/v021i05/v21i05.pdf

HTH,
Kimmo
16.06.2016, 17:30, chalabi.elahe at yahoo.de wrote: