Skip to content

Commit

Permalink
Consolidate and use the same function
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Li <[email protected]>
  • Loading branch information
adam2392 committed Nov 6, 2023
1 parent 895107e commit aadb185
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .spin/cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def setup_submodule(forcesubmodule=False):
def build(ctx, meson_args, jobs=None, clean=False, forcesubmodule=False, verbose=False):
"""Build scikit-tree using submodules.
git submodule update --recursive --remote
git submodule update --recursive --remote
To update submodule wrt latest commits:
Expand Down
12 changes: 4 additions & 8 deletions sktree/tests/test_honest_forest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import numpy as np
import pytest
from numpy.testing import assert_allclose, assert_array_almost_equal
from scipy.stats import entropy
from sklearn import datasets
from sklearn.metrics import accuracy_score, r2_score, roc_auc_score
from sklearn.model_selection import cross_val_score
Expand Down Expand Up @@ -358,16 +357,13 @@ def test_honest_forest_with_sklearn_trees_with_mi():
Forest.fit(X, y)

# compute MI
_, counts = np.unique(y, return_counts=True)
H_Y = entropy(counts, base=np.exp(1))

# _, counts = np.unique(y, return_counts=True)
# H_Y = entropy(counts, base=np.exp(1))
sk_posterior = skForest.predict_proba(X)
H_YX = np.mean(entropy(sk_posterior, base=np.exp(1), axis=1))
sk_score = max(H_Y - H_YX, 0)
sk_score = _mutual_information(y, sk_posterior)

posterior = Forest.predict_proba(X)
H_YX = np.mean(entropy(posterior, base=np.exp(1), axis=1))
score = max(H_Y - H_YX, 0)
score = _mutual_information(y, posterior)

scores.append(score)
sk_scores.append(sk_score)
Expand Down

0 comments on commit aadb185

Please sign in to comment.