[R] neural net

PIKAL Petr petr.pikal at precheza.cz
Thu Dec 13 08:16:58 CET 2012


Hi

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of dada
> Sent: Thursday, December 13, 2012 12:41 AM
> To: r-help at r-project.org
> Subject: [R] neural net
> 
> Hi
> I would like to do neural netowrk analysis on my data. It look like
> this:
> 
> drug	param1	param2	param3	param4	param5	class
> A	111	15	125	40	0.5	1
> B	347	13	280	55	3	2
> C	335	9	119	89	-40	1
> D	477	37	75	2	0	1
> E	863	24	180	10	5	2
> F	737	28	150	15	6	2
> G	390	63	167	12	0	3
> H	209	93	200	48	45	3
> I	376	72	201	45	-60	3
> J 	262	16	205	49	25	3
> K	273	39	267	53	11	1
> L	192	33	164	19	15	2
> M	282	2	213	86	30	1
> N	111	11	198	68	-21	1
> O	387	20	143	12	16	2
> P	674	15	78	-20	-17	2
> R	734	54	140	24	7	2
> S	272	46	159	57	28	2
> T	245	37	90	6	31	2
> 
> I have entered the code below:
> > nn <- neuralnet(
> + class~param1+param2+param3+param4+param5+param5,
> + data=mydata, hidden=2, err.fct="ce",
> + linear.output=FALSE)
> 
> However the error appeared:
> Error in model.frame.default(formula.reverse, data) :
>   object is not a matrix
> 
> I changed the data frame to matrix:
> mydata.mat=as.matrix(mydata)

This is not very wise. It changes all numeric values to character. From documentation and your data frame there is nothing obviously wrong. However you did not provide info about structure of your data something like 

summary(mydata) or str(mydata).

Documentation does not say much about how neuralnet reacts e.g. on NA values. The best way how to proceed seems to try recommended data and compare them to your data to see where are the differences.

Or you can read sources to see where the error message originates.

Regards
Petr

> 
> but still the same error appears...
> 
> How can I fix this ? I would be very grateful for your help  !
> 
> 
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/neural-net-
> tp4652927.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> 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.




More information about the R-help mailing list