Return the gradient and y intercept (m, b) to create two lines to best fit the data
I have been working on this task for a few hours now and have been unsuccessful with getting the target result. I have tried using multiple methods of trying to split the dataset using different clustering methods and logistical regression with no luck. I thought noncontinuous piecewise linear regression may work however found no good resources on how to implement it.
The taks is given a 2D NumPy array of x, y data points determine the gradient and y-intercept for exactly two lines that best fit the data. Here is an example photo where the two blue lines show what a solved solution looks like.
Any help would be greatly appreciated.
Topic linear-regression graphs dataset
Category Data Science