Skip to content
Advertisement

How do I create a linear regression model for a file that has about 500 columns as y variables? Working with Python

This code manually selects a column from the y table and then joins it to the X table. The program then performs linear regression. Any idea how to do this for every single column from the y table?

JavaScript

Advertisement

Answer

You can regress multiple y’s on the same X’s at the same time. Something like this should work

JavaScript

produces

JavaScript

The first row here ([ 0.16115884 0.08471495 0.39169592]) are the regression coefs of y1 on xs and the second are the regression coefs of y2 on xs.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement