We have done below part -
To download the dataset,
heart_dataframe<-read.csv(url("https://dataaspirant.com/wp-content/uploads/2017/01/heart_tidy.csv"))
After which we have task -
- Capture the attribute names of the dataset while executing the algorithm.
- The training dataset should contain 60 percent data from the dataset.
- The testing dataset should contain the remaining data from the dataset.
for above we did
rows<-sample(nrow(heart_dataframe))
heart_dataframe<-heart_dataframe[rows, ]
split <- round(nrow(heart_dataframe) * .60)
train<-heart_dataframe[1:split,]
test<-heart_dataframe[(split+1):nrow(heart_dataframe),]
svm_train<-train(X63 ~.,data=train,method="svmLinear",
trControl=train_control,preProcess=c("center","scale"),tuneLength=10)
- Ensure that both the arguments of the confusion matrix are 'factors'.
- Store the result of the confusion matrix in a "cm" variable.
facing issue with factor and confusion matrix please help us, also whether above step is wrong or not. Please let us know
After completing the above steps, execute the following code to store the output in the file:
total<-cm$table[1,1]+cm$table[1,2]+cm$table[2,1]+cm$table[2,2]
writeLines(toString(total),"output.txt")