在R

时间:2018-02-01 14:29:36

标签: r boost adaboost

今天我正在探索adaboost技术。但是,我从adabag包文档中复制了以下示例代码。

data(iris)
iris.adaboost <- boosting(Species~., data=iris, boos=TRUE,
mfinal=10)
importanceplot(iris.adaboost)

执行第二行后我没有收到任何错误。 但是当我对从https://archive.ics.uci.edu/ml/datasets/car+evaluation

下载的另一个数据集使用相同的方法时
library(adabag)
library(rpart)

cars <- read.csv("car.data.csv", header= FALSE)

# to view no.of obs in each column
sapply(cars, FUN=function(col) sum(is.na(col)))
# to view rows with missing values
cars[!complete.cases(cars),]

cars.adaboost <- boosting(V7 ~., data=cars, boos=TRUE,
                          mfinal=10)`

我收到以下错误

Error in matrix(unlist(value, recursive = FALSE, use.names = FALSE), nrow = nr,  : 
length of 'dimnames' [2] not equal to array extent
In addition: Warning messages:
1: In is.na(e2) : is.na() applied to non-(list or vector) of type 'NULL'
2: In is.na(e2) : is.na() applied to non-(list or vector) of type 'NULL'
3: In is.na(e2) : is.na() applied to non-(list or vector) of type 'NULL'
4: In is.na(e2) : is.na() applied to non-(list or vector) of type 'NULL'
5: In is.na(e2) : is.na() applied to non-(list or vector) of type 'NULL'
6: In is.na(e2) : is.na() applied to non-(list or vector) of type 'NULL'
7: In is.na(e2) : is.na() applied to non-(list or vector) of type 'NULL'
8: In is.na(e2) : is.na() applied to non-(list or vector) of type 'NULL'
9: In is.na(e2) : is.na() applied to non-(list or vector) of type 'NULL'
10: In is.na(e2) : is.na() applied to non-(list or vector) of type 'NULL'

我还在观察中检查了以下NA:

 > # to view rows with missing values
> cars[!complete.cases(cars),]
[1] V1 V2 V3 V4 V5 V6 V7
<0 rows> (or 0-length row.names)

this is the dataset of cars

有人可以帮助我获得我失踪的东西。对不起,如果我问了一个愚蠢的问题,因为我是初学者并开始学习机器学习和R,因为不到一个月?

0 个答案:

没有答案