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.el...@yahoo.de wrote:
Hi Kimmo,
Thanks for your reply, Here is a part of my df:
'data.frame': 562 obs. of 128 variables
$ TE :int 37 37 35 34 37 37 35 33 32 ...
$ TR :int 11 11 8 13 11 8 15 12 8 .....
$ BW :int 150 191 128 145 200 191 ........
$speed :int 4 4 3 3 2 1 4 1 2 3 ..........
and I want to cluster my data based on speed, to see the coming costumer's
protocols fall into which speed group and I think I need to bring this speed
column in Y element of xyf
On Thursday, June 16, 2016 2:29 PM, K. Elo <mailli...@pp.inet.fi> wrote:
Hi!
Some sample data could help us to help you...
But have you read '?xyf' in order to ensure that your 'Y' is what 'xyf'
expects it to be?
What kind of error messages do you get?
Regards,
Kimmo
16.06.2016, 15:13, ch.elahe via R-help wrote:
Is there any answer?
Hi all, I have a df and I want to use supervised Self Organizing Map
to do classification. I should use Kohonen library and xyf function
from it. As you know the xyf function looks like this and I have
problem defining my Y:
xyf(data,Y,grid=somgrid(),rlen=100,alpha=c(0.05,0.01)) I want to do
classification based on a column which shows the speed that a
protocols is run, and this column is the following:
$speed :num 4 4 3 3 3 1 1 1 2 1 4 4 3 numbers from 1 to 4 show the
speed from very fast to very slow protocols. so the property I want
to be modeled is df$speed, but I don't know how should I bring it in
xyf function. Does anyone know how to do that? I also added my train
set ans test set:
dt=sort(sample(nrow(df),nrow(df)*.7)) train=df[dt,]
Xtraining=scale(trian) Xtest=scale(-trian)
center=attr(Xtrianing,"scaled:center")
scale=attr(Xtraining,"scaled:scale")
xyf(Xtraining,........,grid=somgrid(10,10,"hexagonal"))
Thanks for any Help, Elahe
______________________________________________ R-help@r-project.org
mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the
posting guide http://www.R-project.org/posting-guide.html and provide
commented, minimal, self-contained, reproducible code.
______________________________________________ R-help@r-project.org
mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the
posting guide http://www.R-project.org/posting-guide.html and provide
commented, minimal, self-contained, reproducible code.
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.