ML Model to fit two linear functions to a set of data points?

ML Model to fit two linear functions to a set of data points?

by Rodrigo Ruz Cuen -
Number of replies: 0

Hello,

I have a set of data points, which appear like a line with a curve near the beginning. See the image below, which shows the points with a line of best fit (fit to the whole data set).


Instead, they could be described by two linear functions (a line through the leftmost set of points and a separate line through the rest of the data points). I need to develop a quantitative method that allows me to fit two different lines of best fit (linear) to the set of data points, such that the fitting for both is optimized.

One idea I had is to pick a "cutouff point", say at 

t=100
 (x-axis), and fit the points on the left to a line, and the points to the right to a different line. I could then compute χ2 for both lines in order to get the "goodness" of the fits. Then, I could just keep doing the same thing many times with slightly different cutoff points, until I find the pair of lines that gives the best overall fits. If possible, I wanted to use one of the Machine Learning algorithms in class to determine this "cutoff point" so that I can generate results like this: 

What would be the best Machine Learning algorithm to achieve this in Python?

Thanks a lot