de.fu_berlin.ties.demo
Class FilterResult

java.lang.Object
  extended by de.fu_berlin.ties.demo.FilterResult

public class FilterResult
extends Object

Instances of this class contain detailed filtering results with additional debugging information. This class supports only the Winnow classifier and subclasses.

Version:
$Revision: 1.14 $, $Date: 2006/10/21 16:04:09 $, $Author: siefkes $
Author:
Christian Siefkes

Constructor Summary
FilterResult(PredictionDistribution myPredDist, String myText, TokenizingExtractor extractor, Map<String,List<Float>> myFeatureWeights)
          Creates a new instance.
 
Method Summary
 float getNonspamScore()
          Returns the normalized score for the nonspam class.
 String getPredictedClass()
          Returns the predicted class: "spam" or "nonspam".
 double getProbability()
          Returns the probability of the most likely class.
 float getSpamScore()
          Returns the normalized score for the spam class.
 String toString()
          Returns a string representation of this object.
 void writeBodyAttribute(Writer writer)
          Writes attribute name=value pairs that must be inserted into the opening <body ...
 void writeHTMLHead(Writer writer)
          Writes HTML code that must be inserted into the contents of the <head> element of a HTML file containing the output of the writeVizualization(Writer) method.
 void writeTestHTML(Writer writer)
          Writes a simple but complete HTML file that combines the output of of the writeHTMLHead(Writer), writeBodyAttribute(Writer) and writeVizualization(Writer) methods.
 void writeVizualization(Writer writer)
          Writes an HTML fragment that contains a vizualization of the classified mail (showing which features have been most important for classification etc.).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FilterResult

public FilterResult(PredictionDistribution myPredDist,
                    String myText,
                    TokenizingExtractor extractor,
                    Map<String,List<Float>> myFeatureWeights)
Creates a new instance.

Parameters:
myPredDist - the prediction distribution wrapped by this instance
myText - the filtered text
extractor - the feature extractor used to tokenize text sequences -- will be synchronized on itself
myFeatureWeights - a mapping from feature representation to weights arrays, as returned by the Winnow.showFeatureWeights(de.fu_berlin.ties.classify.feature.FeatureVector) method
Method Detail

getPredictedClass

public String getPredictedClass()
Returns the predicted class: "spam" or "nonspam".

Returns:
the predicted class

getProbability

public double getProbability()
Returns the probability of the most likely class.

Returns:
the probability of the predicted class, a number in the in range from 0.0 to 1.0

getNonspamScore

public float getNonspamScore()
Returns the normalized score for the nonspam class. "Good" scores are > 1, "bad" scores are in the ]0, 1[ rande and 1.0 means "don't know".

Returns:
the score for the nonspam class

getSpamScore

public float getSpamScore()
Returns the normalized score for the spam class. "Good" scores are > 1, "bad" scores are in the ]0, 1[ rande and 1.0 means "don't know".

Returns:
the score for the spam class

toString

public String toString()
Returns a string representation of this object.

Overrides:
toString in class Object
Returns:
a textual representation

writeBodyAttribute

public void writeBodyAttribute(Writer writer)
                        throws IOException
Writes attribute name=value pairs that must be inserted into the opening <body ...> tag of a HTML file containing the output of the writeVizualization(Writer) method. These attribute ("onload" and "onkeydown") are necessary for initialization the JavaScript code used for vizualation.

Parameters:
writer - writer to append the HTML code to; neither flushed nor closed by this method
Throws:
IOException - if an I/O error occurs while writing

writeHTMLHead

public void writeHTMLHead(Writer writer)
                   throws IOException
Writes HTML code that must be inserted into the contents of the <head> element of a HTML file containing the output of the writeVizualization(Writer) method.

Parameters:
writer - writer to append the HTML code to; neither flushed nor closed by this method
Throws:
IOException - if an I/O error occurs while writing

writeTestHTML

public void writeTestHTML(Writer writer)
                   throws IOException
Writes a simple but complete HTML file that combines the output of of the writeHTMLHead(Writer), writeBodyAttribute(Writer) and writeVizualization(Writer) methods.

This method is implemented as followings:

   writer.write("<html><head>");
   writeHTMLHead(writer);
   writer.write("</head><body ");
   writeBodyAttribute(writer);
   writer.write(">");
   writeVizualization(writer);
   writer.write("</body></html>\n");
   writer.flush();
 

Parameters:
writer - writer to writer the HTML file to; flushed but not closed by this method
Throws:
IOException - if an I/O error occurs while writing

writeVizualization

public void writeVizualization(Writer writer)
                        throws IOException
Writes an HTML fragment that contains a vizualization of the classified mail (showing which features have been most important for classification etc.). Note that you must insert the output of the writeHTMLHead(Writer) method into the contents of the <head> element and the output of the writeBodyAttribute(Writer) method into the opening <body ...> tag of the HTML file prior to calling this method or the Dynamic HTML code generated by this method will not work at all.

Parameters:
writer - writer to append the HTML code to; neither flushed nor closed by this method
Throws:
IOException - if an I/O error occurs while writing


Copyright © 2003-2007 Christian Siefkes. All Rights Reserved.