Last active
November 27, 2016 00:23
-
-
Save lambday/09d5d9a6fb36a1559e945b478dc06d5f to your computer and use it in GitHub Desktop.
poc api for watchables
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
| # your code goes here | |
| gen_p = GaussianBlobsDataGenerator(...) | |
| gen_q = GaussianBlobsDataGenerator(...) | |
| mmd = QuadraticTimeMMD(gen_p, gen_q) | |
| mmd.set_kernel(GaussianKernel(10, 2**0.5)) | |
| mmd.set_num_samples_p(1000) | |
| mmd.set_num_samples_q(1000) | |
| mmd.enable_watching() | |
| watchables = mmd.get_watchables() # <-- Needs magic, works with inheritance, composition, through registration | |
| # watchables.show() # prints ['perm_indices', 'xval_measures', 'test_power_measures', ....] | |
| # watchables.show().details('perm_indices') # prints a description of what it is | |
| perm_indices_watcher = mmd.watch('perm_indices') # <-- returns a SGObserver impl, backend ReactiveX | |
| perm_indices_watcher.on_update().save() # on_update().print() / do_nothing() / exit() | |
| # perm_indices_watcher.on_error().print() / do_nothing() / exit() | |
| # perm_indices_watcher.on_completion().print() / do_nothing() / exit() | |
| # default for the above handlers is 'do_nothing()' | |
| # can append multiple for the above, like perm_indices_watcher().on_update().print().save().exit(), etc | |
| rejected = mmd.perform_test(alpha) | |
| perm_indices = perm_indices_watcher().get() # returns set if asked to save, None otherwise | |
| mmd.disable_watching() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment