-
Notifications
You must be signed in to change notification settings - Fork 17
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
Add new fast_predict()
API method for prediction
#581
Conversation
- Add a new function for real-time inference vs. the existing `compute_and_save_prediction()` function that is better suited to batch prediction.
- Also add logger creation that was missing before.
Codecov ReportBase: 93.08% // Head: 93.12% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #581 +/- ##
==========================================
+ Coverage 93.08% 93.12% +0.03%
==========================================
Files 31 31
Lines 4529 4551 +22
==========================================
+ Hits 4216 4238 +22
Misses 313 313
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great. Definitely been looking for something like this for awhile! (I still like the idea of being able to save something like these steps directly in a model file, but I think this is at least going in a good direction.)
I have a couple minor comments. One is just about the return value of the new function.
- Use a dictionary instead of a data frame since that better matches the input semantics and is easier to reason about.
- Make `min_score` and `max_score` optional parameters - Check that the optional parameters are specified if `predict_expected` is `True`, since we do not need them otherwise. - Add a new unit test for this new check.
- Make all of the trimming and scaling parameters optional. - Update return values to only return what can be computed given what parameters have been provided. - Update the tests to test all possible combinations. - Remove the computation of expected scores since that's very rarely used and just adds unnecessary complexity to this function.
@mulhod, @amandameganchan, @tazin-afrin I have made the requested changes. Please re-review. |
Better refactoring of trim computation.
1831326
to
b375a6a
Compare
@blongwill thanks for the great review! I have incorporated your suggestions. Please re-review and approve if everything looks good. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this! It looks great!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new changes looks good to me, thanks!
Closes #546.
The current method that
rsmpredict
uses is calledcompute_and_save_prediction()
and is meant for batch prediction – it reads files from disks, does a lot of validation, and writes the predictions to disk. Therefore, it is not suited for real-time prediction on single instances which needs to happen in memory.This PR adds a new function called
fast_predict()
torsmpredict.py
meant to run on a single data point rather than a batch. This function expects the user to have already read all of the necessary files from disk (e.g., in a RFS service'ssetup()
function) and simply pass the in-memory data structures to this function. This function then pre-processes the features, generates predictions for the single data point using the model, and then post-processes the predictions.In addition to adding this new function, this PR also adds tests for it and updates the API documentation to include this new function.