2

I want to use the same function or method in Python as mvregress in MATLAB. As an example, we have x1, x2, x3, x4, x5, x6 inputs and y1, y2, y3 outputs. After using this function we should get some estimate regression coefficients. Does Python have this ability?

Paul
  • 5,473
  • 1
  • 30
  • 37
A. Innokentiev
  • 681
  • 2
  • 11
  • 27

1 Answers1

2

sklearn.linear_model.LinearRegression works fine for multivariate linear regression (where the output is a vector, not a scalar)

>>> from sklearn import linear_model
>>> X = [[1, 2, 3, 4, 5, 6]]
>>> Y = [[1, 2, 3]]
>>> lr = linear_model.LinearRegression()
>>> model = lr.fit(X, Y)
>>> model.predict([[1,2,3,4,5,6]])
array([[ 1.,  2.,  3.]])
bakkal
  • 54,350
  • 12
  • 131
  • 107