3

I am using the nnet package for classification of a target column with 3 states

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

But I want it to use entropy instead of default softmax and when I set softmax=false , it fails with the error :

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

Is there a way to somehow use entropy modelling in this scenario?

OmG
  • 18,337
  • 10
  • 57
  • 90
user2912902
  • 327
  • 1
  • 7
  • 17
  • 1
    `softmax` is the equivalent of `entropy` when you have more than 2 levels of the response. So you don't need to do anything. – Hong Ooi Nov 09 '13 at 10:37

1 Answers1

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)
Markus
  • 5,667
  • 4
  • 48
  • 64
lorelai
  • 147
  • 1
  • 2
  • 9