Browse Source

Switching to enthropy

Loweel 4 years ago
parent
commit
1ced57cf8f
2 changed files with 8 additions and 2 deletions
  1. 6 1
      file.go
  2. 2 1
      matrix.go

+ 6 - 1
file.go

@@ -47,6 +47,11 @@ func saveBayesToFile() {
 		tmpJSON = []byte(err.Error())
 	}
 
+	statsJSON, err := json.MarshalIndent(Classifier.STATS, "", " ")
+	if err != nil {
+		statsJSON = []byte(err.Error())
+	}
+
 	dumpfile := os.Getenv("DUMPFILE")
 	if dumpfile == "" {
 		dumpfile = "bayes.json"
@@ -55,7 +60,7 @@ func saveBayesToFile() {
 	if DebugLog {
 		log.Println("DUMP: ", string(tmpJSON))
 	} else {
-		writeToFile(dumpfile, string(tmpJSON))
+		writeToFile(dumpfile, string(tmpJSON)+string(statsJSON))
 
 		log.Println("File saved: ", dumpfile)
 	}

+ 2 - 1
matrix.go

@@ -89,8 +89,9 @@ func (c *ByClassifier) IsGOOD(key string) {
 
 }
 
-//Posterior calculates the posterior probabilities in pseudo-bayes.
+//Posterior calculates Shannon based entropy using bad and good as different distributions
 func (c *ByClassifier) Posterior(hdr string) map[string]float64 {
+	
 
 	c.Matrix.busy.Lock()
 	defer c.Matrix.busy.Unlock()