0
Rのニューラルネットワークを使って、144の独立変数を持つ車の価格を予測したい。 私のコードの下に。最後の2行:AUCとプロットを除いて、すべて正常に動作します。 ROC(predNN、yTEST)でrocのニューラルネットワーク:Rのニューラルネットワーク
エラー:ROC曲線下面積を計算する ない十分な明確な予測
これは私が得たエラーです。
私は既に従属変数を係数として計算しましたが、このエラーは残ります。 この問題を解決するにはどうすればよいですか?
allind <- sample(x=1:nrow(data_price2),size=nrow(data_price2))
trainind <- allind[1:round(length(allind)/3)]
valind <- allind[(round(length(allind)/3)+1):round(length(allind)*(2/3))]
testind <- allind[round(length(allind)*(2/3)+1):length(allind)]
BasetableTRAIN <- data_price2[trainind,]
BasetableVAL <- data_price2[valind,]
Basetablebig <-rbind(BasetableTRAIN,BasetableVAL)
BasetableTEST <- data_price2[testind,]
#Create a separate response variable
yTRAIN <- BasetableTRAIN$Price
BasetableTRAIN$Price <- NULL
yVAL <- BasetableVAL$Price
BasetableVAL$Price <- NULL
yTEST <- BasetableTEST$Price
BasetableTEST$Price <- NULL
yBIG <- Basetablebig$Price
Basetablebig$Price <- NULL
yTRAIN <- as.factor(yTRAIN)
yVAL <- as.factor(yVAL)
yTEST <- as.factor(yTEST)
yBIG <- as.factor(yBIG)
if (require("nnet")==FALSE) install.packages("nnet") ; library(nnet)
if (require("AUC")==FALSE) install.packages("AUC") ; library(AUC)
size <- 5 #number of units in the hidden layer
decay <- 0.1 #weight decay. Same as lambda in regularized LR. Controls for
overfitting.
rang <- 0.5 #the range of the initial random weights parameter
maxit <- 2000 #set high in order not to run into early stopping
NN <- nnet(yBIG ~ ., Basetablebig, size = size,
rang = rang, decay = decay, maxit = maxit,MaxNWts= Inf)
predNN <- as.numeric(predict(NN,BasetableTEST,type="raw"))
AUC::auc(roc(predNN,yTEST))
plot(roc(predNN,yTEST))
他の人が答えをアップアップしました。 (nconn [i + 1] == ns)cadd < - c(0、from):TRUE/FALSEが必要な値が見つからない場合にエラーが発生します。スケーリングされたbasetableを見ると、ダミー変数の中には多くのNA値がありますが、他のものはそうではありません – GerritCalle
どうすればこの問題を解決できますか? – GerritCalle
すべてのコードの前に 'scale(data_price2)'はそれを行います。私はあなたが言及したエラーをどうやって知っていません。 – abhiieor