Algorithms to model non-linear relationship between two vectors I want to build a model that describes a curve that fits the data shown in the scatterplot. I thought it would be straight forward using sklearn. But the choice and application of the different methods gets rather confusing.
Which algorithms would you use to tackle this problem?

 A: I suppose the answer depends on what you are trying to accomplish: 


*

*Predicting future values

*Performing statistical inference

*Other ? 


My answer is that you can use any of the many regression models available and choose the one that you believe to be the most appropriate using whichever metric you are comfortable with. Here are a few examples along with the Python Sklearn code
Polynomial linear regression
import numpy as np
import matplotlib.pyplot as plt
from sklearn.preprocessing import PolynomialFeatures
from sklearn.linear_model import LinearRegression
from sklearn.pipeline import Pipeline, make_pipeline

model_1 = make_pipeline(PolynomialFeatures(degree = 5),LinearRegression())
model_1.fit(x.reshape(-1,1),y)
plt.figure(figsize = (8,5))
plt.scatter(x,y, alpha = .3, label = 'Data')
plt.plot(x,model_1.predict(x.reshape(-1,1)), color = 'red', label = 'Model')
plt.title('Polynomial degree 5')
plt.xlabel('X'), plt.ylabel('Y')
plt.legend(), plt.show()


Decision tree regression
from sklearn.tree import DecisionTreeRegressor
model_2 = DecisionTreeRegressor(max_depth = 3)
model_2.fit(x.reshape(-1,1),y)


Piecewise linear spline interpolation
from scipy import interpolate
tck = interpolate.splrep(x, y, k=1, s=1, t = [35])
plt.plot(x,interpolate.splev(x, tck, der=0), color = 'red', label = 'Model')


