[R] How to build and importance chart with mlp function from RSNNS package in R?

meg mhaartman at alteryx.com
Mon Jul 7 17:13:40 CEST 2014


I would like to build a bar plot with the importance of the independent
variables ranked by largest value. I am using the mlp function for the model
and don't believe I am using the correct output. model is what comes out of
the mlp function

data(iris)

#shuffle the vector
iris <- iris[sample(1:nrow(iris),length(1:nrow(iris))),1:ncol(iris)]

irisValues <- iris[,1:4]
irisTargets <- decodeClassLabels(iris[,5])
#irisTargets <- decodeClassLabels(iris[,5], valTrue=0.9, valFalse=0.1)

iris <- splitForTrainingAndTest(irisValues, irisTargets, ratio=0.15)
iris <- normTrainingAndTestSet(iris)

model <- mlp(iris$inputsTrain, iris$targetsTrain, size=5,
learnFuncParams=c(0.1),
             maxit=50, inputsTest=iris$inputsTest,
targetsTest=iris$targetsTest)    
ex<-extractNetInfo(model)
    k<-ex$unitDefinitions
    w <- which(k[,5]=="UNIT_INPUT")

    dat<-subset(k, select=c("unitName","unitAct"))[w,]
    dat$unitAct=dat$unitAct/max(dat$unitAct)
    dat["new"]<-colnames(the.data$inputsTrain)


    dat <- dat[order(dat$unitAct),] 
    par(las=2) # make label text perpendicular to 
    par(mar=c(5,8,4,2)) # increase y-axis margin.
    barplot(dat$unitAct, main="Importance of Independent Variables",
horiz=TRUE, names.arg=dat$new, cex.names=0.8)



--
View this message in context: http://r.789695.n4.nabble.com/How-to-build-and-importance-chart-with-mlp-function-from-RSNNS-package-in-R-tp4693635.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list