R 中的超参数调优
Dr. Shirin Elsinghorst
Senior Data Scientist
head(breast_cancer_data)
# A tibble: 6 x 11
diagnosis concavity_mean symmetry_mean fractal_dimension perimeter_se smoothness_se
<chr> <dbl> <dbl> <dbl> <dbl> <dbl>
1 M 0.300 0.242 0.0787 8.59 0.00640
2 M 0.0869 0.181 0.0567 3.40 0.00522
3 M 0.197 0.207 0.0600 4.58 0.00615
4 M 0.241 0.260 0.0974 3.44 0.00911
# 创建线性模型
linear_model <- lm(perimeter_worst ~ fractal_dimension_mean, data = breast_cancer_data)
# 获取系数
summary(linear_model)$coefficients
Estimate Std. Error t value Pr(>|t|)
(Intercept) 167.60 25.91 6.469 3.9e-09 ***
fractal_dimension_mean -926.39 392.86 -2.358 0.0204 *
它们是拟合或训练的结果。
在线性模型中,我们要求的是系数。
linear_model$coefficients
(Intercept) fractal_dimension_mean
167.5972 -926.3866
ggp <- ggplot(data = breast_cancer_data, aes(x = fractal_dimension_mean, y = perimeter_worst)) + geom_point(color = "grey")ggp + geom_abline(slope = linear_model$coefficients[2], intercept = linear_model$coefficients[1])

注意:模型参数在训练中被拟合(即被找到);它们是拟合或训练的结果。
超参数在训练前设定。
args(lm)
help(lm)
?lm
linear_model <- lm(perimeter_worst ~ fractal_dimension_mean,
data = breast_cancer_data,
method = "qr")
在我们的线性模型中:
method 是在拟合之前设定的选项。在机器学习中,我们可能有:

R 中的超参数调优