【问题标题】:Warnings in MLP model(Caret, RSNNS package)MLP 模型中的警告(插入符号、RSNNS 包)
【发布时间】:2017-10-05 12:46:12
【问题描述】:

我通过 R 中的 caret 包运行多层感知模型。代码是:

LR_fitcontrol <- trainControl(method='cv',
                              number=2,
                              classProbs = T,
                              summaryFunction = twoClassSummary,
                              savePredictions = T)
Sys.time()

para.grid <-data.frame(size= c(10))
KNN_fit <- train(LR_formula_tune,data=model_data_Classification,
                 method="mlp",
                 metric='ROC',
                 preProc = c('center','scale'),
                 tuneGrid = para.grid,
                 trControl= LR_fitcontrol
)

我收到的警告。

1: In snnsObject$setUnitName(num, iNames[[i]]) :
  SNNS error message in setUnitName : SNNS-Kernel Error: Symbol pattern invalid (must match [A-Za-z][^|, ]*)

有 16 个类似的警告。

我已经通过插入符号在此数据集上运行了许多其他模型,例如 RF、KNN、Logistic、朴素贝叶斯。所以我想数据集很好。

当然,我用谷歌搜索了这个错误,根本没有类似的结果。我认为需要一些帮助。谢谢!

【问题讨论】:

    标签: r neural-network r-caret


    【解决方案1】:

    我也遇到了同样的问题。正如警告告诉您使用的符号存在一些问题。在我的例子中,它是一个名为“03Prüfen”的因子水平。为了避免警告,我将因子级别更改为“03Pruefen”,从而解决了问题。所以你应该避免像'äöü'等特殊字符。检查你的数据。由于我不知道您的数据是什么样的,因此我无法告诉您您的问题到底出在哪里。

    工作示例:

    library(caret)
    library(RSNNS)
    data(iris) #load example-data
    iris$ExampleFeature <- as.factor(c(rep("01Blümchen", 50), rep("02Blume", 50), rep("03Blöme", 50))) #add factor with problematic factor level names
    
    # Define trainControl #
    control <- trainControl(method='cv',
                            number=2,
                            classProbs = TRUE,
                            savePredictions = "final")
    
    # Start training which will create warnings #
    KNN_fit <- train(Species~.,
                     data=iris,
                     method="mlp",
                     metric='Accuracy',
                     preProc=c('center','scale'),
                     trControl=control
    )
    
    # Change factor level names and re-run training #
    levels(iris$ExampleFeature) <- c("01Bluemchen","02Blume","03Bloeme")
    
    KNN_fit <- train(Species~.,
                     data=iris,
                     method="mlp",
                     metric='Accuracy',
                     preProc=c('center','scale'),
                     trControl=control
    )
    

    此外:当我使用 RStudio 在 Windows 笔记本电脑上运行代码时,不会出现警告。它只发生在我在 CentOS 上运行的 RStudio-Server 上。

    【讨论】:

    • 我从Mac系统得到这个结果,所以可能是平台相关的。
    • 可能是。您的变量名或任何因子级别中是否有任何特殊字符?如果是这样,请更改它并重试。让我知道它是否适合您。
    猜你喜欢
    • 2018-10-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-18
    • 2016-01-15
    • 2015-04-11
    • 2022-11-11
    • 2019-01-25
    相关资源
    最近更新 更多