I want to fit a model to some data, but I would like to allow for a variable number of parameters, dependent on the arguments that provide.
def regressionmodel(df, a, b, c, N):
where df is a dataframe, a, b and c are fixed parameters that always need to be fit and N would be a list of column names that are in the dataframe. One term of the regression model is a sum like this:
M = K1 * col1 + K2 * col2 + K3 * col3 + ... + KN * colN
col1, col2 etc would be columns of the dataframe: df["colname"] and the parameters K1, K2 etc need to be fit with curve_fit, together with a, b and c. Is this at all possible? The ultimate goal is to determine which columns are most important in the fit, i.e. which columns have the largest influence on the data that is being fit, in my case ozone concentrations (with time on the x-axis).
This post seems relevant, but I have trouble adapting it to my needs.