str(adult1_test) 'data.frame': 9049 obs. of 15 variables: $ : num 39 50 37 49 31 42 43 54 43 59 ... $ : num 77516 83311 284582 160187 45781 ... $ : num 13 13 14 5 14 13 14 9 7 9 ... $ : num 2174 0 0 0 14084 ... $ : num 0 0 0 0 0 ... $ : num 40 13 40 16 50 40 45 20 40 40 ... $ : chr " State-gov" " Self-emp-not-inc" " Private" " Private" ... $ : chr " Bachelors" " Bachelors" " Masters" " 9th" ... $ : chr " Never-married" " Married-civ-spouse" " Married-civ-spouse" " Married-spouse-absent" ... $ : chr " Adm-clerical" " Exec-managerial" " Exec-managerial" " Other-service" ... $ : chr " Not-in-family" " Husband" " Wife" " Not-in-family" ... $ : chr " White" " White" " White" " Black" ... $ : chr " Male" " Male" " Female" " Female" ... $ : chr " United-States" " United-States" " United-States" " Jamaica" ... $ : Factor w/ 2 levels " <=50K"," >50K": 1 1 1 1 2 2 2 1 1 1 ... - attr(*, "na.action")= 'omit' Named int [1:2399] 15 28 39 52 62 70 78 94 107 129 ... ..- attr(*, "names")= chr [1:2399] "15" "28" "39" "52" ...
时间: 2023-07-21 11:03:50 浏览: 263
obs-studio_20200505-git-1_amd64.deb
根据您提供的测试数据集的结构,我们可以看到该数据集包含15个变量。然而,这些变量的名称是缺失的,因为它们显示为无名称的数字索引。这可能是导致找不到'age'变量的原因。
请确保在创建测试数据集时,为每个变量提供正确的名称。您可以使用`colnames(adult1_test) <- c("var1", "var2", ...)`来为测试数据集中的每个变量分配适当的名称。然后,您可以再次尝试使用`predict()`函数进行预测,并确保使用正确的变量名称来解决'age'变量找不到的问题。
阅读全文