I'm using Python 2.7 and Scikit-learn to fit a dataset using multiplicate linear regression, where the different terms are multiplied together instead of added together like in sklearn.linear_models.Ridge.
So instead of
y = c1 * X1 + c2 * X2 + c3 * X3 + ...
we need
y = c1 * X1 * c2 * X2 * c3 * X3...
Can we enable Python and Sklearn to fit and predict such a multiplicative/hedonic regression model?
I think you should be able to do this with regular linear regression by manipulating your input data set (data matrix).
The regression y ~ c1 * X1 * c2 * X2 *... is equivalent to y ~ k * (X1 * X2 *...) where k is some constant
So if you multiply all of the values in your design matrix together, then regress on that, I think you should be able to do this.
i.e. if your data matrix, X, is 4 x 1000 with features X1, X2, X3, and X4, use a pre-processing step to create a new matrix X_new, that is 1 x 1000 where the single column equals X1 * X2 * X3 * X4, then fit y ~ X_new (clf = LinearRegression(), clf.fit(X_new,y))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With