r - R 中的 C5.0 机器学习,对测试数据具有 100% 的准确度
问题描述
我正在做一个机器学习项目,并使用 C5.0 决策树来查看乳腺癌数据,尝试预测诊断为恶性还是良性。该数据集是 UCI 机器学习数据集之一,发布在此链接:https ://archive.ics.uci.edu/ml/datasets/Breast+Cancer+Wisconsin+%28Diagnostic%29 。
我认为我的代码对于模型是正确的,但是每当我为测试数据运行它时,它对这些数据具有 100% 的准确性。我假设这意味着我做错了什么,但我不确定是什么:
#Load Library
library(C50)
library(gmodels)
library(tidyverse)
library(dplyr)
#Import Data
setwd("C:\\Users\\Grant\\Downloads")
wdbc<-read.delim("C:\\Users\\Grant\\Downloads\\wdbc.txt", header=TRUE, sep=",")
#Need to convert it to factor
wdbc2=mutate(wdbc, Diagnosis=as.factor(diagnosis))
#Randomize Sequence
set.seed(12345)
wdbc_rand<-wdbc2[order(runif(569)), ]
#Split into training vs. test data
wdbc_train<-wdbc_rand[1:512, ]
wdbc_test<-wdbc_rand[512:569, ]
#Create Model
wdbc_model<-C5.0(x=wdbc_train[-2], y=wdbc_train$Diagnosis)
#Evaluate Performance
wdbc_pred <- predict(wdbc_model, wdbc_test)
CrossTable(wdbc_test$Diagnosis, wdbc_pred, prop.chisq = FALSE,
prop.c = FALSE, prop.r = FALSE, dnn= c('actual diagnosis', 'predicted diagnosis'))
非常感谢我在这里做错的任何帮助或潜在的事情
解决方案
还不能输入评论(需要 50 声望点),所以我将在此处输入。代码似乎是正确的,但我认为准确度不是 100%。在 3 种情况下,预测为 B,而诊断为 M。您在训练模型时也使用 ID 作为预测器,我也会将其删除。
推荐阅读
- python - python aio libray 日志和异步方法日志未显示在函数应用程序洞察力中
- python - pandas boxplot 返回系列类型对象而不是轴
- python - 从网站表Python中提取数据不显示行
- angular - 浏览器中缺少 Angular 12 源映射
- kotlin - 模块找不到包 com.google.gson.stream
- java - Android Studio:无法初始化编辑器(重复)
- doctrine-orm - 如何从 Doctrine sql 查询中映射列名?
- android - 适用于 Android 的 MangoPay 实施
- php - 用 PHP 结构的子元素替换 DOM 结构的 innerHTML 和 HTML 之后
- python-3.x - Discord.py Python 经济机器人,带有 mongodb“NoneType”错误