I had difficulty producing a continuous regression curve, with no splits as is currently the case.
from numpy import *
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from scipy.optimize import curve_fit
from sklearn.metrics import mean_squared_error
from matplotlib.pyplot import *
from scipy.interpolate import *
%matplotlib inline
x = array([28,47,43,40,42,37,64,48,47,45,58,38,45,38,50,42,59,40,49,38,52])
y = array([64,44,46,48,43,55,41,50,52,58,44,56,47,59,40,50,43,58,47,55,40])
p2 = polyfit(x,y,2) # Polynoial curve, secend order
plot (x,y,'o')
plot (x,polyval(p2,x),'r-')
The printed plot is:
But all I need is just a normal curve, the red curve should be just one continuous curve, and not be split or divided as it is now. How can this be done?
(In the code snippet above this is printing a second order regression curve, but the problem also exists in a higher order (and in the first order))
I would appreciate any help.