This one is pretty easy to code. We can replace cvxpy.sum_squares(y - x) in TVR with sigma**2 * cvxpy.sum(cvxpy.huber((y - x)/sigma, M)), where sigma is calculated robustly with median_absolute_deviation as in the integration constant estimation code in utility.py and in evaluate.robust_rme. We might also want to add a huber_const like in kalman_smooth.convex_smooth so the Huber can't flatten out too much as $M \to 0$.
This adds a hyperparameter to the method, $M$, which raises its total to 3 (along with order and $\gamma$). Would need some changes in the default optimization dict at the top of _optimize.py too. But M shouldn't be too hard to optimize over if the $\sigma$ normalization and huber_const are used, because M=0 is an $\ell_1$ norm, M=float('inf') is an $\ell_2$ norm, and M = 2 or 6 or whatever has a standard interpretation of becoming linear at that many sigma from the mean error, such that by $6\sigma$ there are really hardly any inliers that would be treated by the linear region of the Huber, so they get the fit benefits of being treated with the parabolic region. I've accounted for this notion in the default optimization dictionary for robustdiff by letting huberM start at values [0., 2, 6]. (Note the period is important so it's treated as a continuous float by the optimizer and not cast back to discrete ints.)
With that understanding, the code changes are small, and the heaviest part of the work comes after, running experiments using notebook 4 (probably modified to not rerun absolutely everybody) to see how this thing improves on the previous design. More than likely it would slay at the outlier case, but we gotta make sure. Note that when there are outliers, optimize has a huberM of its own and uses evaluate.robust_rme in its loss calculations by default, but with huberM=6 (which shows no serious difference with huberM=float('inf'), interestingly). That should maybe be brought lower to something like 2 if outliers are expected. I believe a ternary to make this selection is already in situ within notebook 4.
This one is pretty easy to code. We can replace$M \to 0$ .
cvxpy.sum_squares(y - x)in TVR withsigma**2 * cvxpy.sum(cvxpy.huber((y - x)/sigma, M)), wheresigmais calculated robustly withmedian_absolute_deviationas in the integration constant estimation code inutility.pyand inevaluate.robust_rme. We might also want to add ahuber_constlike inkalman_smooth.convex_smoothso the Huber can't flatten out too much asThis adds a hyperparameter to the method,$M$ , which raises its total to 3 (along with $\gamma$ ). Would need some changes in the default optimization dict at the top of $\sigma$ normalization and $\ell_1$ norm, $\ell_2$ norm, and $6\sigma$ there are really hardly any inliers that would be treated by the linear region of the Huber, so they get the fit benefits of being treated with the parabolic region. I've accounted for this notion in the default optimization dictionary for
orderand_optimize.pytoo. ButMshouldn't be too hard to optimize over if thehuber_constare used, becauseM=0is anM=float('inf')is anM = 2or6or whatever has a standard interpretation of becoming linear at that manysigmafrom the mean error, such that byrobustdiffby lettinghuberMstart at values[0., 2, 6]. (Note the period is important so it's treated as a continuous float by the optimizer and not cast back to discrete ints.)With that understanding, the code changes are small, and the heaviest part of the work comes after, running experiments using notebook 4 (probably modified to not rerun absolutely everybody) to see how this thing improves on the previous design. More than likely it would slay at the outlier case, but we gotta make sure. Note that when there are outliers,
optimizehas ahuberMof its own and usesevaluate.robust_rmein its loss calculations by default, but withhuberM=6(which shows no serious difference withhuberM=float('inf'), interestingly). That should maybe be brought lower to something like2if outliers are expected. I believe a ternary to make this selection is already in situ within notebook 4.