【发布时间】:2018-11-05 23:12:04
【问题描述】:
我正在测试使用 R 对决策树进行编程,并决定使用来自 UCI 的汽车数据集,可用 here。
根据作者的说法,它有 7 个属性:
CAR car acceptability
. PRICE overall price
. . buying buying price
. . maint price of the maintenance
. TECH technical characteristics
. . COMFORT comfort
. . . doors number of doors
. . . persons capacity in terms of persons to carry
. . . lug_boot the size of luggage boot
. . safety estimated safety of the car
所以我想使用 DT 作为分类器,以考虑购买价格、维护、舒适度、车门、人员、行李箱和安全性来获得汽车的可接受性。
首先我提取了第一列作为因变量,然后我注意到数据是按顺序排列的;取决于第一列的值(非常高、高、中、低)。出于这个原因,我决定对数据进行洗牌。我的代码如下:
car_data<-read.csv("car.data")
library(C50)
set.seed(12345)
car_data_rand<-car_data[order(runif(1727)),]
car_data<-car_data_rand
car_data_train<-car_data[1:1500,]
car_data_test<-car_data[1501:1727,]
answer<-data_train$vhigh
answer_test<-data_test$vhigh
#deleting the dependent variable or y from the data
car_data_train$vhigh<-NULL
car_data_test$vhigh<-NULL
car_model<-C5.0(car_data_train,answer)
summary(car_model)
这里我遇到了一个可怕的错误:
Evaluation on training data (1500 cases):
Decision Tree
----------------
Size Errors
7 967(64.5%) <<
我做错了什么?
【问题讨论】:
标签: r decision-tree