From d7425e5af03263b1cce155f2eae03f3ff86cddc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Montan=CC=83ana?= Date: Fri, 23 Jun 2023 01:25:23 +0200 Subject: [PATCH] Remove unneeded small value added to logs --- bayesclass/FeatureSelect.cpp | 5 ++--- bayesclass/FeatureSelect.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/bayesclass/FeatureSelect.cpp b/bayesclass/FeatureSelect.cpp index ba8db68..e85875a 100644 --- a/bayesclass/FeatureSelect.cpp +++ b/bayesclass/FeatureSelect.cpp @@ -100,11 +100,10 @@ namespace features { for (auto& [label, jointCount] : jointCounts[feat]) { auto p_l_f = jointCount / count; if (p_l_f > 0) { - double epsilon = 1e-9; if (nat) - entropy_f -= p_l_f * log(p_l_f + epsilon); + entropy_f -= p_l_f * log(p_l_f); else - entropy_f -= p_l_f * log2(p_l_f + epsilon); + entropy_f -= p_l_f * log2(p_l_f); } } entropy += p_f * entropy_f; diff --git a/bayesclass/FeatureSelect.h b/bayesclass/FeatureSelect.h index 78a22a1..8737065 100644 --- a/bayesclass/FeatureSelect.h +++ b/bayesclass/FeatureSelect.h @@ -5,7 +5,7 @@ #include using namespace std; namespace features { - typedef double precision_t; + typedef float precision_t; typedef int value_t; typedef vector sample_t; typedef vector samples_t;