def score_linked_tree(tree, neighbor_indices): result = 0.0 n_nodes = len(tree.children) for i in numba.prange(n_nodes): node = numba.int32(i) left_child = tree.children[node][0] right_child = tree.children[node][1] if left_child == -1 and right_child == -1: for j in range(tree.indices[node].shape[0]): idx = tree.indices[node][j] intersection = arr_intersect(neighbor_indices[idx], tree.indices[node]) result += numba.float32(intersection.shape[0] > 1) return result / numba.float32(neighbor_indices.shape[0])
def score_tree(tree, neighbor_indices, data, rng_state): result = 0.0 for i in numba.prange(neighbor_indices.shape[0]): leaf_indices = search_flat_tree( data[i], tree.hyperplanes, tree.offsets, tree.children, tree.indices, rng_state, ) intersection = arr_intersect(neighbor_indices[i], leaf_indices) result += numba.float32(intersection.shape[0] > 1) return result / numba.float32(neighbor_indices.shape[0])