@@ -180,7 +180,7 @@ n_labels` matrix of probabilities, each row summing up to 1.
180
180
(eg. ["versicolor", "virginica", "setosa"]). It specifies the column ordering
181
181
of the output matrix. """
182
182
apply_tree_proba (leaf:: Leaf{T} , features:: AbstractVector{S} , labels) where {S, T} =
183
- collect ( leaf. values ./ leaf. total)
183
+ leaf. values ./ leaf. total
184
184
185
185
function apply_tree_proba (tree:: Node{S, T} , features:: AbstractVector{S} , labels) where {S, T}
186
186
if tree. featval === nothing
@@ -192,8 +192,13 @@ function apply_tree_proba(tree::Node{S, T}, features::AbstractVector{S}, labels)
192
192
end
193
193
end
194
194
195
- apply_tree_proba (tree:: LeafOrNode{S, T} , features:: AbstractMatrix{S} , labels) where {S, T} =
196
- stack_function_results (row-> apply_tree_proba (tree, row, labels), features)
195
+ function apply_tree_proba (tree:: LeafOrNode{S, T} , features:: AbstractMatrix{S} , labels) where {S, T}
196
+ predictions = Vector {NTuple{length(labels), Float64}} (undef, size (features, 1 ))
197
+ for i in 1 : size (features, 1 )
198
+ predictions[i] = apply_tree_proba (tree, view (features, i, :), labels)
199
+ end
200
+ reinterpret (reshape, Float64, predictions) |> transpose |> Matrix
201
+ end
197
202
198
203
function build_forest (
199
204
labels :: AbstractVector{T} ,
0 commit comments