美文网首页数据分析
Udacity 数据分析进阶课程笔记L37:回归

Udacity 数据分析进阶课程笔记L37:回归

作者: 有刺客 | 来源:发表于2018-04-17 14:58 被阅读3次
    1. 通过大量小练习,直观学习:
      • 判断连续与离散分布
      • 简单的回归方程,斜率slope和截距intercept的概念
      • 使用回归方程进行预测
    2. 使用sklearn进行回归分析
    from sklearn.linear_model import LinearRegression
    
    reg = LinearRegression()
    reg.fit(ages_train, net_worths_train)
    km_net_worth = reg.predict([[27]])[0][0] 
    
    ### get the slope
    slope = reg.coef_[0][0] 
    
    ### get the intercept
    intercept = reg.intercept_[0] 
    
    ### get the score on test data
    test_score = reg.score(ages_test, net_worths_test) 
    
    1. 线性回归的误差error:真实值与预测值之差
    2. 最佳回归:
      • 方差最小的回归,或最小化SSE(Sum of Squared Errors)
      • 获得最佳回归的方法:最小二乘法和梯度下降
      • Minimizing the Sun of Squared Errors
    3. 当数据集增大是,SSE可能随之增大,因此在一个小的数据集上使用线性回归时,其SSE可能可能更小。
    4. 使用来评估线性回归模型质量,可规避上一问题。
      • 理解:有多少输出的改变能用输入的改变来解释;
      • 取值通常在0到1之间;
      • 其优点在于与数据集的大小无关
      • 使用R²评估线性回归
      • sklearn中使用,即前文代码最后一行的.score()
      • 使用matplotlib图形化回归结果
    import matplotlib.pyplot as plt
    plt.scatter()
    plt.plot()
    plt.xlabel()
    plt.ylabel()
    plt.show()
    
    1. 比较分类和回归
    比较分类和回归
    1. 多元回归简介
    2. 回归迷你项目

    相关文章

      网友评论

        本文标题:Udacity 数据分析进阶课程笔记L37:回归

        本文链接:https://www.haomeiwen.com/subject/howukftx.html