如何在R中使用MLP(多层感知器)? [英] How to use MLP (Multilayer Perceptron) in R?

查看:840
本文介绍了如何在R中使用MLP(多层感知器)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在R中使用多层感知器训练我的数据,并查看评估结果,例如"auc得分". R中有一个名为"monmlp"的软件包,但是我不知道如何正确使用它.

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.

我写了以下代码

> 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分数?

It is ok up to now, but what is next? How can I find auc score for example?

谢谢..

推荐答案

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

这篇关于如何在R中使用MLP(多层感知器)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆