0
$\begingroup$

I write this script in R about decision tree.

library(class)
library(ggplot2)
library(gmodels)
library(scales)
library(caret)
library(tidyverse)


db_data <- iris
row_train <- sample(nrow(iris), nrow(iris)*0.8)
db_train <- iris[row_train,]
db_test <- iris[-row_train,]

unique(db_train$Species)
table(db_train$Species)
model_dt<-train(Species ~ ., data = db_train, method = "rpart",tuneLenght = 9)
summary(model_dt)
#-------

#PREDICTION NEW RECORD
#-------
test_data <- db_test
db_test$predict <- predict(model_dt, newdata=test_data, interval='confidence')
confusionMatrix(data=factor(db_test$predict),reference=factor(db_test$Species))

but when I run model_dt I have this error:

  Error in train(Species ~ ., data = db_train, method = "rpart", tuneLenght = 9) : 
  unused arguments (data = db_train, method = "rpart", tuneLenght = 9)

why?

$\endgroup$

1 Answer 1

1
$\begingroup$

Something that is wrong is the spelling of tuneLength. The code has tuneLenght = 9. Maybe that will get the program further.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.