다음 슬라이드는 현재 link입니다. 슬라이드 121/128에 있으며 AUC를 복제하는 방법을 알고 싶습니다. 저자는 그렇게하는 방법을 설명하지 않았습니다 (슬라이드 124에서도 동일). 두 번째로 슬라이드 125에서 다음 코드가 생성됩니다.xgboost 모델에서 AUC 플로팅 R
bestRound = which.max(as.matrix(cv.res)[,3]-as.matrix(cv.res)[,4])
bestRound
다음과 같은 오류가 나타납니다. as.matrix (cv.res)에
오류 [2] : 경계
다음 코드에 대한 데이터를 아웃 첨자 here에서 다운로드 될 수 있으며, I는 아래의 코드를 생성 한 너의 참고.
질문 : 어떻게 AUC를 작성자로 만들 수 있으며 아래 첨자가 범위를 벗어나는 이유는 무엇입니까?
는 ----- 코드 ------
# Kaggle Winning Solutions
train <- read.csv('train.csv', header = TRUE)
test <- read.csv('test.csv', header = TRUE)
y <- train[, 1]
train <- as.matrix(train[, -1])
test <- as.matrix(test)
train[1, ]
#We want to determin who is more influencial than the other
new.train <- cbind(train[, 12:22], train[, 1:11])
train = rbind(train, new.train)
y <- c(y, 1 - y)
x <- rbind(train, test)
(dat[,i]+lambda)/(dat[,j]+lambda)
A.follow.ratio = calcRatio(x,1,2)
A.mention.ratio = calcRatio(x,4,6)
A.retweet.ratio = calcRatio(x,5,7)
A.follow.post = calcRatio(x,1,8)
A.mention.post = calcRatio(x,4,8)
A.retweet.post = calcRatio(x,5,8)
B.follow.ratio = calcRatio(x,12,13)
B.mention.ratio = calcRatio(x,15,17)
B.retweet.ratio = calcRatio(x,16,18)
B.follow.post = calcRatio(x,12,19)
B.mention.post = calcRatio(x,15,19)
B.retweet.post = calcRatio(x,16,19)
x = cbind(x[,1:11],
A.follow.ratio,A.mention.ratio,A.retweet.ratio,
A.follow.post,A.mention.post,A.retweet.post,
x[,12:22],
B.follow.ratio,B.mention.ratio,B.retweet.ratio,
B.follow.post,B.mention.post,B.retweet.post)
AB.diff = x[,1:17]-x[,18:34]
x = cbind(x,AB.diff)
train = x[1:nrow(train),]
test = x[-(1:nrow(train)),]
set.seed(1024)
cv.res <- xgb.cv(data = train, nfold = 3, label = y, nrounds = 100, verbose = FALSE,
objective = 'binary:logistic', eval_metric = 'auc')
플롯 여기 AUC 그래프 여기
set.seed(1024)
cv.res = xgb.cv(data = train, nfold = 3, label = y, nrounds = 3000,
objective='binary:logistic', eval_metric = 'auc',
eta = 0.005, gamma = 1,lambda = 3, nthread = 8,
max_depth = 4, min_child_weight = 1, verbose = F,
subsample = 0.8,colsample_bytree = 0.8)
내가
건너 코드에 휴식입니다#bestRound: - subscript out of bounds
bestRound <- which.max(as.matrix(cv.res)[,3]-as.matrix(cv.res)[,4])
bestRound
cv.res
cv.res[bestRound,]
set.seed(1024) bst <- xgboost(data = train, label = y, nrounds = 3000,
objective='binary:logistic', eval_metric = 'auc',
eta = 0.005, gamma = 1,lambda = 3, nthread = 8,
max_depth = 4, min_child_weight = 1,
subsample = 0.8,colsample_bytree = 0.8)
preds <- predict(bst,test,ntreelimit = bestRound)
result <- data.frame(Id = 1:nrow(test), Choice = preds)
write.csv(result,'submission.csv',quote=FALSE,row.names=FALSE)
AUC 플롯을 이용해 주셔서 감사합니다. "교차 검증 예측을 얻으려면 xgb.cv를 호출 할 때 predict = T를 지정해야합니다"라는 오류가 발생했습니다. – user113156
내가 복제하려고하는 또 다른 요점은 슬라이드 121/128에 있습니다. 저자는 "교육 및 테스트 세트에서 AUC의 추세를 볼 수 있습니다."라고 말했습니다. 테스트 세트에서 이것을 복제하는 방법은 무엇입니까? 이것을 테스트 세트에 복제하는 목적은 무엇입니까? – user113156
@ user113156 그럼 xgboost 모델을 훈련하는 것이 훨씬 더 있습니다. 사람들은 일을하는 방식을 선호합니다. 일반적으로 교차 검증 과정에서 하이퍼 매개 변수, 데이터 변환, 업/다운 샘플링, 변수 선택, 확률 임계 값 최적화, 비용 함수 선택이 수행됩니다. 일반적으로 CV의 반복은 아니지만 예를 들어 3-4 배 CV의 5 번의 반복. 그리고이 모든 것들 중에서 가장 좋은 세트를 골라 내면 모든 기차 데이터로 모델을 훈련시키고 테스트 세트에서 검증합니다. 이것은 과도한 피팅을 피하기 위해 모두 완료되었습니다. – missuse