首页 > 解决方案 > R错误:protect():在RTextTools包的train_models()中使用TREE算法时保护堆栈溢出

问题描述

我想寻求有关以下方面的帮助 - 为什么在使用 R 中 RTextTools 包中的 TREE 分类器时出现错误。

我决心使用社交媒体文本数据评估决策树分类器的准确性。我设法使用这个确切的代码来评估 SVM。但是当我尝试在 train_models() 中实现 TREE 算法时,我得到了错误。

错误 错误:protect():保护堆栈溢出

我的数据集

我的代码

library("e1071")
library("RTextTools")

rm()
gc()

data_combinez <- read.csv(file="C:/Users/.../Documents/R/book1.csv", header = TRUE, stringsAsFactors = FALSE, sep=",")

data_combinez$X  <- str_squish(data_combinez$X)

data_combinez$sentiment_scores <- factor(data_combinez$sentiment_scores, levels = c(-1, 0, 1))

# shuffle the rows in the dataset
set.seed(1234)  
data_combinez <- data_combinez[sample(nrow(data_combinez)),]

trainids <- seq(1, floor(nrow(data_combinez)*0.5))
training_text <- data_combinez$X[trainids]
training_sentiment <- data_combinez$sentiment_scores[trainids]

testids <- seq(floor(nrow(data_combinez)*0.5)+1, nrow(data_combinez))
testing_text <- data_combinez$X[testids]
testing_sentiment <- data_combinez$sentiment_scores[testids]

matrix = create_matrix(data_combinez[, 1], language = "english", weighting = weightTfIdf, ngramLength = 1)

container = create_container(matrix, data_combinez[, 2], trainSize = trainids, testSize = testids, virgin = FALSE)

models = train_models(container, algorithms = "TREE")
# !!! ---- ERROR OCCUR HERE : Error: protect(): protection stack overflow

# print_algorithms()

results = classify_models(container, models)

# accuracy
recall_accuracy(testing_sentiment, results[, "TREE_LABEL"])

本地机器环境

我的尝试 我试图通过命令提示符运行这行代码来解决这个问题,但仍然遇到同样的错误。

C:\Program Files\RStudio\bin\rstudio.exe --max-ppsize=500000

标签: r

解决方案


推荐阅读