Skip to Content
数据科学中的实用统计学(第2版)
book

数据科学中的实用统计学(第2版)

by Peter Bruce, Andrew Bruce, Peter Gedeck
October 2021
Intermediate to advanced
289 pages
8h 31m
Chinese
Posts & Telecom Press
Content preview from 数据科学中的实用统计学(第2版)
156
4
formula = 'AdjSalePrice ~ bs(SqFtTotLiving, df=6, degree=3) + ' +
'SqFtLot + Bathrooms + Bedrooms + BldgGrade'
model_spline = smf.ols(formula=formula, data=house_98105)
result_spline = model_spline.fit()
线性项的系数有直接的意义,而样条项的系数是不可解释的。可视化方式更适合揭示样条
拟合的本质。图
4-12
出了上面回归的偏残差图。与多项式模型不同的是,样条模型与
平滑曲线匹配得更加紧密,这说明样条回归具有更大的灵活性。在这个例子中,样条回归
曲线对数据的拟合更紧密。这意味着样条回归是更好的模型吗?并不一定。从样条曲线来
看,面积非常小的房屋(小于
1000
平方英尺)要比稍大一些的房屋的价值更高
,这显然
不符合经济学规律。这可能是某个混淆变量导致的,参见
4.5.3
节。
4-12:变量
SqFtTotLiving
的样条回归拟合曲线(实线)与平滑曲线(虚线)的比较
4.7.3
 广义可加模型
假设你基于先验知识或者回归诊断,怀疑响应变量和某个预测变量之间存在非线性关系。
多项式项可能不够灵活,无法捕获这种关系,而样条项又需要指定节点。这时就可以使用
广义可加模型
,或称
GAM
,它是一种非常灵活的建模技术
,可以自动拟合一个样条回归。
可以使用
R
中的
mgcv
包来为房屋数据拟合一个
GAM
模型:
回归与预测 ...
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

Python机器学习案例精解

Python机器学习案例精解

Posts & Telecom Press, Yuxi (Hayden) Liu

Publisher Resources

ISBN: 9787115569028