首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在R中使用MLP (多层感知器)?

如何在R中使用MLP (多层感知器)?
EN

Stack Overflow用户
提问于 2013-04-26 12:47:23
回答 1查看 15.1K关注 0票数 1

我想用R中的多层感知器来训练我的数据,然后看看评估结果,比如'auc score‘。在R中有一个名为"monmlp“的包,但是我不知道如何正确使用它。

我写了下面的代码

代码语言:javascript
复制
> 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分数?

谢谢..

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-04-26 16:20:45

按照Machine learning task view的建议,您可以使用ROCR包。

代码语言:javascript
复制
# 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]]
票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16228954

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档