# Tricky detail when converting a random forest from scikit-learn into ONNX¶

scikit-learn use a specific comparison when computing the preduction of a decision tree, it does (float)x <= threshold (see tree.pyx / method apply_dense). ONNX does not specify such things and compares x to threshold, both having the same type. What to do then when writing the converter.

## Region where (float)x <= y¶

Let's see how the comparison (float)x <= y looks like.

## Equivalent to (float)x <= (float)y ?¶

Applied to a decision tree, it does not mean that the evaluation of the condition of each node would fail in 5.75% of the cases, it depends on how the thresholds are built and the area of errors depends on the numbers.

## Good threshold¶

Let's draw the function:

That's explain some tricky lines in package skl2onnx. Let's check if it still works with negative value.

It works.