在 R 中基于 CTG 数据集建立随机森林模型:因变量 NSP,其他列为自变量,并计算准确率。
Build a random forest model on top of the ‘CTG’ dataset, where ‘NSP’ is the dependent variable and all other columns are independent variables.
题目类型: 技术面试题
这是一道技术面试题,常见于澳洲IT公司面试中。
难度: hard
分类: 机器学习实战, 随机森林, 模型评估
标签: R, randomForest, caret, confusion matrix
参考答案摘要
核心答案 使用 randomForest 包构建模型,且将 NSP 转为因子(分类变量),再进行训练/测试划分和预测。 data<-read.csv("C:/Users/intellipaat/Downloads/CTG.csv",header=True) str(data) data$NSP<-as.factor(data$NSP) table(data$NSP) set.seed(123) s...
本题提供 STAR 原则详细解答和技术解析,登录匠人学院学习中心即可查看完整答案。