Discretizers.jl
Discretizers.jl copied to clipboard
RegularLinearDiscretizer or something better than bisection search
Turns out removing the Dicts didn't help my performance too much... I guess I didn't look hard enough at the profiling.
The encoding still seems to be a bit slow because of the binary search. All of my grids are regular, so I could implement at RegularLinearDiscretizer that encodes in O(1) time.
Another option would be to replace https://github.com/sisl/Discretizers.jl/blob/b43839f39c3f9ca09c025434788eb8f10c48d55c/src/linear_discretizer.jl#L70 with something like
c = floor(Int, (b-a)*(x-va)/(vb-va))
which would be faster if the bins are evenly spaced, but could have bad performance if bins are irregular (maybe... I think).
Seems like RegularLinearDiscretizer would be best, but wanted to check if anyone else had anything to say/if anyone knows of another package that already does this.
Or...
struct LinearDiscretizer{N, D, E<:AbstractVector} ...
binedges::E
...
end
And then we could write a special method of encode
that does O(1) lookup for LinearDiscretizer
s that have an AbstractRange
as binedges
.
Yeah, I think we could specialize for uniform bins. I like O(1) lookups.