Iris redux - a more robust accuracy.
In this exercise, you will build linear SVMs for 100 distinct training/test partitions of the iris dataset. You will then evaluate the performance of your model by calculating the mean accuracy and standard deviation. This procedure, which is quite general, will give you a far more robust measure of model performance than the ones obtained from a single partition.
Bu egzersiz
Support Vector Machines in R
kursunun bir parçasıdırEgzersiz talimatları
- For each trial:
- Partition the dataset into training and test sets in a random 80/20 split.
- Build a default cost linear SVM on the training dataset.
- Evaluate the accuracy of your model (
accuracyhas been initialized in your environment).
Uygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
for (i in 1:___){
#assign 80% of the data to the training set
sample_size <- ___(___ * nrow(iris))
train <- ___(seq_len(nrow(iris)), size = ___)
trainset <- iris[train, ]
testset <- iris[-train, ]
#build model using training data
svm_model <- svm(Species~ ., data = ___,
type = "C-classification", kernel = "linear")
#calculate accuracy on test data
pred_test <- predict(svm_model, ___)
accuracy[i] <- mean(pred_test == ___$Species)
}
mean(___)
sd(___)