I would like to calculate a multiple linear regression of the form Y = aX1 + bX2 where Y.shape == X1.shape == X2.shape = (200,192,288). I would like to preform the multiple linear regression along axis=0. I believe an operation of this type should result in two arrays of shape (192,288) each containing the coefficients for "a" and "b" respectively. Im struggling to find an efficient way to do this.
Asked
Active
Viewed 137 times
0
-
you need to reshape your arrays so they are `Y.shape == (1_075_200, 1)` and `X.shape == (1_075_200, 2)`, then use `sklearn` as in this [answer](https://stackoverflow.com/a/11479279/6692898) – RichieV Sep 21 '20 at 20:26
-
Im not understanding your notation here with the subscores, or how that answers applies to multiple linear regression w 3D arrays... Can you elaborate in an actual answer? – John Sep 21 '20 at 20:42
-
even though you have 3D arrays, you are not trying to do multiple regressions with each of the dimensions in an array, you are actually trying to map the value in each position of both X arrays to the Y array... in other words, you don't really care about the shape of the arrays, you can flatten your arrays and use a multiple linear regression as in the linked answer – RichieV Sep 21 '20 at 20:50
-
your new `X_data` would be an array of shape `(1075200, 2)`, one row for each datapoint and two columns for `X1 and X2`... underscore is just a thousands separator that is ignored by python when it is part of a number – RichieV Sep 21 '20 at 20:52