Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RegularLinearDiscretizer or something better than bisection search #26

Open
zsunberg opened this issue Jan 31, 2020 · 2 comments
Open

Comments

@zsunberg
Copy link
Member

zsunberg commented Jan 31, 2020

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

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.

@zsunberg
Copy link
Member Author

zsunberg commented Jan 31, 2020

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 LinearDiscretizers that have an AbstractRange as binedges.

@mykelk
Copy link
Member

mykelk commented Feb 1, 2020

Yeah, I think we could specialize for uniform bins. I like O(1) lookups.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants