Baoqiang Cao
2005-Jul-22 16:18 UTC
[R] setting weights for such a two-class problem in nnet and svm
Dear All, I have such a two-class problem, one class is very large(~98% of total), and the other is just 2%. According to manual of nnet, I need setup "weights", so I intend to set 1 for class one, 49 for class 2. How do I do that? Just weights=49? Meanwhile I'd like to try svm(e1071), again, how do I setup "class.weights"? Thanks. BTW: Many thanks to Jake and Uwe for their answers about using "save" to store trained networks! Best regards, Baoqiang Cao
Prof Brian Ripley
2005-Jul-22 16:56 UTC
[R] setting weights for such a two-class problem in nnet and svm
On Fri, 22 Jul 2005, Baoqiang Cao wrote:> Dear All, > > I have such a two-class problem, one class is very large(~98% of total), > and the other is just 2%. According to manual of nnet, I need setup > "weights", so I intend to set 1 for class one, 49 for class 2. How do I > do that? Just weights=49?I do not know what you mean by `manual of nnet', but no, not that since the help page says weights: (case) weights for each example - if missing defaults to 1. More likely you want ifelse(class==1, 1/49, 1). However, there is more to it than that, and do please read the reference books on the help page. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
David Meyer
2005-Jul-24 17:57 UTC
[R] setting weights for such a two-class problem in nnet and svm
Dear Baoqiang, there is an example on the svm Help page on the use of 'class.weights'. HTH David ---------------- I have such a two-class problem, one class is very large(~98% of total), and the other is just 2%. According to manual of nnet, I need setup "weights", so I intend to set 1 for class one, 49 for class 2. How do I do that? Just weights=49? Meanwhile I'd like to try svm(e1071), again, how do I setup "class.weights"? Thanks. -- Dr. David Meyer Department of Information Systems and Operations Vienna University of Economics and Business Administration Augasse 2-6, A-1090 Wien, Austria, Europe Fax: +43-1-313 36x746 Tel: +43-1-313 36x4393 HP: http://wi.wu-wien.ac.at/~meyer/