Add support for online drift detectors#1108
Merged
adriangonz merged 10 commits intoApr 20, 2023
Merged
Conversation
ascillitoe
commented
Apr 19, 2023
ascillitoe
commented
Apr 19, 2023
ascillitoe
commented
Apr 19, 2023
| # If batch is configured, wrap X in a list so that it is not unpacked | ||
| X = np.array(input_data) | ||
| if self._ad_settings.batch_size: | ||
| X = [X] |
Author
There was a problem hiding this comment.
Wrap X in a list (of length 1) so that we don't unpack into single instances when running in batch mode (i.e. offline drift detectors or outlier detectors). pred is then returned as a list of length 1.
This slightly circuitous logic is intended to avoid having two duplicate try-except blocks for the two (offline vs online) use cases...
ascillitoe
commented
Apr 19, 2023
ascillitoe
commented
Apr 19, 2023
ascillitoe
commented
Apr 19, 2023
adriangonz
approved these changes
Apr 19, 2023
adriangonz
left a comment
Contributor
There was a problem hiding this comment.
This looks great @ascillitoe! 🚀
I've added a minor comment around the state save logic and check, but everything else should be good to go once the linter and tests pass!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds support for online drift detectors to Alibi Detect runtime.
Overview
This involves two primary changes:
self.tupdated each time. If a request contains a batch of instances, the payload must be unpacked and passed to the detector one instance at a time.state_save_freqtime-steps, wherestate_save_freqis a new configurable parameter added toAlibiDetectSettings.Limitations
Parallel inference is NOT currently supported for online detectors (i.e.
parallel_workers=0is required). This would require careful thought wrt to how state is managed/shared across parallel workers, in addition to considering the implications of distributing non-iid samples between workers.TODO's