sorry I am still fairly new to python and hoping someone can help me with a curve fitting issue...
I have a MxN dataframe "data" where M is number of samples and N is number of variables (10). I have a Mx1 dependent variable "Fractions" which are a fraction between 0 and 1 that correspond to each sample.
I know how to easily run a multiple linear regression between the independent variables N and and dependent variable Fractions, however, I wrapped the regression in a sigmoid regression to keep responses between 0 and 1.
I was able to perform this like so...
def sigmoid(x,b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10):
y = 1 / (1 + np.exp(- (b0 + b1*x[:,0] + b2*x[:,1] + b3*x[:,2] + b4*x[:,3] + b5*x[:,4] +
b6 * x[:,5] + b7*x[:,6] + b8*x[:,7] + b9*x[:,8] + b10*x[:,9])))
return y
popt, pcov = curve_fit(sigmoid,data,fractions)
'''use coefficients from curve_fit to estimate new fraction from new 1xN data'''
newFraction = sigmoid(newData, *popt)
However, I would like to implement some sort of stepwise multiple regression for feature selection, preferably based on AIC. I have found these following methods using python...
http://scikit-learn.org/stable/modules/generated/sklearn.feature_selection.RFE.html https://planspace.org/20150423-forward_selection_with_statsmodels/ https://datascience.stackexchange.com/questions/24405/how-to-do-stepwise-regression-using-sklearn/24447#24447
But all of these methods rely on using a regression that involves a .fit() method. Is there a way to implement a model like above using a any of the .fit() methods like statsmodels or lmfit? I have also looked into Lasso-type methods, however, again can't figure out how to implement my function.