5. 模型训练和调参(The caret package) |
您所在的位置:网站首页 › r语言train › 5. 模型训练和调参(The caret package) |
1. 简介(The caret package ) 2. 可视化(The caret package) 3. 预处理(The caret package) 4. 数据分割(The caret package) 5. 模型训练和调参内容: Model Training and Parameter TuningAn ExampleBasic Parameter TuningNotes on ReproducibilityCustomizing the Tuning ProcessPre-Processing OptionsAlternate Tuning GridsPlotting the Resampling ProfileThe trainControl FunctionAlternate Performance MetricsChoosing the Final ModelExtracting Predictions and Class ProbabilitiesExploring and Comparing Resampling DistributionsWithin-ModelBetween-ModelsFitting Models Without Parameter Tuning 5.1 Model Training and Parameter Tuningcaret包有很多函数试图精简构建模型和评估模型的过程。 train 函数能用于: * 评估,应用抽样,模型调参的影响 * 通过参数选择最优模型 * 从训练集中评估模型表现 首先,需要选择一个具体地模型。现在,有233个可以使用;详情请看train Model List 或 train Model By Tag,在这些介绍中,有一个可被优化的参数列表。用户也可以自定义模型。 第一步就是调整模型(算法中的第一行就是选择一系列要估计的参数。例如,如果要拟合一个偏最小二乘模型,需要设定PLS估计的参数。) mlbench包中有一个Sonar数据集,这里,我们载入数据集: library(mlbench) data(Sonar) str(Sonar[, 1:10]) ## 'data.frame': 208 obs. of 10 variables: ## $ V1 : num 0.02 0.0453 0.0262 0.01 0.0762 0.0286 0.0317 0.0519 0.0223 0.0164 ... ## $ V2 : num 0.0371 0.0523 0.0582 0.0171 0.0666 0.0453 0.0956 0.0548 0.0375 0.0173 ... ## $ V3 : num 0.0428 0.0843 0.1099 0.0623 0.0481 ... ## $ V4 : num 0.0207 0.0689 0.1083 0.0205 0.0394 ... ## $ V5 : num 0.0954 0.1183 0.0974 0.0205 0.059 ... ## $ V6 : num 0.0986 0.2583 0.228 0.0368 0.0649 ... ## $ V7 : num 0.154 0.216 0.243 0.11 0.121 ... ## $ V8 : num 0.16 0.348 0.377 0.128 0.247 ... ## $ V9 : num 0.3109 0.3337 0.5598 0.0598 0.3564 ... ## $ V10: num 0.211 0.287 0.619 0.126 0.446 ...函数createDataPartition能创建一个分层的随机样本进入训练集和测试集: library(caret) set.seed(998) inTraining |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |