-
Notifications
You must be signed in to change notification settings - Fork 24
Made kerneldiff to address #162
#163
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A lot of sections belonged to now-deprecated methods. They can get absorbed into one. |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added deprecation messages to the docs, as well as warnings for runtime. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,7 @@ | |
|
|
||
| from ..utils import evaluate | ||
| from ..finite_difference import finitediff, first_order, second_order, fourth_order | ||
| from ..smooth_finite_difference import mediandiff, meandiff, gaussiandiff, friedrichsdiff, butterdiff | ||
| from ..smooth_finite_difference import kerneldiff, mediandiff, meandiff, gaussiandiff, friedrichsdiff, butterdiff | ||
| from ..polynomial_fit import polydiff, savgoldiff, splinediff | ||
| from ..basis_fit import spectraldiff, rbfdiff | ||
| from ..total_variation_regularization import tvrdiff, velocity, acceleration, jerk, iterative_velocity, smooth_acceleration, jerk_sliding | ||
|
|
@@ -19,10 +19,25 @@ | |
|
|
||
| # Map from method -> (search_space, bounds_low_hi) | ||
| method_params_and_bounds = { | ||
| meandiff: ({'window_size': [5, 15, 30, 50], | ||
| kerneldiff: ({'kernel': {'mean', 'median', 'gaussian', 'friedrichs'}, | ||
| 'window_size': [5, 15, 30, 50], | ||
| 'num_iterations': [1, 5, 10]}, | ||
| {'window_size': (1, 1e6), | ||
| 'num_iterations': (1, 100)}), | ||
| meandiff: ({'window_size': [5, 15, 30, 50], # Deprecated method | ||
| 'num_iterations': [1, 5, 10]}, | ||
| {'window_size': (1, 1e6), | ||
| 'num_iterations': (1, 100)}), | ||
| butterdiff: ({'filter_order': set(i for i in range(1,11)), # categorical to save us from doing double work by guessing between orders | ||
| 'cutoff_freq': [0.0001, 0.001, 0.005, 0.01, 0.1, 0.5], | ||
| 'num_iterations': [1, 5, 10]}, | ||
| {'cutoff_freq': (1e-4, 1-1e-2), | ||
| 'num_iterations': (1, 1000)}), | ||
| finitediff: ({'num_iterations': [5, 10, 30, 50], | ||
| 'order': {2, 4}}, # order is categorical here, because it can't be 3 | ||
| {'num_iterations': (1, 1000)}), | ||
| first_order: ({'num_iterations': [5, 10, 30, 50]}, # Separated because optimizing over this one is rare due to shifted answer | ||
| {'num_iterations': (1, 1000)}), | ||
| polydiff: ({'step_size': [1, 2, 5], | ||
| 'kernel': {'friedrichs', 'gaussian'}, # categorical | ||
| 'degree': [2, 3, 5, 7], | ||
|
|
@@ -49,26 +64,16 @@ | |
| 'lmbd': [1e-3, 1e-2, 1e-1]}, | ||
| {'sigma': (1e-3, 1e3), | ||
| 'lmbd': (1e-4, 0.5)}), | ||
| finitediff: ({'num_iterations': [5, 10, 30, 50], | ||
| 'order': {2, 4}}, # order is categorical here, because it can't be 3 | ||
| {'num_iterations': (1, 1000)}), | ||
| first_order: ({'num_iterations': [5, 10, 30, 50]}, | ||
| {'num_iterations': (1, 1000)}), | ||
| butterdiff: ({'filter_order': set(i for i in range(1,11)), # categorical to save us from doing double work by guessing between orders | ||
| 'cutoff_freq': [0.0001, 0.001, 0.005, 0.01, 0.1, 0.5], | ||
| 'num_iterations': [1, 5, 10]}, | ||
| {'cutoff_freq': (1e-4, 1-1e-2), | ||
| 'num_iterations': (1, 1000)}), | ||
| tvrdiff: ({'gamma': [1e-2, 1e-1, 1, 10, 100, 1000], | ||
| 'order': {1, 2, 3}}, # warning: order 1 hacks the loss function when tvgamma is used, tends to win but is usually suboptimal choice in terms of true RMSE | ||
| {'gamma': (1e-4, 1e7)}), | ||
| velocity: ({'gamma': [1e-2, 1e-1, 1, 10, 100, 1000]}, | ||
| velocity: ({'gamma': [1e-2, 1e-1, 1, 10, 100, 1000]}, # Deprecated method | ||
| {'gamma': (1e-4, 1e7)}), | ||
| iterative_velocity: ({'num_iterations': [1, 5, 10], | ||
| 'gamma': [1e-2, 1e-1, 1, 10, 100, 1000], | ||
| 'scale': 'small'}, | ||
| {'num_iterations': (1, 100), # gets expensive with more iterations | ||
| 'gamma': (1e-4, 1e7)}), | ||
| iterative_velocity: ({'scale': 'small', # Rare to optimize this one, because it's longer-running than convex version | ||
| 'num_iterations': [1, 5, 10], | ||
| 'gamma': [1e-2, 1e-1, 1, 10, 100, 1000]}, | ||
| {'num_iterations': (1, 100), # gets expensive with more iterations | ||
| 'gamma': (1e-4, 1e7)}), | ||
| smooth_acceleration: ({'gamma': [1e-2, 1e-1, 1, 10, 100, 1000], | ||
| 'window_size': [3, 10, 30, 50, 90, 130]}, | ||
| {'gamma': (1e-4, 1e7), | ||
|
|
@@ -77,7 +82,7 @@ | |
| 'order': {1, 2, 3}, # for this few options, the optimization works better if this is categorical | ||
| 'qr_ratio': [10**k for k in range(-9, 10, 2)] + [1e12, 1e16]}, | ||
| {'qr_ratio': [1e-10, 1e20]}), # qr_ratio is usually >>1 | ||
| constant_velocity: ({'q': [1e-8, 1e-4, 1e-1, 1e1, 1e4, 1e8], | ||
| constant_velocity: ({'q': [1e-8, 1e-4, 1e-1, 1e1, 1e4, 1e8], # Deprecated method | ||
| 'r': [1e-8, 1e-4, 1e-1, 1e1, 1e4, 1e8], | ||
| 'forwardbackward': {True, False}}, | ||
| {'q': (1e-10, 1e10), | ||
|
|
@@ -95,14 +100,14 @@ | |
| 'gamma': (1e-3, 1000), | ||
| 'window_size': (15, 1000)}) | ||
| } # Methods with nonunique parameter sets are aliased in the dictionary below | ||
| for method in [second_order, fourth_order]: | ||
| for method in [second_order, fourth_order]: # Deprecated, redundant methods | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I realized basically all these methods I'm aliasing down here are redundant. An argument to truly consider them deprecated and remove them eventually. |
||
| method_params_and_bounds[method] = method_params_and_bounds[first_order] | ||
| for method in [mediandiff, gaussiandiff, friedrichsdiff]: | ||
| for method in [mediandiff, gaussiandiff, friedrichsdiff]: # Deprecated methods | ||
| method_params_and_bounds[method] = method_params_and_bounds[meandiff] | ||
| for method in [acceleration, jerk]: | ||
| for method in [acceleration, jerk]: # Deprecated, redundant methods | ||
| method_params_and_bounds[method] = method_params_and_bounds[velocity] | ||
| method_params_and_bounds[jerk_sliding] = method_params_and_bounds[smooth_acceleration] | ||
| for method in [constant_acceleration, constant_jerk]: | ||
| for method in [constant_acceleration, constant_jerk]: # Deprecated, redundant methods | ||
| method_params_and_bounds[method] = method_params_and_bounds[constant_velocity] | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,4 @@ | ||
| """Apply smoothing method before finite difference. | ||
| """ | ||
| from ._smooth_finite_difference import mediandiff, meandiff, gaussiandiff, friedrichsdiff, butterdiff, splinediff | ||
|
|
||
| __all__ = ['mediandiff', 'meandiff', 'gaussiandiff', 'friedrichsdiff', 'butterdiff'] # So automodule from the .rst finds them | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| # splinediff is still included in the imports list so backwards compatibility isn't broken, but excluded | ||
| # from the __all__ list so sphinx doesn't try to document it from this module. | ||
| from ._smooth_finite_difference import kerneldiff, mediandiff, meandiff, gaussiandiff, friedrichsdiff, butterdiff, splinediff | ||
| # splinediff is still included in the imports list so backwards compatibility isn't broken | ||
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.
Now manually documenting things in here so they show up in the order I want.