Browse Source

Adding stats to the file + better probs

Loweel 4 years ago
parent
commit
174d4b005e
1 changed files with 8 additions and 8 deletions
  1. 8 8
      matrix.go

+ 8 - 8
matrix.go

@@ -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))
-
-}