' {:任务1失败 - "下标超出范围" '

时间:2016-01-28 02:47:32

标签: r machine-learning classification

我是R的新手,我正在尝试运行此代码,但我总是收到此错误:

  

{:任务1失败 - "下标超出范围"

时出错

这是我正在运行的代码

svmFit <- train(class ~., method = "svmLinear", data = teacher3,
            tuneLength = 7,
            trControl = trainControl(
                method = "cv", indexOut = teacher3.train))

OR

C45Fit <- train(class ~ ., method = "J48", data = teacher3,
tuneLength = 5,
trControl = trainControl(
    method = "cv", indexOut = teacher3.train))

OR

ctreeFit <- train(class ~ ., method = "ctree", data = teacher3,
tuneLength = 5,
trControl = trainControl(
    method = "cv", indexOut = teacher3.train))

我已经包含了所有需要的包并打电话给他们!但是这个错误一直显示在所有分类中

这是我的数据集的输入:

structure(list(native_speaker = structure(c(1L, 2L, 1L, 1L, 2L, 
2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 
2L, 2L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 
2L, 2L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 
2L, 1L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 
2L, 2L), .Label = c("english speaker", "non-english speaker"), class = "factor"), 
    course_instructor = structure(c(12L, 19L, 12L, 5L, 14L, 12L, 
    20L, 22L, 13L, 19L, 22L, 6L, 10L, 9L, 9L, 9L, 14L, 13L, 6L, 
    14L, 4L, 4L, 3L, 15L, 19L, 14L, 2L, 1L, 18L, 13L, 23L, 10L, 
    6L, 6L, 5L, 17L, 25L, 5L, 1L, 12L, 19L, 12L, 5L, 14L, 12L, 
    20L, 22L, 13L, 19L, 22L, 6L, 10L, 9L, 9L, 9L, 14L, 13L, 6L, 
    14L, 4L, 4L, 3L, 15L, 19L, 14L, 2L, 1L, 18L, 13L, 23L, 10L, 
    6L, 6L, 5L, 17L, 25L, 5L, 1L, 12L, 6L, 17L, 20L, 6L, 10L, 
    13L, 14L, 12L, 12L, 12L, 1L, 21L, 20L, 10L, 21L, 15L, 15L, 
    23L, 13L, 20L, 6L, 9L, 12L, 12L, 9L, 13L, 8L, 12L, 8L, 12L, 
    6L, 22L, 14L, 1L, 2L, 11L, 2L, 19L, 12L, 3L, 19L, 8L, 6L, 
    20L, 22L, 1L, 6L, 2L, 8L, 13L, 10L, 8L, 21L, 1L, 16L, 20L, 
    11L, 20L, 13L, 14L, 22L, 12L, 21L, 17L, 7L, 24L, 12L, 7L, 
    22L, 10L, 13L, 3L), .Label = c("Agnes Gonzales", "Amber Waters", 
    "Amelia Gray", "Audrey Abbott", "Carla Hill", "Cesar Lynch", 
    "Derrick Johnson", "Donnie Hayes", "Elena Gordon", "Frank Barnes", 
    "Glenn Reynolds", "Herman Jensen", "Jonathan Mitchell", "Julian Brooks", 
    "Kristine Conner", "Lydia Maxwell", "Marianne Vega", "Marion Steele", 
    "Marlene Jones", "Marvin Klein", "Maurice Kennedy", "Pete Hicks", 
    "Ron Parks", "Ted Briggs", "Vernon Frank"), class = "factor"), 
    course = structure(c(22L, 22L, 22L, 21L, 14L, 22L, 16L, 22L, 
    22L, 22L, 9L, 4L, 18L, 19L, 19L, 19L, 14L, 22L, 22L, 7L, 
    23L, 23L, 10L, 1L, 14L, 14L, 22L, 1L, 21L, 22L, 4L, 16L, 
    4L, 22L, 21L, 24L, 12L, 21L, 1L, 22L, 22L, 22L, 21L, 14L, 
    22L, 16L, 22L, 22L, 22L, 9L, 4L, 18L, 19L, 19L, 19L, 14L, 
    22L, 22L, 7L, 23L, 23L, 10L, 1L, 14L, 14L, 22L, 1L, 21L, 
    22L, 4L, 16L, 4L, 22L, 21L, 24L, 12L, 21L, 1L, 22L, 22L, 
    6L, 21L, 22L, 18L, 22L, 14L, 22L, 22L, 22L, 9L, 19L, 16L, 
    7L, 19L, 1L, 24L, 12L, 14L, 21L, 4L, 19L, 22L, 22L, 19L, 
    22L, 21L, 22L, 21L, 22L, 4L, 22L, 14L, 1L, 22L, 23L, 23L, 
    4L, 22L, 10L, 4L, 21L, 17L, 3L, 22L, 1L, 4L, 22L, 21L, 4L, 
    5L, 1L, 2L, 14L, 8L, 15L, 24L, 3L, 4L, 14L, 22L, 22L, 2L, 
    11L, 21L, 13L, 22L, 21L, 22L, 23L, 4L, 20L), .Label = c("Applied Multivariate Analysis", 
    "Basic Applied Statistics", "Basic Probability Theory", "Basic Statistics for Economics", 
    "Caclulus I", "Computing and Graphics in Applied Statistics", 
    "english I", "english II", "Independent Studies in Statistics", 
    "Intermediate Statistical Analysis", "Introduction to Experimental Design", 
    "Introduction to Sampling", "Introductory Statistics for Business", 
    "Level II Statistics", "Level III Statistics. ", "Managerial Statistics", 
    "Regression Methods", "Reliability-Quality Control", "Statistical Quality Control", 
    "Statistics for Social Work", "Statistics I", "Statistics II", 
    "Theory of Probability", "Theory of Statistics"), class = "factor"), 
    season = structure(c(2L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 
    2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 
    2L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 1L, 
    1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("regular", "summer"
    ), class = "factor"), class_size = c(19L, 17L, 49L, 33L, 
    55L, 20L, 19L, 27L, 58L, 20L, 9L, 30L, 29L, 39L, 42L, 43L, 
    10L, 46L, 10L, 42L, 27L, 23L, 31L, 22L, 37L, 13L, 24L, 38L, 
    42L, 28L, 51L, 19L, 31L, 13L, 37L, 36L, 21L, 48L, 38L, 19L, 
    17L, 49L, 33L, 55L, 20L, 19L, 27L, 58L, 20L, 9L, 30L, 29L, 
    39L, 42L, 43L, 10L, 46L, 10L, 42L, 27L, 23L, 31L, 22L, 37L, 
    13L, 24L, 38L, 42L, 28L, 51L, 19L, 31L, 13L, 37L, 36L, 21L, 
    48L, 38L, 25L, 17L, 11L, 39L, 11L, 19L, 45L, 20L, 20L, 20L, 
    38L, 17L, 19L, 24L, 25L, 31L, 31L, 18L, 22L, 27L, 14L, 20L, 
    35L, 20L, 20L, 37L, 15L, 25L, 10L, 14L, 38L, 29L, 19L, 30L, 
    32L, 27L, 34L, 23L, 66L, 12L, 29L, 19L, 3L, 17L, 7L, 21L, 
    36L, 54L, 29L, 45L, 11L, 16L, 18L, 44L, 17L, 21L, 20L, 24L, 
    5L, 42L, 30L, 19L, 11L, 29L, 15L, 37L, 10L, 24L, 26L, 12L, 
    48L, 51L, 27L), class = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
    3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
    2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
    3L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, 
    3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 2L, 
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 
    1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 2L, 2L, 2L, 
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("high", 
    "low", "medium"), class = "factor")), .Names = c("native_speaker", 
"course_instructor", "course", "season", "class_size", "class"
), class = "data.frame", row.names = c(NA, -151L))

0 个答案:

没有答案