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

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

by Peter Bruce, Andrew Bruce, Peter Gedeck
October 2021
Intermediate to advanced content levelIntermediate to advanced
289 pages
8h 31m
Chinese
Posts & Telecom Press
Content preview from 数据科学中的实用统计学(第2版)
统计机器学习
225
6.4.3
 正则化
避免过拟合
盲目应用
xgboost
会在训练数据上出现过拟合,结果就是模型不具有稳定性。过拟合有如
下两个问题。
模型应用在训练数据之外的新数据上时,准确度会下降。
模型的预测非常容易变化,从而导致不稳定的结果。
所有建模技术都有过拟合的潜在危险,例如,如果回归公式中包含了太多变量,模型就会
得到虚假的预测结果。不过,对于多数统计方法,可以通过正确地选择预测变量来避免过
拟合,随机森林甚至不用调整参数,一般也能得到一个合理的模型。
xgboost
与这些方法不一样。我们使用贷款数据拟合
xgboost
模型,模型中包含训练集
中的所有变量。
R
代码如下所示:
seed <- 400820
predictors <- data.matrix(loan_data[, -which(names(loan_data) %in%
'outcome')])
label <- as.numeric(loan_data$outcome) - 1
test_idx <- sample(nrow(loan_data), 10000)
xgb_default <- xgboost(data=predictors[-test_idx,], label=label[-test_idx],
objective='binary:logistic', nrounds=250, verbose=0)
pred_default <- predict(xgb_default, predictors[test_idx,]) ...
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.
Start your free trial

You might also like

Pandas数据清洗与建模

Pandas数据清洗与建模

丹尼尔·陈
C++语言导学(原书第2版)

C++语言导学(原书第2版)

本贾尼 斯特劳斯特鲁普

Publisher Resources

ISBN: 9787115569028