1. # View more python learning tutorial on my Youtube and Youku channel!!!
  2.  
  3. # Youtube video tutorial: https://www.youtube.com/channel/UCdyjiB5H8Pu7aDTNVXTTpcg
  4. # Youku video tutorial: http://i.youku.com/pythontutorial
  5.  
  6. """
  7. Please note, this code is only for python 3+. If you are using python 2+, please modify the code accordingly.
  8. """
  9. from __future__ import print_function
  10. from sklearn import datasets
  11. from sklearn.linear_model import LinearRegression
  12. import matplotlib.pyplot as plt
  13.  
  14. loaded_data = datasets.load_boston()
  15. data_X = loaded_data.data
  16. data_y = loaded_data.target

  17. #用线性回归模型预测波士顿房价
  18. model = LinearRegression()
  19. model.fit(data_X, data_y)
  20.  
  21. print(model.predict(data_X[:4, :]))
  22. print(data_y[:4])

  23. #利用python自带的工具,生成用于回归的数据集,可以设置参数决定是否加入噪声等设置
  24. X, y = datasets.make_regression(n_samples=100, n_features=1, n_targets=1, noise=10)
  25. plt.scatter(X, y)
  26. plt.show()

莫烦python教程学习笔记——使用波士顿数据集、生成用于回归的数据集的更多相关文章

  1. 莫烦python教程学习笔记——保存模型、加载模型的两种方法

    # View more python tutorials on my Youtube and Youku channel!!! # Youtube video tutorial: https://ww ...

  2. 莫烦python教程学习笔记——validation_curve用于调参

    # View more python learning tutorial on my Youtube and Youku channel!!! # Youtube video tutorial: ht ...

  3. 莫烦python教程学习笔记——learn_curve曲线用于过拟合问题

    # View more python learning tutorial on my Youtube and Youku channel!!! # Youtube video tutorial: ht ...

  4. 莫烦python教程学习笔记——利用交叉验证计算模型得分、选择模型参数

    # View more python learning tutorial on my Youtube and Youku channel!!! # Youtube video tutorial: ht ...

  5. 莫烦python教程学习笔记——数据预处理之normalization

    # View more python learning tutorial on my Youtube and Youku channel!!! # Youtube video tutorial: ht ...

  6. 莫烦python教程学习笔记——线性回归模型的属性

    #调用查看线性回归的几个属性 # Youtube video tutorial: https://www.youtube.com/channel/UCdyjiB5H8Pu7aDTNVXTTpcg # ...

  7. 莫烦python教程学习笔记——使用鸢尾花数据集

    # View more python learning tutorial on my Youtube and Youku channel!!! # Youtube video tutorial: ht ...

  8. 莫烦python教程学习笔记——总结篇

    一.机器学习算法分类: 监督学习:提供数据和数据分类标签.--分类.回归 非监督学习:只提供数据,不提供标签. 半监督学习 强化学习:尝试各种手段,自己去适应环境和规则.总结经验利用反馈,不断提高算法 ...

  9. 莫烦大大TensorFlow学习笔记(9)----可视化

      一.Matplotlib[结果可视化] #import os #os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' import tensorflow as tf i ...

随机推荐

  1. Python使用cx_Oracle模块操作Oracle数据库--通过sql语句和存储操作

    https://www.jb51.net/article/125160.htm?utm_medium=referral  Python使用cx_Oracle调用Oracle存储过程的方法示例 http ...

  2. [bzoj4553]序列

    记第i个位置有三个属性:1.ai表示原来的值:2.bi表示变成最大的值:3.ci表示变成最小的值.那么对于如果i在j的前面,那么必然有:$ai\le cj$且$bi\le aj$,那么令f[i]表示以 ...

  3. [loj3276]遗迹

    假设已知$a_{i}$,通过以下方式确定$b_{i}$:从后往前枚举每一个数$i$,先令$b_{i}=a_{i}$,再将$b_{i}$不断减1直至不存在$j>i$且$b_{i}=b_{j}$或$ ...

  4. [luogu5162]WD与积木

    设$g_{n}$表示$n$个积木放的方案数,枚举最后一层所放的积木,则有$g_{n}=\sum_{i=1}^{n}c(n,i)g_{n-i}$(因为积木有编号的所以要选出$i$个) 将组合数展开并化简 ...

  5. hutool的时间工具类

    hutool的时间工具类 糊涂的时间工具类有很多使用方法,用到了这几个 日期向后偏移     String now = DateUtil.now();        Date date4= DateU ...

  6. 多线程02.继承Thread类

    package chapter2; /** * 1.使用static虽然完成了当前的功能. * 但是static的生命周期比较长,需要在所有线程执行完成后才会结束. * 还有号没有按照顺序进行打印 * ...

  7. 实战!spring Boot security+JWT 前后端分离架构认证登录!

    大家好,我是不才陈某~ 认证.授权是实战项目中必不可少的部分,而Spring Security则将作为首选安全组件,因此陈某新开了 <Spring Security 进阶> 这个专栏,写一 ...

  8. 基于Vue简易封装的快速构建Echarts组件 -- fx67llQuickEcharts

    fx67llQuickEcharts A tool to help you use Echarts quickly! npm 组件说明 这本来是一个测试如何发布Vue组件至npm库的测试项目 做完之后 ...

  9. 洛谷 P5224 - Candies(循环卷积)

    洛谷题面传送门 一道题解长度大概不到 1k 的题,可还是决定写篇题解,因为自己没有做出来( \(1004535809\) 好评( 首先这个 \(\equiv m\pmod{k}\) 有点把我们往单位根 ...

  10. 洛谷 P6030 - [SDOI2012]走迷宫(高斯消元+SCC 缩点)

    题面传送门 之所以写个题解是因为题解区大部分题解的做法都有 bug(u1s1 周六上午在讨论区里连发两个 hack 的是我,由于我被禁言才让 ycx 代发的) 首先碰到这种期望题,我们套路地设 \(d ...