Skip to content

Commit

Permalink
if the classifier has not been trained yet, there is no category the …
Browse files Browse the repository at this point in the history
…classifier can use to classify
  • Loading branch information
ptnplanet committed Mar 11, 2012
1 parent fd3577c commit 6703a0c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion BayesClassifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ public int compare(Entry<K, Float> o1, Entry<K, Float> o2) {
public K classify(Collection<T> features) {
SortedSet<Entry<K, Float>> probabilites =
this.categoryProbabilities(features);
return probabilites.last().getKey();
if (probabilites.size() > 0)
return probabilites.last().getKey();
return null;
}

}

0 comments on commit 6703a0c

Please sign in to comment.