tc
Class TCNaiveBayesResult

java.lang.Object
  extended bytc.TCNaiveBayesResult
All Implemented Interfaces:
java.io.Serializable

public class TCNaiveBayesResult
extends java.lang.Object
implements java.io.Serializable

this class holds the result of a naive bayes classification for ONE document "probability" in this context is always the probability that the document was "created" by the category

See Also:
Serialized Form

Nested Class Summary
(package private)  class TCNaiveBayesResult.TCBayesCategoryListElement
          holds the scores, probabilities etc.
 
Field Summary
(package private)  java.util.ArrayList bayesResults
          holds the TCBayesCategoryListElements for every category
(package private)  int testDocumentIndex
          the test document index, if the result if used for a test document
 
Constructor Summary
(package private) TCNaiveBayesResult(int index)
          constructor of a result class for a naive bayes category ranking
 
Method Summary
 void addBayesCategoryResult(java.lang.String categoryLabel, double probability)
          adds a result for one category.
 java.lang.String getCategoryLabelWithRank(int rank)
          returns the category label with rank "rank".
 int getFirstRankWithScoreSmallerThan(double pr)
          method to determine a variable threshold for RCut
 double getProbabilityForCategory(java.lang.String clabel)
          returns the probability for the category with label "clabel"
 double getProbabilityOfCategoryWithRank(int rank)
          returns the probability of the category with rank "rank"
 boolean isLabeledAs(java.lang.String label, int rankThreshold)
          checks, if the given label "label" was assigned to the document from the naive bayes classifier, given the rankThreshold (the first rank whose threshold was lower than the threshold for the classifier)
 void normalize(double nf)
          normalizes the probabilities (so that the probabilities that the document was created by the category is <= P(C_i))
 void sort()
          sorts the arraylist containing the results for all categories according to their probabilities that the document was created by this category (highest value gets index 0 and so on)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

testDocumentIndex

int testDocumentIndex
the test document index, if the result if used for a test document


bayesResults

java.util.ArrayList bayesResults
holds the TCBayesCategoryListElements for every category

Constructor Detail

TCNaiveBayesResult

TCNaiveBayesResult(int index)
constructor of a result class for a naive bayes category ranking

Method Detail

addBayesCategoryResult

public void addBayesCategoryResult(java.lang.String categoryLabel,
                                   double probability)
adds a result for one category.

Parameters:
categoryLabel - the label of the category
probability - the probability that the document this instance belongs to was created by the category which is added

normalize

public void normalize(double nf)
normalizes the probabilities (so that the probabilities that the document was created by the category is <= P(C_i))

Parameters:
nf -

sort

public void sort()
sorts the arraylist containing the results for all categories according to their probabilities that the document was created by this category (highest value gets index 0 and so on)


getCategoryLabelWithRank

public java.lang.String getCategoryLabelWithRank(int rank)
returns the category label with rank "rank". Should be called AFTER the arraylit has been sorted

Parameters:
rank - the rank of the category
Returns:
the label of the category with rank "rank"

getProbabilityForCategory

public double getProbabilityForCategory(java.lang.String clabel)
returns the probability for the category with label "clabel"

Parameters:
clabel - the label of the category
Returns:

getProbabilityOfCategoryWithRank

public double getProbabilityOfCategoryWithRank(int rank)
returns the probability of the category with rank "rank"

Parameters:
rank - the rank of the category
Returns:
the probability

getFirstRankWithScoreSmallerThan

public int getFirstRankWithScoreSmallerThan(double pr)
method to determine a variable threshold for RCut

Parameters:
pr - the probability threshold
Returns:

isLabeledAs

public boolean isLabeledAs(java.lang.String label,
                           int rankThreshold)
checks, if the given label "label" was assigned to the document from the naive bayes classifier, given the rankThreshold (the first rank whose threshold was lower than the threshold for the classifier)

Parameters:
label - the label of the category
rankThreshold - the rank threshold
Returns:
true, if the document was classified into the category with label "label"