From 6e15342ca36e30c7d9f54d1c5da36ce80571939e Mon Sep 17 00:00:00 2001 From: Shawn Azman Date: Sun, 2 Nov 2025 21:14:08 +0000 Subject: [PATCH] UBS-2: Round probability displays to 3 decimal places in tree output - Modified base_perpendicular.py to round classification tree probabilities - Modified base_hyperplane.py to round classification tree probabilities - Wraps _compute_posterior_mean() with np.round(decimals=3) for better readability --- bayesian_decision_tree/base_hyperplane.py | 2 +- bayesian_decision_tree/base_perpendicular.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bayesian_decision_tree/base_hyperplane.py b/bayesian_decision_tree/base_hyperplane.py index 27e0f1d..e9d8c1b 100644 --- a/bayesian_decision_tree/base_hyperplane.py +++ b/bayesian_decision_tree/base_hyperplane.py @@ -174,7 +174,7 @@ def _str(self, anchor, VERT_RIGHT, DOWN_RIGHT, BAR, GEQ, is_back_child): if self.is_leaf(): s += 'y={}, n={}'.format(self._predict_leaf(), self.n_data_) if not self.is_regression: - s += ', p(y)={}'.format(self._compute_posterior_mean()) + s += ', p(y)={}'.format(np.round(self._compute_posterior_mean(), decimals=3)) else: s += 'HP(origin={}, normal={})'.format(self.best_hyperplane_origin_, self.best_hyperplane_normal_) diff --git a/bayesian_decision_tree/base_perpendicular.py b/bayesian_decision_tree/base_perpendicular.py index 84a8b7f..8edcfda 100644 --- a/bayesian_decision_tree/base_perpendicular.py +++ b/bayesian_decision_tree/base_perpendicular.py @@ -237,7 +237,7 @@ def _str(self, anchor, parent_split_value, VERT_RIGHT, DOWN_RIGHT, BAR, GEQ, is_ if self.is_leaf(): s += 'y={}, n={}'.format(self._predict_leaf(), self.n_data_) if not self.is_regression: - s += ', p(y)={}'.format(self._compute_posterior_mean()) + s += ', p(y)={}'.format(np.round(self._compute_posterior_mean(), decimals=3)) else: s += '{}={}'.format(self.split_feature_name_, self.split_value_)