3 ms·
I said it was overkill because I thought I had a simple analytical solution as follows. Note: I don't know anything about segmented regression, this is just you
by zawerf 9y ago
I said it was overkill because I thought I had a simple analytical solution as follows. Note: I don't know anything about segmented regression, this is just your standard CS dynamic programming to calculate splits
DP[i][j] = min over k of (DP[i][k] + (cost of splitting at k) + (linear regression error of points from kth to jth))
This should run in O(n^3) which will be fine for the author's requirement of ~100 points. But this isn't a complete solution since it's not obvious how to choose the cost of splitting (which is needed otherwise it will just split everything into 1 or 2 point segments).
I think thinking about this more and explicitly trying to design this cost function is still better than labeling a bunch of data until the machine learning algorithm can reverse engineer the cost function from your head. Then you can be confident of what your code is doing and why and know that it won't randomly output potato.
- loverofthings 9y agoIf you have labeled data (meaning that you know where proper splits need to be made) it's quite easy to build a DP based classifier that minimizes the error over training set. For example, if you were building a model that spits out 0 for no split, and 1 for split, you can easily make a simple cost sensitive linear model that takes into account previous decisions (something like HMM). Viterbi algorithm would be the DP step. For some, to me unknown, reason CNN performs well if not better than DP based HMM.