Re: [R] [klaR package] [NaiveBayes] warning message numerical 0 probability
On 03.11.2010 16:26, Fabon Dzogang wrote: Hi, I run R 2.10.1 under ubuntu 10.04 LTS (Lucid Lynx) and klaR version 0.6-4. I compute a model over a 2 classes dataset (composed of 700 examples). To that aim, I use the function NaiveBayes provided in the package klaR. When I then use the prediction function : predict(my_model, new_data). I get the following warning : "In FUN(1:747[[747L]], ...) : Numerical 0 probability with observation 458" As I did not find any documentation or any discussion concerning this warning message, I looked in the klaR source code and found the following line in predict.NaiveBayes.R : "warning("Numerical 0 probability with observation ", i)" Within Naive Bayes in order to calculate the posteriori probabilities of the classes it is necessary to calculate the probabilities of the observations given the classes. The function NaiveBayes prints a warning if all these probabilities are numerical 0, i.e. that the observation has a numerical probability of 0 for *all* classes. Usually this is only the case when the obs. is an extreme outlier. I will change the warning to say "all classes" in further releases of klaR. Best wishes, Uwe Ligges Unfortunately, it is hard to get a clear picture of the whole process reading the code. I wonder if someone could help me with the meaning of this warning message. Sorry I did not provide an example, but I could not simulate the same message over a small toy example. Thank you, Fabon Dzogang. __ R-help@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. __ R-help@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.
Re: [R] [klaR package] [NaiveBayes] warning message numerical 0 probability
Thank you very much for this clarification, Sincerely, Fabon Dzogang. 2010/11/15 Uwe Ligges : > > > On 03.11.2010 16:26, Fabon Dzogang wrote: >> >> Hi, >> >> I run R 2.10.1 under ubuntu 10.04 LTS (Lucid Lynx) and klaR version 0.6-4. >> >> I compute a model over a 2 classes dataset (composed of 700 examples). >> To that aim, I use the function NaiveBayes provided in the package >> klaR. >> When I then use the prediction function : predict(my_model, new_data). >> I get the following warning : >> >> "In FUN(1:747[[747L]], ...) : Numerical 0 probability with observation >> 458" >> >> As I did not find any documentation or any discussion concerning this >> warning message, I looked in the klaR source code and found the >> following line in predict.NaiveBayes.R : >> >> "warning("Numerical 0 probability with observation ", i)" > > > Within Naive Bayes in order to calculate the posteriori probabilities of > the classes it is necessary to calculate the probabilities of the > observations given the classes. The function NaiveBayes prints a warning > if all these probabilities are numerical 0, i.e. that the observation > has a numerical probability of 0 for *all* classes. Usually this is only > the case when the obs. is an extreme outlier. > > I will change the warning to say "all classes" in further releases of klaR. > > Best wishes, > Uwe Ligges > > > >> Unfortunately, it is hard to get a clear picture of the whole process >> reading the code. I wonder if someone could help me with the meaning >> of this warning message. >> >> Sorry I did not provide an example, but I could not simulate the same >> message over a small toy example. >> >> Thank you, >> >> Fabon Dzogang. >> >> __ >> R-help@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. > -- Fabon Dzogang __ R-help@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.
Re: [R] [klaR package] [NaiveBayes] warning message numerical 0 probability
Uwe Ligges statistik.tu-dortmund.de> writes: > > > On 03.11.2010 16:26, Fabon Dzogang wrote: > > Hi, > > > > I run R 2.10.1 under ubuntu 10.04 LTS (Lucid Lynx) and klaR version 0.6-4. > > > > I compute a model over a 2 classes dataset (composed of 700 examples). > > To that aim, I use the function NaiveBayes provided in the package > > klaR. > > When I then use the prediction function : predict(my_model, new_data). > > I get the following warning : > > > > "In FUN(1:747[[747L]], ...) : Numerical 0 probability with observation 458" > > > > As I did not find any documentation or any discussion concerning this > > warning message, I looked in the klaR source code and found the > > following line in predict.NaiveBayes.R : > > > > "warning("Numerical 0 probability with observation ", i)" > > Within Naive Bayes in order to calculate the posteriori probabilities of > the classes it is necessary to calculate the probabilities of the > observations given the classes. The function NaiveBayes prints a warning > if all these probabilities are numerical 0, i.e. that the observation > has a numerical probability of 0 for *all* classes. Usually this is only > the case when the obs. is an extreme outlier. > > I will change the warning to say "all classes" in further releases of klaR. > > Best wishes, > Uwe Ligges > > > Unfortunately, it is hard to get a clear picture of the whole process > > reading the code. I wonder if someone could help me with the meaning > > of this warning message. > > > > Sorry I did not provide an example, but I could not simulate the same > > message over a small toy example. > > > > Thank you, > > > > Fabon Dzogang. > > > > __ > > R-help 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. > > Hello, I am following this thread after it's one year old! I am also getting the warnings for probabilities=0, but for ALL observations! I am using NaiveBayes() to obtain the posteriors of all training examples (29 classes; 49 numeric continuous variables, 700 examples), thus the command: my.model <-NaiveBayes(class ~ ., data = data, usekernel = TRUE) predict(my.model) as expected, it returns predicted classes and a matrix of posteriors for each training examples, BUT with this warning for ALL training examples. Still the accuracy is ~60% and is within expectation. Please give some comments, Is this possible?? Should I ignore the warnings?? The posteriors returned look like this: Class1 class2class3class4 ... 1 6.725408e-58 0.6 4.277379e-09 2.923033e-90 2 4.443767e-48 0.997316780 2.683220e-03 1.710466e-75 3 3.348223e-40 0.93916 6.799327e-08 6.760083e-81 ... ... Sorry I am replying via the Gmane interface and cannot attach my dataset. But I am starting to follow this mailing list now, so may be able to reply with attachments to the next message. grateful for any comments! Ted Chang __ R-help@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.
Re: [R] [klaR package] [NaiveBayes] warning message numerical 0 probability
On 10.11.2011 09:00, Ted Chang wrote: Uwe Ligges statistik.tu-dortmund.de> writes: On 03.11.2010 16:26, Fabon Dzogang wrote: Hi, I run R 2.10.1 under ubuntu 10.04 LTS (Lucid Lynx) and klaR version 0.6-4. I compute a model over a 2 classes dataset (composed of 700 examples). To that aim, I use the function NaiveBayes provided in the package klaR. When I then use the prediction function : predict(my_model, new_data). I get the following warning : "In FUN(1:747[[747L]], ...) : Numerical 0 probability with observation 458" As I did not find any documentation or any discussion concerning this warning message, I looked in the klaR source code and found the following line in predict.NaiveBayes.R : "warning("Numerical 0 probability with observation ", i)" Within Naive Bayes in order to calculate the posteriori probabilities of the classes it is necessary to calculate the probabilities of the observations given the classes. The function NaiveBayes prints a warning if all these probabilities are numerical 0, i.e. that the observation has a numerical probability of 0 for *all* classes. Usually this is only the case when the obs. is an extreme outlier. I will change the warning to say "all classes" in further releases of klaR. Best wishes, Uwe Ligges Unfortunately, it is hard to get a clear picture of the whole process reading the code. I wonder if someone could help me with the meaning of this warning message. Sorry I did not provide an example, but I could not simulate the same message over a small toy example. Thank you, Fabon Dzogang. __ R-help 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. Hello, I am following this thread after it's one year old! I am also getting the warnings for probabilities=0, but for ALL observations! I am using NaiveBayes() to obtain the posteriors of all training examples (29 classes; 49 numeric continuous variables, 700 examples), thus the command: my.model<-NaiveBayes(class ~ ., data = data, usekernel = TRUE) Please send data and code (if the above is not all the code) to me privately. I'll take a look. Best, Uwe Ligges predict(my.model) as expected, it returns predicted classes and a matrix of posteriors for each training examples, BUT with this warning for ALL training examples. Still the accuracy is ~60% and is within expectation. Please give some comments, Is this possible?? Should I ignore the warnings?? The posteriors returned look like this: Class1 class2class3class4 ... 1 6.725408e-58 0.6 4.277379e-09 2.923033e-90 2 4.443767e-48 0.997316780 2.683220e-03 1.710466e-75 3 3.348223e-40 0.93916 6.799327e-08 6.760083e-81 ... ... Sorry I am replying via the Gmane interface and cannot attach my dataset. But I am starting to follow this mailing list now, so may be able to reply with attachments to the next message. grateful for any comments! Ted Chang __ R-help@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. __ R-help@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.