r - R错误:protect():在RTextTools包的train_models()中使用TREE算法时保护堆栈溢出
问题描述
我想寻求有关以下方面的帮助 - 为什么在使用 R 中 RTextTools 包中的 TREE 分类器时出现错误。
我决心使用社交媒体文本数据评估决策树分类器的准确性。我设法使用这个确切的代码来评估 SVM。但是当我尝试在 train_models() 中实现 TREE 算法时,我得到了错误。
错误 错误:protect():保护堆栈溢出
我的数据集
- 4 列,26,814 行(HEADER = TRUE),2.73MB 大小
- 在此处下载:https ://drive.google.com/file/d/1u8ojYrebqXUP_1GsptTv_FsQWnFV2sZy/view
我的代码
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"])
本地机器环境
- RStudio 版本 1.4.1717
- 处理器 第 11 代 Intel(R) Core(TM) i5-11300H @ 3.10GHz 3.11 GHz
- RAM 16.0 GB(可用 15.8 GB)
- 操作系统 Windows 10 家庭 64 位
我的尝试 我试图通过命令提示符运行这行代码来解决这个问题,但仍然遇到同样的错误。
C:\Program Files\RStudio\bin\rstudio.exe --max-ppsize=500000
解决方案
推荐阅读
- r - 在R中将日期名称转换为日期格式
- apache - htaccess 不在服务器上更新?
- html - 在标签中使用 hreflang 属性有什么好处?
- angular - 如何使用测试库重新呈现 Angular 属性指令
- python - 数到 10 和下一行
- javascript - 检查一个对象是否是另一个对象的后代
- javascript - @click 事件不起作用,并且 .native 给出与父级相同的值
- java - 需要帮助创建Mandarin Square Capturing的用例图
- reactjs - react-slick 在第一页加载时将宽度初始化为 0
- azure - Azure 数据工厂无法将数据从 Rest API 获取到 Cosmos DB