3

我正在使用 nnet 包对具有 3 个状态的目标列进行分类

model <- nnet(targetcolumn ~ ., data=DATAFRAME)

但我希望它使用熵而不是默认的 softmax,当我设置 softmax=false 时,它​​会失败并出现错误:

model <- nnet(targetcolumn ~ ., data=DATAFRAME, maxit=1000, MaxNWts=10000,softmax=FALSE, entropy=TRUE)

Error in nnet.default(x, y, w, softmax = false, ...) : 
  formal argument "softmax" matched by multiple actual arguments

有没有办法在这种情况下以某种方式使用熵建模?

4

1 回答 1

3
# because you've got a classification problem it is imperative that
softmax=TRUE

#to calculate the entropy
entropy=TRUE

But before these 2 work together it is necessary that you transform your Y (0 1 2 ...) into a matrix of dummy variables. This is done by:

dataframe$Y = class.ind(dataframe$targetcolumn)

# delete the old target variable
dataframe$targetcolumn=NULL

# and now you can start creating your ANN
nnet1 = nnet (Y~., dataframe, size=..., decay=..., entropy=TRUE, softmax=TRUE)
于 2014-11-25T13:48:09.367 回答