I am doing multivariate regression in python using the weighted least squares method. I have a data set that is 10x4, in other words, there are 4 functions for each sample in the data.
If my dataset is X, I can do the following to get the regression function coefficients:
import numpy as np
import statsmodels.api as sm
from statsmodels.sandbox.regression.predstd import wls_prediction_std
mod_wls = sm.WLS(y, X)
res_wls = mod_wls.fit()
print res_wls.params
For my specific 10x4 dataset, this gives me the following result:
[ 0.06210193 5.24256099 0.15214974 0.12325115]
However, they told me that I needed to create a regression function g(X), by iterating over EACH x[i]in Xand summing up the various regression functions.
I suppose (but would like to be corrected if I misunderstood it), I suppose that means that g(x) = g(x1) + g(x2) + g(x3) + ... + g(x10)
, , . , :
[ 0.11 1.22 0.33 0.88]
[ 1.22 0.55 0.44 0.11]
, g(X) :
[ 1.33 1.77 0.77 0.99]
0.11 + 1.22 = 1.33 ..
.
: scikit-learn?
, - ?
, , , , ?