2013-04-26 138 views
1

我想用R中的多层感知器训练我的数据,并看到评估结果,如'auc score'。 R中有一个名为“monmlp”的包,但我不知道如何正确使用它。如何在R中使用MLP(多层感知器)?

我写了下面的代码

> 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) 

这是确定到现在为止,但下一步是什么?如何找到auc分数?

谢谢..

回答

7

正如所建议的Machine learning task view, 可以使用ROCR包。

# 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]] 
+0

非常感谢。 – ykpemre 2013-04-26 09:19:11