予測確率のベクトルがあり、予測しきい値ベクトルの各値のベクトルを分類したいと思います。リストの最初の要素がしきい値が0の場合に分類される要素になり、リストの最後の要素がしきい値が1の場合に分類されるようになります。私の試みは助けになりません。
set.seed(1)
Predictions=runif(100)
predClassify=function(x){
Classifier=function(x,y){ifelse(x>=y,"Over","Under")}
classThreshold=seq(0,1,.1)
tmp=list()
for(i in seq_along(classThreshold)){
tmp[[?]]=as.factor(myClassifierFunc(x,classThreshold[i]))# not sure how to index this an outer for loop?
return(tmp)
}
classifiedList=predClassify(Predictions)
空を作成する代わりに、「classThreshold」のに等しいのをlist
作成してから、NULL
list
length
length
tmp[[i]]
tmp <- vector('list', length(classThreshold))
for(i in seq_along(classThreshold)){
tmp[[i]]=as.factor(myClassifierFunc(x,classThreshold[i]))
}
全機能を使用する
predClassify=function(x){
Classifier <- function(x,y){ifelse(x >= y, "Over", "Under")}
classThreshold <- seq(0,1,.1)
tmp <- vector('list', length(classThreshold))
for(i in seq_along(classThreshold)){
tmp[[i]]=as.factor(Classifier(x,classThreshold[i]))
}
tmp
}
-チェック
classifiedList <- predClassify(Predictions)
lengths(classifiedList)
#[1] 100 100 100 100 100 100 100 100 100 100 100
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加