Skip to Content
精通数据科学算法
book

精通数据科学算法

by Posts & Telecom Press, David Natingga
May 2024
Intermediate to advanced
181 pages
3h 9m
Chinese
Packt Publishing
Content preview from 精通数据科学算法

第6章 回归分析

回归分析是预测因变量之间关系的一个过程。例如,如果变量y线性地依赖于变量x,则回归分析试图预测变量yx之间的线性关系等式y = ax + b中的常数a和b。

本章将介绍以下内容:

  • 在华氏和摄氏温度转换的例子中,通过一个完整的数据集来展示线性回归的基本原理与核心思想;
  • 基于实际完整的数据,使用统计软件R来实现线性回归分析法的一些应用,包括华氏和摄氏温度转换、根据身高预测体重、根据距离预测飞行时长的例子;
  • 梯度下降算法,用以找到最佳匹配的回归模型(使用最小均方算法),在6.3节还讲述了如何使用Python实现该算法;
  • 在弹道飞行分析实例以及问题4的细菌数量预测实例中,讲述了如何使用R构建非线性回归模型。

在这个例子中,华氏温度和摄氏温度是线性相关的。在给定的华氏温度和摄氏温度对照表中,可以预估从华氏度数转换为摄氏度数的公式常量,反之亦然,如表6-1所示。

接下来从基本原则进行分析。

期望推导出从F(华氏度数)到C(摄氏度数)的如下转换公式:

C = a*F + b

这里,a和b是待计算的常量。函数C = a*F + b的图像是一条直线,而两点决定唯一的直线,因此,实际只需要表中的两个点:(F1, C1)和(F2, C2)。由此可以得到如下公式:

C1 = a*F1 + b C2 = a*F2 + b

现在,C2-C1=(a*F2+b)-(a*F1+b)=a*(F2-F1)。因此可以得到:

a=(C2-C1)/(F2-F1)

b=C1-a*F1=C1-[(C2-C1)/(F2-F1)]

接下来,把表单的前两组数据(F1,C1)=(5,-15)和(F2,C2)=(14, -10)代入公式中,得到了下面的结果: ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

数据科学原理

数据科学原理

Posts & Telecom Press, Sinan Ozdemir
PyTorch深度学习

PyTorch深度学习

Posts & Telecom Press, Vishnu Subramanian
程序员学数据结构

程序员学数据结构

Posts & Telecom Press, William Smith
可编程网络自动化

可编程网络自动化

Jason Edelman, Scott S. Lowe, Matt Oswalt

Publisher Resources

ISBN: 9781836204596