RE: [Classifier4j-devel] RE: Fwd: calculateOverallProbability Que stio ns
Status: Beta
Brought to you by:
nicklothian
|
From: Nick L. <nl...@es...> - 2004-09-09 23:16:00
|
If that works better for you, then do it.
I'd suggest something like (untested!):
public class YourClassifier extends BayesianClassifier {
protected double calculateOverallProbability(WordProbability[] wps)
{
if (wps == null || wps.length == 0) {
return IClassifier.NEUTRAL_PROBABILITY;
} else {
return
super.calculateOverallProbability(WordProbability[] wps);
}
}
}
The classifier heirachy is designed to be extended like that.
Nick
> -----Original Message-----
> From: David Spencer [mailto:dav...@ya...]
> Sent: Friday, 10 September 2004 4:29 AM
> To: cla...@li...
> Subject: [Classifier4j-devel] RE: Fwd: calculateOverallProbability
> Questio ns
> Importance: Low
>
>
> I just stumbled across this thread from last year:
>
> http://sourceforge.net/mailarchive/forum.php?thread_id=3483166
> &forum_id=34026
>
> I'm having similar "troubles" in the sense that classify() is
> returning
> 0.99 too often and it's because some of the words either have zero
> matches or zero non-matches.
>
> The question is, does it make sense to ignore words that don't have at
> least 1 match and at least 1 non-match?
>
> It's easy enough to extend BayesianClassifier and override
> calculateOverallProbability() and in my experiment it seems to work
> "better", though I guess you could argue it's not fair to ignore such
> words, as maybe a given word will always be a match or non-match such
> it should be considered somehow.
>
> Anyway the code mode I did was at the bottom here of this fragment -
> just added 2 lines:
>
> protected double
> calculateOverallProbability(WordProbability[] wps)
> {
> if (wps == null || wps.length == 0)
> {
> return IClassifier.NEUTRAL_PROBABILITY;
> }
> else
> {
> // we need to calculate xy/(xy + z)
> // where z = (1-x)(1-y)
>
> // firstly, calculate z and xy
> double z = 0d;
> double xy = 0d;
> for (int i = 0; i < wps.length; i++)
> {
> // dss begin
> if ( wps[ i].getMatchingCount()
> == 0) continue;
> if ( wps[
> i].getNonMatchingCount() == 0) continue;
> // dss end
> ...
>
>
>
>
>
> =====
>
>
>
>
> _______________________________
> Do you Yahoo!?
> Shop for Back-to-School deals on Yahoo! Shopping.
> http://shopping.yahoo.com/backtoschool
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
> Project Admins to receive an Apple iPod Mini FREE for your
> judgement on
> who ports your project to Linux PPC the best. Sponsored by IBM.
> Deadline: Sept. 13. Go here: http://sf.net/ppc_contest.php
> _______________________________________________
> Classifier4j-devel mailing list
> Cla...@li...
> https://lists.sourceforge.net/lists/listinfo/classifier4j-devel
>
>
|