50
50
clf_source_dt .fit (Xs , ys )
51
51
clf_source_rf .fit (Xs , ys )
52
52
53
+ Nkmin = sum (yt == 0 )
54
+ root_source_values = clf_source_dt .tree_ .value [0 ].reshape (- 1 )
55
+ props_s = root_source_values
56
+ props_s = props_s / sum (props_s )
57
+ props_t = np .zeros (props_s .size )
58
+ for k in range (props_s .size ):
59
+ props_t [k ] = np .sum (yt == k ) / yt .size
60
+
61
+ coeffs = np .divide (props_t , props_s )
62
+
53
63
def test_depth ():
54
64
ut .depth_tree (clf_source_dt )
55
65
ut .depth_rf (clf_source_rf )
56
66
ut .depth (clf_source_dt ,node_test )
57
- ut .depth_array (clf_source_dt ,np .arange (clf_source_dt .tree_ .node_counte_count ))
67
+ ut .depth_array (clf_source_dt ,np .arange (clf_source_dt .tree_ .node_count ))
58
68
59
69
def test_rules ():
60
70
@@ -96,8 +106,8 @@ def test_splits():
96
106
ut .new_random_split (np .ones (s )/ s ,coh_splits )
97
107
98
108
def test_error ():
99
- e = ut .error (clf_source_dt ,node_test )
100
- le = ut .leaf_error (clf_source_dt ,node_test )
109
+ e = ut .error (clf_source_dt . tree_ ,node_test )
110
+ le = ut .leaf_error (clf_source_dt . tree_ ,node_test )
101
111
return e ,le
102
112
103
113
def test_distribution ():
@@ -110,8 +120,8 @@ def test_distribution():
110
120
ut .compute_Q_children_target (Xs ,ys ,phi ,threshold ,classes_test )
111
121
112
122
def test_pruning_risk ():
113
- ut .compute_LLR_estimates_homog (clf_source_dt )
114
- ut .contain_leaf_to_not_prune (clf_source_dt )
123
+ ut .compute_LLR_estimates_homog (clf_source_dt , Nkmin = Nkmin )
124
+ ut .contain_leaf_to_not_prune (clf_source_dt , Nkmin = Nkmin , coeffs = coeffs )
115
125
116
126
def test_divergence_computation ():
117
127
phi = clf_source_dt .tree_ .feature [0 ]
0 commit comments