在 R 语言中基于 ‘mtcars’ 数据集实现简单线性回归,其中因变量为 ‘mpg’,自变量为 ‘disp’。
Implement simple linear regression in R on this ‘mtcars’ dataset, where the dependent variable is ‘mpg’ and the independent variable is ‘disp.’
题目类型: 技术面试题
这是一道技术面试题,常见于澳洲IT公司面试中。
难度: medium
分类: Machine Learning
标签: linear-regression, mtcars, caret, train-test-split
参考答案摘要
答案 这里我们需要找出 ‘mpg’ 如何随着排量(disp)变化。 我们需要把数据划分为训练集(training dataset)和测试集(testing dataset),以避免模型过拟合(overfit)。 如果不把数据集划分为这两部分,模型就会对训练数据过拟合,因此当我们加入新数据时,模型在新数据上的表现会很差。 因此,为了划分数据集,我们需要 caret 包。caret 包中包含 crea...
本题提供 STAR 原则详细解答和技术解析,登录匠人学院学习中心即可查看完整答案。