Binarize
EasyMachine LearningArray
Description
Given an array and a threshold, return a binary array with 1 where the value is strictly greater than the threshold and 0 otherwise.
Examples
Input:
[1,2,3,4], 2Output:
[0,0,1,1]Explanation:
Every value above the threshold maps to one and everything at or below it maps to zero.
Input:
[5,0,3], 0Output:
[1,0,1]Explanation:
Every value above the threshold maps to one and everything at or below it maps to zero.
Input:
[-1,1], 0Output:
[0,1]Explanation:
Every value above the threshold maps to one and everything at or below it maps to zero.
Constraints
- •
1 ≤ length ≤ 10⁴