Skip to content

Commit

Permalink
bug fix for smoothing
Browse files Browse the repository at this point in the history
  • Loading branch information
dimus committed Jun 14, 2018
1 parent bc9d9fa commit e966c1e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,14 @@ func likelihood(nb *NaiveBayes, feature Featurer, label Labeler) float64 {
countFeature := nb.FeatureFreq[name][value][label]

countRest := (nb.FeatureTotal[name][value] - countFeature)
pFeature := countFeature / nb.LabelFreq[label]

// crude smoothing
if countFeature == 0 {
countFeature = smooth
}

pFeature := countFeature / nb.LabelFreq[label]

if countRest == 0 {
countRest = smooth
}
Expand Down

0 comments on commit e966c1e

Please sign in to comment.