我正试图在temp1=cumsum(a); %Commulative Sum
temp2=[0 diff(mod(temp1,10))];%Indexes where sum >=10 (indicated by negative values)
temp2(temp1<0)=0; %Removing false indexes which may come if `a` has -ve values
required = find(temp2 <0) %Required indexes
中使用AUC
检测到最佳genetic algorithm
。这是代码:
R
但在library(GA)
library(ROCR)
realResult <- sample( c(T,F), 350, replace=TRUE, prob=c( 0.5, 0.5) )
AUCfitness<-function(scores){
res<-prediction(scores, realResult, label.ordering = NULL)
auc.tmp <- performance(res,"auc");
auc <- as.numeric(auc.tmp@y.values)
# print(paste0("AUC is: ",auc))
auc
}
min <- 0.000654226
max <- 9433.873
GA <- ga(type = "real-valued", fitness = AUCfitness, min = min, max = max, monitor = FALSE,popSize = 350)
summary(GA)
行中,它抱怨:
ga
如您所见,我的 Error in prediction(scores, realResult, label.ordering = NULL) :
Number of predictions in each run must be equal to the number of labels for each run.
大小为350和realResult
,因此我不应该面对此错误
答案 0 :(得分:0)
几分钟前解决了这个问题。 似乎都是因为NA。 我删除了所有与模型有关的NA案例,然后一切正常。