问题
I want to train my data using multilayer perceptron in R and see the evaluation result like 'auc score'. There is a package named "monmlp" in R, however I don't know how to use it correctly.
I wrote the following code
> mlp.model = monmlp.fit(x, y, hidden1=3, n.ensemble=15, monotone=1, bag=T)
** Ensemble 1
** Bagging on
1 0.9206784
** 0.9206784
** Ensemble 2
** Bagging on
1 0.8200886
** 0.8200886
** Ensemble 3
** Bagging on
1 0.8278868
** 0.8278868
.
.
.
** Ensemble 15
** Bagging on
1 0.8186057
** 0.8186057
mlp.pred <- monmlp.predict(x = x, weights = mlp.model)
It is ok up to now, but what is next? How can I find auc score for example?
Thanks..
回答1:
As suggested by the Machine learning task view, you can use the ROCR package.
# Sample data
library(monmlp)
n <- 1000
k <- 7
x <- matrix( rnorm(k*n), nr=n )
w <- rnorm(k)
y <- ifelse( logistic( x %*% w ) + rnorm(n, sd = 0.2) > 1, 0, 1 )
# Fit the model and compute the predictions
r <- monmlp.fit(x, y, hidden1=3, n.ensemble=15, monotone=1, bag=TRUE)
z <- monmlp.predict(x = x, weights = r)
# Compute the AUC
library(ROCR)
plot( performance( prediction( z, y ), "tpr","fpr" ) )
performance( prediction( z, y ), "auc" )@y.values[[1]]
来源:https://stackoverflow.com/questions/16228954/how-to-use-mlp-multilayer-perceptron-in-r