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

Is it possible to select multiple items in one query to the list? #2

Closed
jmancherje opened this issue Mar 11, 2016 · 3 comments
Closed

Comments

@jmancherje
Copy link

For example, I'd like to select 5 unique items from a weighted list. I can write some functionality to do this myself, but I'm curious if there's a feature to specify a number of items to select.

@Schoonology
Copy link
Owner

There's not anything already built, mostly because with a weighted set like this, typically you want multiple items from the set to respect the weighted distribution itself, including duplicates.

What is the use case for getting a set of unique items? It could be a really useful feature, but I'm having trouble thinking of a use case.

@jmancherje
Copy link
Author

My situation is pretty specific. Essentially I have a list of items that is continuously growing, I am sending a weekly newsletter containing 5 or so of these items selected at random. I want to avoid duplicates within a short period of time so I'm adding a column to track the time since an item was last sent in an email and using the square of that time to assign a weight.

I wrote a wrapper function that makes multiple selections removing each choice from the original list and reassigning the weights dynamically for a certain number of selections given as an argument.

@Schoonology
Copy link
Owner

I looked at adding this to the API, and couldn't find anything that didn't make other calling conventions worse. I'm going to close this for now, though I'm open to PRs with concrete ideas for where to take this.

If it's any consolation, I added a section to the README (along with a complete overhaul to make it easier to consume) linking back to your algorithm as an example of how to handle this: https://github.com/Schoonology/weighted#selecting-multiple-items-simultaneously

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