hello, i am so glad to write you.
i am dealing now with writing my M.Sc in Applied Statistics thesis, titled " 
Data Mining Classifiers and Predictive Models Validation and Evaluation".
I am planning to compare several DM classifiers like "NN, kNN, SVM, Dtree, and 
Naïve Bayes" according to their Predicting accuracy, interpretability, 
scalability, and time consuming etc.
I have faced a problem when I am writing the classification table using R
The problem is facing me at the last command.
The error is :
" tab <- table(pred = prediction, true = testset[,7])
Error in table(pred = prediction, true = testset[, 7]) : 
  all arguments must have the same length"
can you explain me the error please.
When I apply the code at iris data it works perfect. But when I use fish data 
at rrcov library I am facing this error. 
 
Thanx a lot in advanced
Mohammed 
 
Here is the code for modifying
 
library (rrcov)
data(fish)
library(e1071)
names(fish)
[1] "Weight"  "Length1" "Length2" "Length3" "Height"  "Width"   "Species"
 model  <- svm(Species~., data=fish,type="C")
 print(model)
summary(model)
index <- 1:nrow(fish)
 testindex <- sample(index, trunc(length(index)*30/100))
 testset <- fish[testindex,]
 trainset <- fish[-testindex,]
 model <- svm(Species~., data = trainset)
  prediction <- predict(model, testset[,-7])
  tab <- table(pred = prediction, true = testset[,7])
Error in table(pred = prediction, true = testset[, 7]) : 
  all arguments must have the same length
 
the same error I found when using the naïvebayes classifier
 
library(e1071)
library(class) 
data(fish)
summary(fish)
classifier<-naiveBayes(fish[,1:6], fish[,7]) 
 table(predict(classifier, fish[,-7]), fish[,7])
Error in table(predict(classifier, fish[, -7]), fish[, 7]) : 
  all arguments must have the same length
                                          
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to