标签:model res als sklearn cep style mes jobs type
import numpy as np import matplotlib.pyplot as plt from sklearn import datasets # 获取数据 boston = datasets.load_boston() X = boston.data y = boston.target # 数据处理 X = X[y < 50.0] y = y[y < 50.0]
from sklearn.linear_model import LinearRegression # 求解多元线性方程 lin_reg = LinearRegression() lin_reg.fit(X, y)
LinearRegression(copy_X=True, fit_intercept=True, n_jobs=None, normalize=False)
lin_reg.coef_
array([-1.06715912e-01, 3.53133180e-02, -4.38830943e-02, 4.52209315e-01, -1.23981083e+01, 3.75945346e+00, -2.36790549e-02, -1.21096549e+00, 2.51301879e-01, -1.37774382e-02, -8.38180086e-01, 7.85316354e-03, -3.50107918e-01])
np.argsort(lin_reg.coef_)
array([ 4, 7, 10, 12, 0, 2, 6, 9, 11, 1, 8, 3, 5], dtype=int64)
boston.feature_names[np.argsort(lin_reg.coef_)]
array([‘NOX‘, ‘DIS‘, ‘PTRATIO‘, ‘LSTAT‘, ‘CRIM‘, ‘INDUS‘, ‘AGE‘, ‘TAX‘, ‘B‘, ‘ZN‘, ‘RAD‘, ‘CHAS‘, ‘RM‘], dtype=‘<U7‘)
标签:model res als sklearn cep style mes jobs type
原文地址:https://www.cnblogs.com/waterr/p/14039928.html