码迷,mamicode.com
首页 > 其他好文 > 详细

莫烦scikit-learn学习自修第五天【训练模型的属性】

时间:2018-09-05 08:53:50      阅读:280      评论:0      收藏:0      [点我收藏+]

标签:data   lib   coding   sklearn   asi   mode   plt   ali   target   

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学习自修第五天【训练模型的属性】

标签:data   lib   coding   sklearn   asi   mode   plt   ali   target   

原文地址:https://www.cnblogs.com/liuzhiqaingxyz/p/9589936.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!