|
@@ -124,8 +124,14 @@ func (c *ByClassifier) Posterior(hdr string) map[string]float64 {
|
|
|
hBadM = math.Log2(lenTokens) - (hBadM / lenTokens)
|
|
|
hGoodM = math.Log2(lenTokens) - (hGoodM / lenTokens)
|
|
|
|
|
|
- ff["BAD"] = sigmoid(-hBadM)
|
|
|
- ff["GOOD"] = sigmoid(-hGoodM)
|
|
|
+ maxScore := math.Abs(hBadM) + math.Abs(hGoodM)
|
|
|
+
|
|
|
+ if maxScore == 0 {
|
|
|
+ maxScore = 1
|
|
|
+ }
|
|
|
+
|
|
|
+ ff["BAD"] = math.Abs(hBadM) / maxScore
|
|
|
+ ff["GOOD"] = math.Abs(hGoodM) / maxScore
|
|
|
|
|
|
log.Println("Entropies: ", ff)
|
|
|
|
|
@@ -211,9 +217,3 @@ func (c *ByClassifier) readInitList(filePath, class string) {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-
|
|
|
-func sigmoid(x float64) float64 {
|
|
|
-
|
|
|
- return 1.0 / (1.0 + math.Exp(-x))
|
|
|
-
|
|
|
-}
|