莫烦scikit-learn学习自修第五天训练模型的属性
Posted liuzhiqaingxyz
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了莫烦scikit-learn学习自修第五天训练模型的属性相关的知识,希望对你有一定的参考价值。
1.代码实战
#!/usr/bin/env python #!_*_ coding:UTF-8 _*_ from sklearn import datasets from sklearn.linear_model import LinearRegression import matplotlib.pyplot as plt # 从内置训练数据集中加载房价数据 loaded_data = datasets.load_boston() data_X = loaded_data.data data_y = loaded_data.target model = LinearRegression() model.fit(data_X, data_y) print model.coef_ print model.intercept_ print model.get_params() print model.score(data_X, data_y)
结果:
[ -1.07170557e-01 4.63952195e-02 2.08602395e-02 2.68856140e+00 /Users/liudaoqiang/PycharmProjects/numpy/venv/lib/python2.7/site-packages/scipy/linalg/basic.py:1226: RuntimeWarning: internal gelsd driver lwork query error, required iwork dimension not returned. This is likely the result of LAPACK bug 0038, fixed in LAPACK 3.2.2 (released July 21, 2010). Falling back to ‘gelss‘ driver. -1.77957587e+01 3.80475246e+00 7.51061703e-04 -1.47575880e+00 warnings.warn(mesg, RuntimeWarning) 3.05655038e-01 -1.23293463e-02 -9.53463555e-01 9.39251272e-03 -5.25466633e-01] 36.4911032804 {‘copy_X‘: True, ‘normalize‘: False, ‘n_jobs‘: 1, ‘fit_intercept‘: True} 0.740607742865
以上是关于莫烦scikit-learn学习自修第五天训练模型的属性的主要内容,如果未能解决你的问题,请参考以下文章