웹 사이트의 경우 - search for method = 'glm'
herecaret
내에 조정 매개 변수가 없습니다.
우리는 쉽게이 몇 가지 기본적인 train
호출을 테스트하여 경우가 확인할 수 있습니다. 우선 웹 서적 당 튜닝 파라미터 (cp
)를 가지고있는 메소드 (rpart
)부터 시작해 보겠습니다.
library(caret)
data(GermanCredit)
# Check tuning parameter via `modelLookup` (matches up with the web book)
modelLookup('rpart')
# model parameter label forReg forClass probModel
#1 rpart cp Complexity Parameter TRUE TRUE TRUE
# Observe that the `cp` parameter is tuned
set.seed(1)
model_rpart <- train(Class ~., data=GermanCredit, method='rpart')
model_rpart
#CART
#1000 samples
# 61 predictor
# 2 classes: 'Bad', 'Good'
#No pre-processing
#Resampling: Bootstrapped (25 reps)
#Summary of sample sizes: 1000, 1000, 1000, 1000, 1000, 1000, ...
#Resampling results across tuning parameters:
# cp Accuracy Kappa
# 0.01555556 0.7091276 0.2398993
# 0.03000000 0.7025574 0.1950021
# 0.04444444 0.6991700 0.1316720
#Accuracy was used to select the optimal model using the largest value.
#The final value used for the model was cp = 0.01555556.
cp
매개 변수가 조정 된 것을 볼 수 있습니다. 이제 glm
을 사용해 보겠습니다.
# Check tuning parameter via `modelLookup` (shows a parameter called 'parameter')
modelLookup('glm')
# model parameter label forReg forClass probModel
#1 glm parameter parameter TRUE TRUE TRUE
# Try out the train function to see if 'parameter' gets tuned
set.seed(1)
model_glm <- train(Class ~., data=GermanCredit, method='glm')
model_glm
#Generalized Linear Model
#1000 samples
# 61 predictor
# 2 classes: 'Bad', 'Good'
#No pre-processing
#Resampling: Bootstrapped (25 reps)
#Summary of sample sizes: 1000, 1000, 1000, 1000, 1000, 1000, ...
#Resampling results:
# Accuracy Kappa
# 0.7386384 0.3478527
위의 경우 glm
을 사용하면 매개 변수 튜닝을 수행하지 않았습니다. 내 경험상 parameter
이라는 parameter
은 실제 조정 매개 변수가 아닌 자리 표시 자일뿐입니다. 다음에 나오는 코드에서 알 수 있듯이, 비록 우리가 그것을 parameter
에 맞추도록 강요하려고해도, 기본적으로 오직 하나의 값만을 가지고 있습니다.
set.seed(1)
model_glm2 <- train(Class ~., data=GermanCredit, method='glm',
tuneGrid=expand.grid(parameter=c(0.001, 0.01, 0.1, 1,10,100, 1000)))
model_glm2
#Generalized Linear Model
#1000 samples
# 61 predictor
# 2 classes: 'Bad', 'Good'
#No pre-processing
#Resampling: Bootstrapped (25 reps)
#Summary of sample sizes: 1000, 1000, 1000, 1000, 1000, 1000, ...
#Resampling results across tuning parameters:
# Accuracy Kappa parameter
# 0.7386384 0.3478527 0.001
# 0.7386384 0.3478527 0.001
# 0.7386384 0.3478527 0.001
# 0.7386384 0.3478527 0.001
# 0.7386384 0.3478527 0.001
# 0.7386384 0.3478527 0.001
# 0.7386384 0.3478527 0.001
#Accuracy was used to select the optimal model using the largest value.
#The final value used for the model was parameter = 0.001.
시도'modelLookup ("GLM") ', 여기를 참조하십시오 : https://stackoverflow.com/questions/43970831/the-tuning-parameter-in-glm-vs-rf/44010331#44010331 –
그것을 'tuneLength'를 지정하고 그리드의 스펙이 급격히 변하는 대신에 변화하기로 결정된 '캐럿 (catcht)'매개 변수를 관찰하는 것부터 시작하는 것이 좋습니다. – dmi3kno
'glm' 메소드에는 튜닝 매개 변수가 없습니다. https://topepo.github.io/caret/train-models-by-tag.html, 거기에는 더미 튜닝 매개 변수가 있습니다. 아무 것도하지 않습니다. – jmuhlenkamp