Задание: “Your task is to calculate the vector of the coefficients of the linear regression for the prediction of the first variable (the first column of data) by all the rest.”
“Нарисовал” два решения:
from numpy import loadtxt from sklearn.linear_model import LinearRegression x = loadtxt('boston_houses.csv', delimiter=',', skiprows=1) r = LinearRegression().fit(x[:, 1 :], x[:, 0]) print(r.intercept_, *r.coef_) и from numpy import loadtxt import statsmodels.api as sm x = loadtxt('boston_houses.csv', delimiter=',', skiprows=1) y = x[:, 0] x = x[:, 1 :] x = sm.add_constant(x) model = sm.OLS(y, x) print(*model.fit().params)
Но в тестовой среде модули sklearn и statsmodels не доступны…
- Прошу подсказать, чем еще можно воспользоваться?