|
8 | 8 | from hashlib import sha1 |
9 | 9 | from tqdm import tqdm |
10 | 10 |
|
11 | | -from ..utils import evaluate |
| 11 | +from ..utils import evaluate, utility |
12 | 12 | from ..finite_difference import finitediff, first_order, second_order, fourth_order |
13 | 13 | from ..smooth_finite_difference import kerneldiff, mediandiff, meandiff, gaussiandiff, friedrichsdiff, butterdiff |
14 | 14 | from ..polynomial_fit import polydiff, savgoldiff, splinediff |
@@ -157,8 +157,12 @@ def _objective_function(point, func, x, dt, singleton_params, categorical_params |
157 | 157 | elif metric == 'error_correlation': |
158 | 158 | ec = evaluate.error_correlation(dxdt_truth, dxdt_hat, padding=padding) |
159 | 159 | cache[key] = ec; return ec |
160 | | - else: # then minimize (RMSE(x_hat - x) || sqrt{2*Mean(Huber((x_hat- x)/sigma, M))}*sigma) + gamma*TV(dxdt_hat) |
161 | | - # rubust_rme(,inf) = rmse(), so just use the simpler function in that case |
| 160 | + else: # then minimize L(Phi) = (RMSE(trapz(dxdt_hat) + c - x) || sqrt{2*Mean(Huber((trapz(dxdt_hat) + c - x)/sigma, M))}*sigma) + gamma*TV(dxdt_hat) |
| 161 | + # It seems like we should be able to use x_hat rather than the trapz integral of dxdt_hat + constant, but the latter is more reliable, |
| 162 | + # because it accounts for the accuracy of the derivative directly, not through the generating algorithm's smooth signal estimate. |
| 163 | + rec_x_hat = utility.integrate_dxdt_hat(dxdt_hat, dt) |
| 164 | + rec_x_hat += utility.estimate_integration_constant(x, rec_x_hat, M=huberM) |
| 165 | + # rubust_rme(,M=inf) = rmse(), so just use the simpler function if M=inf |
162 | 166 | cost = evaluate.rmse(x, x_hat, padding=padding) if huberM == float('inf') else evaluate.robust_rme(x, x_hat, padding=padding, M=huberM) |
163 | 167 | cost += tvgamma*evaluate.total_variation(dxdt_hat, padding=padding) |
164 | 168 | cache[key] = cost; return cost |
|
0 commit comments