【问题标题】:How to use MLP (Multilayer Perceptron) in R?如何在 R 中使用 MLP(多层感知器)?
【发布时间】:2013-04-20 04:27:53
【问题描述】:

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

我写了以下代码

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

谢谢..

【问题讨论】:

    标签: r neural-network


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2017-04-12
      • 2018-07-15
      • 2021-01-29
      • 1970-01-01
      • 2017-10-07
      • 2015-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多