MM1 Last 5: > mm1Frame<-data.frame(gooddata[,1:70],gooddata[,71]) > colnames(mm1Frame)[71]<-"success" > mm1Frame$success<-as.factor(as.logical(mm1Frame$success)) > > set.seed(600) > mm1Frame[,"train"] <- ifelse(runif(nrow(mm1Frame))<0.75,1,0) > trainset <- mm1Frame[mm1Frame$train==1,] > testset <- mm1Frame[mm1Frame$train==0,] > trainColNum <- grep("train",names(trainset)) > trainset <- trainset[,-trainColNum] > testset <- testset[,-trainColNum] > typeColNum <- grep("success",names(mm1Frame)) > > #SVM > #https://eight2late.wordpress.com/2017/02/07/a-gentle-introduction-to-support-vector-machines-using-r/ > #Linear > set.seed(600) > svm_model <- svm(success~., data=trainset, method="C-classification", kernel="linear") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "linear") Parameters: SVM-Type: C-classification SVM-Kernel: linear cost: 1 gamma: 0.01428571 Number of Support Vectors: 52 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.979021 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.8490566 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 0 6 TRUE 2 45 > > #Radial > set.seed(600) > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="radial") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "radial") Parameters: SVM-Type: C-classification SVM-Kernel: radial cost: 1 gamma: 0.01428571 Number of Support Vectors: 91 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.9160839 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.9622642 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 0 0 TRUE 2 51 > > #Sigmoid > set.seed(600) > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="sigmoid") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "sigmoid") Parameters: SVM-Type: C-classification SVM-Kernel: sigmoid cost: 1 gamma: 0.01428571 coef.0: 0 Number of Support Vectors: 32 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.9090909 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.9622642 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 0 0 TRUE 2 51 > > #Polynomial > set.seed(600) > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="polynomial") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "polynomial") Parameters: SVM-Type: C-classification SVM-Kernel: polynomial cost: 1 degree: 3 gamma: 0.01428571 coef.0: 0 Number of Support Vectors: 83 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.9370629 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.9433962 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 0 1 TRUE 2 50 > > #Tuning for radial > set.seed(600) > tune_out <- tune.svm(x=trainset[,-typeColNum],y=trainset[,typeColNum],gamma=10^(-3:3),cost=c(0.01,0.1,1,10,100,1000),kernel="radial") > tune_out$best.parameters$cost [1] 0.01 > tune_out$best.parameters$gamma [1] 0.001 > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="radial",cost=tune_out$best.parameters$cost,gamma=tune_out$best.parameters$gamma) > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.9090909 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.9622642 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 0 0 TRUE 2 51 > > #https://www.r-bloggers.com/understanding-naive-bayes-classifier-using-r/ > #Naive Bayes > set.seed(600) > nb_model <- naiveBayes(success ~ ., data =trainset) > summary(nb_model) Length Class Mode apriori 2 table numeric tables 70 -none- list levels 2 -none- character call 4 -none- call > pred_train <-predict(nb_model,trainset) > mean(pred_train==trainset$success) [1] 0.7272727 > pred_test <-predict(nb_model,testset) > mean(pred_test==testset$success) [1] 0.5471698 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 0 22 TRUE 2 29 kreis1konz last 5: > set.seed(600) > kr1konzFrame[,"train"] <- ifelse(runif(nrow(kr1konzFrame))<0.75,1,0) > trainset <- kr1konzFrame[kr1konzFrame$train==1,] > testset <- kr1konzFrame[kr1konzFrame$train==0,] > trainColNum <- grep("train",names(trainset)) > trainset <- trainset[,-trainColNum] > testset <- testset[,-trainColNum] > typeColNum <- grep("success",names(kr1konzFrame)) > > #SVM > #https://eight2late.wordpress.com/2017/02/07/a-gentle-introduction-to-support-vector-machines-using-r/ > #Linear > set.seed(600) > svm_model <- svm(success~., data=trainset, method="C-classification", kernel="linear") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "linear") Parameters: SVM-Type: C-classification SVM-Kernel: linear cost: 1 gamma: 0.01428571 Number of Support Vectors: 103 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.8251748 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.5660377 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 25 14 TRUE 9 5 > > #Radial > set.seed(600) > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="radial") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "radial") Parameters: SVM-Type: C-classification SVM-Kernel: radial cost: 1 gamma: 0.01428571 Number of Support Vectors: 129 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.7762238 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.6603774 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 32 16 TRUE 2 3 > > #Sigmoid > set.seed(600) > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="sigmoid") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "sigmoid") Parameters: SVM-Type: C-classification SVM-Kernel: sigmoid cost: 1 gamma: 0.01428571 coef.0: 0 Number of Support Vectors: 117 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.5874126 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.6226415 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 30 16 TRUE 4 3 > > #Polynomial > set.seed(600) > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="polynomial") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "polynomial") Parameters: SVM-Type: C-classification SVM-Kernel: polynomial cost: 1 degree: 3 gamma: 0.01428571 coef.0: 0 Number of Support Vectors: 132 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.7412587 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.6226415 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 31 17 TRUE 3 2 > > #Tuning for radial > set.seed(600) > tune_out <- tune.svm(x=trainset[,-typeColNum],y=trainset[,typeColNum],gamma=10^(-3:3),cost=c(0.01,0.1,1,10,100,1000),kernel="radial") > tune_out$best.parameters$cost [1] 1 > tune_out$best.parameters$gamma [1] 0.1 > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="radial",cost=tune_out$best.parameters$cost,gamma=tune_out$best.parameters$gamma) > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.986014 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.6603774 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 32 16 TRUE 2 3 > > #https://www.r-bloggers.com/understanding-naive-bayes-classifier-using-r/ > #Naive Bayes > set.seed(600) > nb_model <- naiveBayes(success ~ ., data =trainset) > summary(nb_model) Length Class Mode apriori 2 table numeric tables 70 -none- list levels 2 -none- character call 4 -none- call > pred_train <-predict(nb_model,trainset) > mean(pred_train==trainset$success) [1] 0.6643357 > pred_test <-predict(nb_model,testset) > mean(pred_test==testset$success) [1] 0.5283019 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 22 13 TRUE 12 6 kreis2konz last 5: > set.seed(600) > kr2konzFrame[,"train"] <- ifelse(runif(nrow(kr2konzFrame))<0.75,1,0) > trainset <- kr2konzFrame[kr2konzFrame$train==1,] > testset <- kr2konzFrame[kr2konzFrame$train==0,] > trainColNum <- grep("train",names(trainset)) > trainset <- trainset[,-trainColNum] > testset <- testset[,-trainColNum] > typeColNum <- grep("success",names(kr2konzFrame)) > > #SVM > #https://eight2late.wordpress.com/2017/02/07/a-gentle-introduction-to-support-vector-machines-using-r/ > #Linear > set.seed(600) > svm_model <- svm(success~., data=trainset, method="C-classification", kernel="linear") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "linear") Parameters: SVM-Type: C-classification SVM-Kernel: linear cost: 1 gamma: 0.01428571 Number of Support Vectors: 104 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.8461538 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.5283019 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 26 18 TRUE 7 2 > > #Radial > set.seed(600) > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="radial") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "radial") Parameters: SVM-Type: C-classification SVM-Kernel: radial cost: 1 gamma: 0.01428571 Number of Support Vectors: 130 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.7342657 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.6226415 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 33 20 TRUE 0 0 > > #Sigmoid > set.seed(600) > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="sigmoid") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "sigmoid") Parameters: SVM-Type: C-classification SVM-Kernel: sigmoid cost: 1 gamma: 0.01428571 coef.0: 0 Number of Support Vectors: 110 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.5804196 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.5660377 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 30 20 TRUE 3 0 > > #Polynomial > set.seed(600) > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="polynomial") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "polynomial") Parameters: SVM-Type: C-classification SVM-Kernel: polynomial cost: 1 degree: 3 gamma: 0.01428571 coef.0: 0 Number of Support Vectors: 130 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.7622378 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.6037736 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 31 19 TRUE 2 1 > > #Tuning for radial > set.seed(600) > tune_out <- tune.svm(x=trainset[,-typeColNum],y=trainset[,typeColNum],gamma=10^(-3:3),cost=c(0.01,0.1,1,10,100,1000),kernel="radial") > tune_out$best.parameters$cost [1] 1 > tune_out$best.parameters$gamma [1] 0.1 > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="radial",cost=tune_out$best.parameters$cost,gamma=tune_out$best.parameters$gamma) > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.986014 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.6226415 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 32 19 TRUE 1 1 > > > #https://www.r-bloggers.com/understanding-naive-bayes-classifier-using-r/ > #Naive Bayes > set.seed(600) > nb_model <- naiveBayes(success ~ ., data =trainset) > summary(nb_model) Length Class Mode apriori 2 table numeric tables 70 -none- list levels 2 -none- character call 4 -none- call > pred_train <-predict(nb_model,trainset) > mean(pred_train==trainset$success) [1] 0.6643357 > pred_test <-predict(nb_model,testset) > mean(pred_test==testset$success) [1] 0.5660377 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 26 16 TRUE 7 4 zyldurch last 5: > set.seed(600) > zyldurchFrame[,"train"] <- ifelse(runif(nrow(zyldurchFrame))<0.75,1,0) > trainset <- zyldurchFrame[zyldurchFrame$train==1,] > testset <- zyldurchFrame[zyldurchFrame$train==0,] > trainColNum <- grep("train",names(trainset)) > trainset <- trainset[,-trainColNum] > testset <- testset[,-trainColNum] > typeColNum <- grep("success",names(zyldurchFrame)) > > #SVM > #https://eight2late.wordpress.com/2017/02/07/a-gentle-introduction-to-support-vector-machines-using-r/ > #Linear > set.seed(600) > svm_model <- svm(success~., data=trainset, method="C-classification", kernel="linear") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "linear") Parameters: SVM-Type: C-classification SVM-Kernel: linear cost: 1 gamma: 0.01428571 Number of Support Vectors: 76 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.8811189 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.6792453 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 2 6 TRUE 11 34 > > #Radial > set.seed(600) > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="radial") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "radial") Parameters: SVM-Type: C-classification SVM-Kernel: radial cost: 1 gamma: 0.01428571 Number of Support Vectors: 114 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.8111888 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.754717 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 0 0 TRUE 13 40 > > #Sigmoid > set.seed(600) > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="sigmoid") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "sigmoid") Parameters: SVM-Type: C-classification SVM-Kernel: sigmoid cost: 1 gamma: 0.01428571 coef.0: 0 Number of Support Vectors: 70 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.7622378 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.7735849 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 1 0 TRUE 12 40 > > #Polynomial > set.seed(600) > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="polynomial") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "polynomial") Parameters: SVM-Type: C-classification SVM-Kernel: polynomial cost: 1 degree: 3 gamma: 0.01428571 coef.0: 0 Number of Support Vectors: 111 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.8741259 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.7358491 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 1 2 TRUE 12 38 > > #Tuning for radial > set.seed(600) > tune_out <- tune.svm(x=trainset[,-typeColNum],y=trainset[,typeColNum],gamma=10^(-3:3),cost=c(0.01,0.1,1,10,100,1000),kernel="radial") > tune_out$best.parameters$cost [1] 0.01 > tune_out$best.parameters$gamma [1] 0.001 > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="radial",cost=tune_out$best.parameters$cost,gamma=tune_out$best.parameters$gamma) > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.7832168 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.754717 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 0 0 TRUE 13 40 > > #https://www.r-bloggers.com/understanding-naive-bayes-classifier-using-r/ > #Naive Bayes > set.seed(600) > nb_model <- naiveBayes(success ~ ., data =trainset) > summary(nb_model) Length Class Mode apriori 2 table numeric tables 70 -none- list levels 2 -none- character call 4 -none- call > pred_train <-predict(nb_model,trainset) > mean(pred_train==trainset$success) [1] 0.7132867 > pred_test <-predict(nb_model,testset) > mean(pred_test==testset$success) [1] 0.6037736 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 2 10 TRUE 11 30 zyldurch last 5 feature selection: > set.seed(600) > zyldurchFrame<-data.frame(gooddata[,1:70],gooddata[,83]) > colnames(zyldurchFrame)[71]<-"success" > > zyldurchFrame$success<-as.factor(as.logical(zyldurchFrame$success)) > > #https://machinelearningmastery.com/feature-selection-with-the-caret-r-package/ > #feature selection(recursive feature elimination) > control <- rfeControl(functions=rfFuncs, method="cv", number=5) > results <- rfe(zyldurchFrame[,1:70], zyldurchFrame[,71], sizes=c(1:70), rfeControl=control) > print(results) Recursive feature selection Outer resampling method: Cross-Validated (5 fold) Resampling performance over subset size: Variables Accuracy Kappa AccuracySD KappaSD Selected 1 0.6229 -0.115453 0.08579 0.15496 2 0.7148 -0.013958 0.04853 0.12284 3 0.7298 -0.004031 0.06424 0.08083 4 0.7295 0.028579 0.04217 0.04731 5 0.7402 0.044906 0.03784 0.03009 6 0.7199 -0.025709 0.04627 0.04592 7 0.7352 -0.006665 0.03350 0.08410 8 0.7453 0.053310 0.03134 0.04368 9 0.7301 0.005789 0.03385 0.06852 10 0.7298 -0.017446 0.01831 0.08851 11 0.7348 -0.008664 0.02745 0.11708 12 0.7452 -0.008563 0.02800 0.08499 13 0.7401 -0.016865 0.02990 0.06199 14 0.7603 0.042999 0.03724 0.10222 15 0.7503 0.002711 0.03899 0.07873 16 0.7353 -0.009600 0.08197 0.16610 17 0.7301 -0.072039 0.06292 0.09088 18 0.7352 -0.063396 0.06273 0.09061 19 0.7301 -0.067418 0.07425 0.10703 20 0.7402 -0.032840 0.05179 0.09918 21 0.7402 -0.032840 0.05179 0.09918 22 0.7501 0.003923 0.04053 0.11880 23 0.7553 -0.010217 0.03121 0.07293 24 0.7402 -0.061060 0.03784 0.05949 25 0.7451 -0.029572 0.02854 0.07434 26 0.7247 -0.084687 0.04653 0.07071 27 0.7449 -0.053420 0.02992 0.05612 28 0.7352 -0.042264 0.04870 0.09750 29 0.7401 -0.035328 0.04280 0.09180 30 0.7449 -0.053420 0.02992 0.05612 31 0.7398 -0.062064 0.03231 0.05843 32 0.7347 -0.071741 0.02825 0.04879 33 0.7398 -0.062064 0.03231 0.05843 34 0.7501 -0.043743 0.03177 0.06115 35 0.7502 -0.019894 0.03045 0.07443 36 0.7502 -0.019894 0.03045 0.07443 37 0.7555 -0.009742 0.03516 0.09209 38 0.7552 -0.012364 0.02061 0.06173 39 0.7552 -0.012364 0.02061 0.06173 40 0.7553 -0.012111 0.01868 0.06155 41 0.7605 -0.002212 0.02585 0.08100 42 0.7552 -0.012364 0.02061 0.06173 43 0.7552 -0.012364 0.02061 0.06173 44 0.7552 -0.012364 0.02061 0.06173 45 0.7552 -0.012364 0.02061 0.06173 46 0.7552 -0.012364 0.02061 0.06173 47 0.7552 -0.012364 0.02061 0.06173 48 0.7605 -0.002212 0.02585 0.08100 49 0.7552 -0.012364 0.02061 0.06173 50 0.7605 -0.002212 0.02585 0.08100 51 0.7656 0.007466 0.02415 0.07689 * 52 0.7605 -0.002212 0.02585 0.08100 53 0.7605 -0.002212 0.02585 0.08100 54 0.7552 -0.012364 0.02061 0.06173 55 0.7605 -0.002212 0.02585 0.08100 56 0.7551 -0.036213 0.02255 0.04960 57 0.7603 -0.002687 0.02019 0.05838 58 0.7656 0.007466 0.02415 0.07689 59 0.7605 -0.002212 0.02585 0.08100 60 0.7656 0.007466 0.02415 0.07689 61 0.7603 -0.027638 0.02019 0.04040 62 0.7656 0.007466 0.02415 0.07689 63 0.7603 -0.027638 0.02019 0.04040 64 0.7656 0.007466 0.02415 0.07689 65 0.7603 -0.027638 0.02019 0.04040 66 0.7605 -0.002212 0.02585 0.08100 67 0.7605 -0.002212 0.02585 0.08100 68 0.7656 0.007466 0.02415 0.07689 69 0.7603 -0.027638 0.02019 0.04040 70 0.7656 0.007466 0.02415 0.07689 The top 5 variables (out of 51): ns.2.s..Channel.MachineAxis.aaLoad.u1.2.1, ns.2.s..Channel.MachineAxis.aaLoad.u1.2.2, ns.2.s..Channel.MachineAxis.aaLeadP.u1.1.5, ns.2.s..Channel.MachineAxis.aaLeadP.u1.1.4, ns.2.s..Channel.MachineAxis.aaLoad.u1.2.4 > predictors(results) [1] "ns.2.s..Channel.MachineAxis.aaLoad.u1.2.1" "ns.2.s..Channel.MachineAxis.aaLoad.u1.2.2" "ns.2.s..Channel.MachineAxis.aaLeadP.u1.1.5" "ns.2.s..Channel.MachineAxis.aaLeadP.u1.1.4" [5] "ns.2.s..Channel.MachineAxis.aaLoad.u1.2.4" "ns.2.s..Channel.MachineAxis.aaLoad.u1.2.3" "ns.2.s..Channel.Spindle.driveLoad3" "ns.2.s..Channel.MachineAxis.aaTorque.u1.3.5" [9] "ns.2.s..Channel.MachineAxis.aaTorque.u1.3.3" "ns.2.s..Channel.MachineAxis.aaTorque.u1.2.3" "ns.2.s..Channel.MachineAxis.aaLoad.u1.3.3" "ns.2.s..Channel.MachineAxis.aaLoad.u1.3.1" [13] "ns.2.s..Channel.MachineAxis.aaTorque.u1.2.5" "ns.2.s..Channel.MachineAxis.aaLoad.u1.1.4" "ns.2.s..Channel.Spindle.driveLoad5" "ns.2.s..Channel.MachineAxis.aaLoad.u1.3.4" [17] "ns.2.s..Channel.MachineAxis.aaTorque.u1.1.4" "ns.2.s..Channel.MachineAxis.aaLoad.u1.1.2" "ns.2.s..Channel.MachineAxis.aaTorque.u1.2.4" "ns.2.s..Channel.Spindle.actSpeed1" [21] "ns.2.s..Channel.MachineAxis.aaVactB.u1.2.4" "ns.2.s..Channel.MachineAxis.aaLoad.u1.2.5" "ns.2.s..Channel.Spindle.driveLoad2" "ns.2.s..Channel.MachineAxis.aaLoad.u1.3.5" [25] "ns.2.s..Channel.MachineAxis.aaVactB.u1.1.5" "ns.2.s..Channel.MachineAxis.aaLoad.u1.3.2" "ns.2.s..Channel.MachineAxis.aaVactB.u1.3.5" "ns.2.s..Channel.Spindle.actSpeed2" [29] "ns.2.s..Channel.MachineAxis.aaTorque.u1.3.2" "ns.2.s..Channel.MachineAxis.aaVactB.u1.2.2" "ns.2.s..Channel.MachineAxis.aaLeadP.u1.3.3" "ns.2.s..Channel.MachineAxis.aaTorque.u1.3.4" [33] "ns.2.s..Channel.MachineAxis.aaVactB.u1.2.1" "ns.2.s..Channel.MachineAxis.aaVactB.u1.2.5" "ns.2.s..Channel.MachineAxis.aaVactB.u1.1.2" "ns.2.s..Channel.MachineAxis.aaLeadP.u1.2.2" [37] "ns.2.s..Channel.MachineAxis.aaVactB.u1.1.4" "ns.2.s..Channel.MachineAxis.aaLeadP.u1.2.4" "ns.2.s..Channel.MachineAxis.aaTorque.u1.1.1" "ns.2.s..Channel.MachineAxis.aaTorque.u1.1.5" [41] "ns.2.s..Channel.MachineAxis.aaLeadP.u1.1.2" "ns.2.s..Channel.MachineAxis.aaLoad.u1.1.5" "ns.2.s..Channel.MachineAxis.aaLeadP.u1.2.1" "ns.2.s..Channel.MachineAxis.aaVactB.u1.1.3" [45] "ns.2.s..Channel.Spindle.driveLoad1" "ns.2.s..Channel.Spindle.driveLoad4" "ns.2.s..Channel.Spindle.actSpeed4" "ns.2.s..Channel.MachineAxis.aaLeadP.u1.1.3" [49] "ns.2.s..Channel.MachineAxis.aaTorque.u1.3.1" "ns.2.s..Channel.MachineAxis.aaLoad.u1.1.1" "ns.2.s..Channel.MachineAxis.aaVactB.u1.2.3" > plot(results, type=c("g", "o")) ns.2.s..Channel.MachineAxis.aaLoad.u1.2.1 ns.2.s..Channel.MachineAxis.aaLoad.u1.2.2 ns.2.s..Channel.MachineAxis.aaLeadP.u1.1.5 ns.2.s..Channel.MachineAxis.aaLeadP.u1.1.4 ns.2.s..Channel.MachineAxis.aaLoad.u1.2.4 ns.2.s..Channel.MachineAxis.aaLoad.u1.2.3 ns.2.s..Channel.Spindle.driveLoad3 ns.2.s..Channel.MachineAxis.aaTorque.u1.3.5 ns.2.s..Channel.MachineAxis.aaTorque.u1.3.3 ns.2.s..Channel.MachineAxis.aaTorque.u1.2.3 ns.2.s..Channel.MachineAxis.aaLoad.u1.3.3 ns.2.s..Channel.MachineAxis.aaLoad.u1.3.1 ns.2.s..Channel.MachineAxis.aaTorque.u1.2.5 ns.2.s..Channel.MachineAxis.aaLoad.u1.1.4 > reduceddata <- data.frame(zyldurchFrame$ns.2.s..Channel.MachineAxis.aaLoad.u1.2.1, + zyldurchFrame$ns.2.s..Channel.MachineAxis.aaLoad.u1.2.2, + zyldurchFrame$ns.2.s..Channel.MachineAxis.aaLeadP.u1.1.5, + zyldurchFrame$ns.2.s..Channel.MachineAxis.aaLeadP.u1.1.4, + zyldurchFrame$ns.2.s..Channel.MachineAxis.aaLoad.u1.2.4, + zyldurchFrame$ns.2.s..Channel.MachineAxis.aaLoad.u1.2.3, + zyldurchFrame$ns.2.s..Channel.Spindle.driveLoad3, + zyldurchFrame$ns.2.s..Channel.MachineAxis.aaTorque.u1.3.5, + zyldurchFrame$ns.2.s..Channel.MachineAxis.aaTorque.u1.3.3, + zyldurchFrame$ns.2.s..Channel.MachineAxis.aaTorque.u1.2.3, + zyldurchFrame$ns.2.s..Channel.MachineAxis.aaLoad.u1.3.3, + zyldurchFrame$ns.2.s..Channel.MachineAxis.aaLoad.u1.3.1, + zyldurchFrame$ns.2.s..Channel.MachineAxis.aaTorque.u1.2.5, + zyldurchFrame$ns.2.s..Channel.MachineAxis.aaLoad.u1.1.4, + zyldurchFrame$success) > #Splitting data into test and training data 75/25 > set.seed(600) > reduceddata[,"train"] <- ifelse(runif(nrow(reduceddata))<0.75,1,0) > trainset <- reduceddata[reduceddata$train==1,] > testset <- reduceddata[reduceddata$train==0,] > trainColNum <- grep("train",names(trainset)) > trainset <- trainset[,-trainColNum] > testset <- testset[,-trainColNum] > typeColNum <- grep("success",names(reduceddata)) > #SVM > #https://eight2late.wordpress.com/2017/02/07/a-gentle-introduction-to-support-vector-machines-using-r/ > #Linear > set.seed(600) > svm_model <- svm(zyldurchFrame.success~., data=trainset, method="C-classification", kernel="linear") > svm_model Call: svm(formula = zyldurchFrame.success ~ ., data = trainset, method = "C-classification", kernel = "linear") Parameters: SVM-Type: C-classification SVM-Kernel: linear cost: 1 gamma: 0.07142857 Number of Support Vectors: 80 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$zyldurchFrame.success) [1] 0.7832168 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$zyldurchFrame.success) [1] 0.754717 > confusion(pred_test,testset$zyldurchFrame.success) true predicted FALSE TRUE FALSE 0 0 TRUE 13 40 > > > #Radial > set.seed(600) > svm_model <- svm(zyldurchFrame.success~ ., data=trainset, method="C-classification", kernel="radial") > svm_model Call: svm(formula = zyldurchFrame.success ~ ., data = trainset, method = "C-classification", kernel = "radial") Parameters: SVM-Type: C-classification SVM-Kernel: radial cost: 1 gamma: 0.07142857 Number of Support Vectors: 87 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$zyldurchFrame.success) [1] 0.7902098 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$zyldurchFrame.success) [1] 0.754717 > confusion(pred_test,testset$zyldurchFrame.success) true predicted FALSE TRUE FALSE 0 0 TRUE 13 40 > > #Sigmoid > set.seed(600) > svm_model <- svm(zyldurchFrame.success~ ., data=trainset, method="C-classification", kernel="sigmoid") > svm_model Call: svm(formula = zyldurchFrame.success ~ ., data = trainset, method = "C-classification", kernel = "sigmoid") Parameters: SVM-Type: C-classification SVM-Kernel: sigmoid cost: 1 gamma: 0.07142857 coef.0: 0 Number of Support Vectors: 63 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$zyldurchFrame.success) [1] 0.7552448 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$zyldurchFrame.success) [1] 0.754717 > confusion(pred_test,testset$zyldurchFrame.success) true predicted FALSE TRUE FALSE 0 0 TRUE 13 40 > > #Polynomial > set.seed(600) > svm_model <- svm(zyldurchFrame.success~ ., data=trainset, method="C-classification", kernel="polynomial") > svm_model Call: svm(formula = zyldurchFrame.success ~ ., data = trainset, method = "C-classification", kernel = "polynomial") Parameters: SVM-Type: C-classification SVM-Kernel: polynomial cost: 1 degree: 3 gamma: 0.07142857 coef.0: 0 Number of Support Vectors: 78 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$zyldurchFrame.success) [1] 0.8251748 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$zyldurchFrame.success) [1] 0.7358491 > confusion(pred_test,testset$zyldurchFrame.success) true predicted FALSE TRUE FALSE 1 2 TRUE 12 38 > > > #Tuning for radial > set.seed(600) > tune_out <- tune.svm(x=trainset[,-typeColNum],y=trainset[,typeColNum],gamma=10^(-3:3),cost=c(0.01,0.1,1,10,100,1000),kernel="radial") > tune_out$best.parameters$cost [1] 1 > tune_out$best.parameters$gamma [1] 1 > svm_model <- svm(zyldurchFrame.success~ ., data=trainset, method="C-classification", kernel="radial",cost=tune_out$best.parameters$cost,gamma=tune_out$best.parameters$gamma) > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$zyldurchFrame.success) [1] 0.8741259 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$zyldurchFrame.success) [1] 0.754717 > confusion(pred_test,testset$zyldurchFrame.success) true predicted FALSE TRUE FALSE 0 0 TRUE 13 40 > > > #https://www.r-bloggers.com/understanding-naive-bayes-classifier-using-r/ > #Naive Bayes > set.seed(600) > nb_model <- naiveBayes(zyldurchFrame.success ~ ., data =trainset) > summary(nb_model) Length Class Mode apriori 2 table numeric tables 14 -none- list levels 2 -none- character call 4 -none- call > pred_train <-predict(nb_model,trainset) > mean(pred_train==trainset$zyldurchFrame.success) [1] 0.6923077 > pred_test <-predict(nb_model,testset) > mean(pred_test==testset$zyldurchFrame.success) [1] 0.6037736 > confusion(pred_test,testset$zyldurchFrame.success) true predicted FALSE TRUE FALSE 3 11 TRUE 10 29 mm1 first 5: > set.seed(600) > mm1Frame<-data.frame(gooddata[,1:70],gooddata[,71]) > colnames(mm1Frame)[71]<-"success" > mm1Frame$success<-as.factor(as.logical(mm1Frame$success)) > > set.seed(600) > mm1Frame[,"train"] <- ifelse(runif(nrow(mm1Frame))<0.75,1,0) > trainset <- mm1Frame[mm1Frame$train==1,] > testset <- mm1Frame[mm1Frame$train==0,] > trainColNum <- grep("train",names(trainset)) > trainset <- trainset[,-trainColNum] > testset <- testset[,-trainColNum] > typeColNum <- grep("success",names(mm1Frame)) > > #SVM > #https://eight2late.wordpress.com/2017/02/07/a-gentle-introduction-to-support-vector-machines-using-r/ > #Linear > set.seed(600) > svm_model <- svm(success~., data=trainset, method="C-classification", kernel="linear") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "linear") Parameters: SVM-Type: C-classification SVM-Kernel: linear cost: 1 gamma: 0.01428571 Number of Support Vectors: 40 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.993007 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.8301887 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 0 7 TRUE 2 44 > > #Radial > set.seed(600) > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="radial") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "radial") Parameters: SVM-Type: C-classification SVM-Kernel: radial cost: 1 gamma: 0.01428571 Number of Support Vectors: 84 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.9300699 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.9622642 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 0 0 TRUE 2 51 > > #Sigmoid > set.seed(600) > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="sigmoid") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "sigmoid") Parameters: SVM-Type: C-classification SVM-Kernel: sigmoid cost: 1 gamma: 0.01428571 coef.0: 0 Number of Support Vectors: 35 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.9020979 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.9622642 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 0 0 TRUE 2 51 > > #Polynomial > set.seed(600) > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="polynomial") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "polynomial") Parameters: SVM-Type: C-classification SVM-Kernel: polynomial cost: 1 degree: 3 gamma: 0.01428571 coef.0: 0 Number of Support Vectors: 104 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.9370629 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.9622642 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 0 0 TRUE 2 51 > > #Tuning for radial > set.seed(600) > tune_out <- tune.svm(x=trainset[,-typeColNum],y=trainset[,typeColNum],gamma=10^(-3:3),cost=c(0.01,0.1,1,10,100,1000),kernel="radial") > tune_out$best.parameters$cost [1] 0.01 > tune_out$best.parameters$gamma [1] 0.001 > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="radial",cost=tune_out$best.parameters$cost,gamma=tune_out$best.parameters$gamma) > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.9090909 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.9622642 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 0 0 TRUE 2 51 > > #https://www.r-bloggers.com/understanding-naive-bayes-classifier-using-r/ > #Naive Bayes > set.seed(600) > nb_model <- naiveBayes(success ~ ., data =trainset) > summary(nb_model) Length Class Mode apriori 2 table numeric tables 70 -none- list levels 2 -none- character call 4 -none- call > pred_train <-predict(nb_model,trainset) > mean(pred_train==trainset$success) [1] 0.3356643 > pred_test <-predict(nb_model,testset) > mean(pred_test==testset$success) [1] 0.1132075 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 1 46 TRUE 1 5 kreis1konz first 5: > set.seed(600) > kr1konzFrame[,"train"] <- ifelse(runif(nrow(kr1konzFrame))<0.75,1,0) > trainset <- kr1konzFrame[kr1konzFrame$train==1,] > testset <- kr1konzFrame[kr1konzFrame$train==0,] > trainColNum <- grep("train",names(trainset)) > trainset <- trainset[,-trainColNum] > testset <- testset[,-trainColNum] > typeColNum <- grep("success",names(kr1konzFrame)) > > #SVM > #https://eight2late.wordpress.com/2017/02/07/a-gentle-introduction-to-support-vector-machines-using-r/ > #Linear > set.seed(600) > svm_model <- svm(success~., data=trainset, method="C-classification", kernel="linear") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "linear") Parameters: SVM-Type: C-classification SVM-Kernel: linear cost: 1 gamma: 0.01428571 Number of Support Vectors: 83 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.8881119 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.5660377 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 20 9 TRUE 14 10 > > #Radial > set.seed(600) > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="radial") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "radial") Parameters: SVM-Type: C-classification SVM-Kernel: radial cost: 1 gamma: 0.01428571 Number of Support Vectors: 126 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.8811189 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.6226415 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 30 16 TRUE 4 3 > > #Sigmoid > set.seed(600) > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="sigmoid") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "sigmoid") Parameters: SVM-Type: C-classification SVM-Kernel: sigmoid cost: 1 gamma: 0.01428571 coef.0: 0 Number of Support Vectors: 117 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.6853147 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.6037736 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 26 13 TRUE 8 6 > > #Polynomial > set.seed(600) > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="polynomial") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "polynomial") Parameters: SVM-Type: C-classification SVM-Kernel: polynomial cost: 1 degree: 3 gamma: 0.01428571 coef.0: 0 Number of Support Vectors: 136 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.6993007 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.6415094 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 34 19 TRUE 0 0 > > #Tuning for radial > set.seed(600) > tune_out <- tune.svm(x=trainset[,-typeColNum],y=trainset[,typeColNum],gamma=10^(-3:3),cost=c(0.01,0.1,1,10,100,1000),kernel="radial") > tune_out$best.parameters$cost [1] 10 > tune_out$best.parameters$gamma [1] 0.001 > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="radial",cost=tune_out$best.parameters$cost,gamma=tune_out$best.parameters$gamma) > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.8251748 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.5660377 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 24 13 TRUE 10 6 > > #https://www.r-bloggers.com/understanding-naive-bayes-classifier-using-r/ > #Naive Bayes > set.seed(600) > nb_model <- naiveBayes(success ~ ., data =trainset) > summary(nb_model) Length Class Mode apriori 2 table numeric tables 70 -none- list levels 2 -none- character call 4 -none- call > pred_train <-predict(nb_model,trainset) > mean(pred_train==trainset$success) [1] 0.4265734 > pred_test <-predict(nb_model,testset) > mean(pred_test==testset$success) [1] 0.3773585 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 1 0 TRUE 33 19 kreis2konz first 5: > set.seed(600) > kr2konzFrame<-data.frame(gooddata[,1:70],gooddata[,82]) > colnames(kr2konzFrame)[71]<-"success" > kr2konzFrame$success<-as.factor(as.logical(kr2konzFrame$success)) > > set.seed(600) > kr2konzFrame[,"train"] <- ifelse(runif(nrow(kr2konzFrame))<0.75,1,0) > trainset <- kr2konzFrame[kr2konzFrame$train==1,] > testset <- kr2konzFrame[kr2konzFrame$train==0,] > trainColNum <- grep("train",names(trainset)) > trainset <- trainset[,-trainColNum] > testset <- testset[,-trainColNum] > typeColNum <- grep("success",names(kr2konzFrame)) > > #SVM > #https://eight2late.wordpress.com/2017/02/07/a-gentle-introduction-to-support-vector-machines-using-r/ > #Linear > set.seed(600) > svm_model <- svm(success~., data=trainset, method="C-classification", kernel="linear") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "linear") Parameters: SVM-Type: C-classification SVM-Kernel: linear cost: 1 gamma: 0.01428571 Number of Support Vectors: 87 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.8881119 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.5283019 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 23 15 TRUE 10 5 > > #Radial > set.seed(600) > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="radial") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "radial") Parameters: SVM-Type: C-classification SVM-Kernel: radial cost: 1 gamma: 0.01428571 Number of Support Vectors: 130 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.8531469 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.6037736 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 32 20 TRUE 1 0 > > #Sigmoid > set.seed(600) > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="sigmoid") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "sigmoid") Parameters: SVM-Type: C-classification SVM-Kernel: sigmoid cost: 1 gamma: 0.01428571 coef.0: 0 Number of Support Vectors: 113 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.6573427 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.6037736 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 29 17 TRUE 4 3 > > #Polynomial > set.seed(600) > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="polynomial") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "polynomial") Parameters: SVM-Type: C-classification SVM-Kernel: polynomial cost: 1 degree: 3 gamma: 0.01428571 coef.0: 0 Number of Support Vectors: 137 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.7202797 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.6226415 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 33 20 TRUE 0 0 > > #Tuning for radial > set.seed(600) > tune_out <- tune.svm(x=trainset[,-typeColNum],y=trainset[,typeColNum],gamma=10^(-3:3),cost=c(0.01,0.1,1,10,100,1000),kernel="radial") > tune_out$best.parameters$cost [1] 10 > tune_out$best.parameters$gamma [1] 0.001 > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="radial",cost=tune_out$best.parameters$cost,gamma=tune_out$best.parameters$gamma) > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.8251748 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.5849057 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 29 18 TRUE 4 2 > > > #https://www.r-bloggers.com/understanding-naive-bayes-classifier-using-r/ > #Naive Bayes > set.seed(600) > nb_model <- naiveBayes(success ~ ., data =trainset) > summary(nb_model) Length Class Mode apriori 2 table numeric tables 70 -none- list levels 2 -none- character call 4 -none- call > pred_train <-predict(nb_model,trainset) > mean(pred_train==trainset$success) [1] 0.4055944 > pred_test <-predict(nb_model,testset) > mean(pred_test==testset$success) [1] 0.3962264 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 1 0 TRUE 32 20 zyldurch first 5: > set.seed(600) > zyldurchFrame<-data.frame(gooddata[,1:70],gooddata[,83]) > colnames(zyldurchFrame)[71]<-"success" > zyldurchFrame$success<-as.factor(as.logical(zyldurchFrame$success)) > > set.seed(600) > zyldurchFrame[,"train"] <- ifelse(runif(nrow(zyldurchFrame))<0.75,1,0) > trainset <- zyldurchFrame[zyldurchFrame$train==1,] > testset <- zyldurchFrame[zyldurchFrame$train==0,] > trainColNum <- grep("train",names(trainset)) > trainset <- trainset[,-trainColNum] > testset <- testset[,-trainColNum] > typeColNum <- grep("success",names(zyldurchFrame)) > > #SVM > #https://eight2late.wordpress.com/2017/02/07/a-gentle-introduction-to-support-vector-machines-using-r/ > #Linear > set.seed(600) > svm_model <- svm(success~., data=trainset, method="C-classification", kernel="linear") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "linear") Parameters: SVM-Type: C-classification SVM-Kernel: linear cost: 1 gamma: 0.01428571 Number of Support Vectors: 70 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.965035 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.6792453 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 6 10 TRUE 7 30 > > #Radial > set.seed(600) > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="radial") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "radial") Parameters: SVM-Type: C-classification SVM-Kernel: radial cost: 1 gamma: 0.01428571 Number of Support Vectors: 118 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.8041958 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.754717 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 0 0 TRUE 13 40 > > #Sigmoid > set.seed(600) > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="sigmoid") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "sigmoid") Parameters: SVM-Type: C-classification SVM-Kernel: sigmoid cost: 1 gamma: 0.01428571 coef.0: 0 Number of Support Vectors: 71 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.7762238 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.754717 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 0 0 TRUE 13 40 > > #Polynomial > set.seed(600) > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="polynomial") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "polynomial") Parameters: SVM-Type: C-classification SVM-Kernel: polynomial cost: 1 degree: 3 gamma: 0.01428571 coef.0: 0 Number of Support Vectors: 134 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.8111888 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.754717 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 0 0 TRUE 13 40 > > #Tuning for radial > set.seed(600) > tune_out <- tune.svm(x=trainset[,-typeColNum],y=trainset[,typeColNum],gamma=10^(-3:3),cost=c(0.01,0.1,1,10,100,1000),kernel="radial") > tune_out$best.parameters$cost [1] 0.01 > tune_out$best.parameters$gamma [1] 0.001 > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="radial",cost=tune_out$best.parameters$cost,gamma=tune_out$best.parameters$gamma) > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.7832168 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.754717 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 0 0 TRUE 13 40 > > #https://www.r-bloggers.com/understanding-naive-bayes-classifier-using-r/ > #Naive Bayes > set.seed(600) > nb_model <- naiveBayes(success ~ ., data =trainset) > summary(nb_model) Length Class Mode apriori 2 table numeric tables 70 -none- list levels 2 -none- character call 4 -none- call > pred_train <-predict(nb_model,trainset) > mean(pred_train==trainset$success) [1] 0.5174825 > pred_test <-predict(nb_model,testset) > mean(pred_test==testset$success) [1] 0.490566 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 11 25 TRUE 2 15 kreis2konz first 5 with feature selection: > set.seed(600) > kr2konzFrame<-data.frame(gooddata[,1:70],gooddata[,82]) > colnames(kr2konzFrame)[71]<-"success" > kr2konzFrame$success<-as.factor(as.logical(kr2konzFrame$success)) > > #https://machinelearningmastery.com/feature-selection-with-the-caret-r-package/ > #feature selection(recursive feature elimination) > control <- rfeControl(functions=rfFuncs, method="cv", number=5) > results <- rfe(kr2konzFrame[,1:70], kr2konzFrame[,71], sizes=c(1:70), rfeControl=control) > print(results) Recursive feature selection Outer resampling method: Cross-Validated (5 fold) Resampling performance over subset size: Variables Accuracy Kappa AccuracySD KappaSD Selected 1 0.6178 0.144911 0.08704 0.18024 2 0.5814 0.058553 0.03107 0.05183 3 0.6322 0.198469 0.11220 0.24771 4 0.6217 0.169128 0.09549 0.20060 5 0.6069 0.142621 0.04759 0.09745 6 0.6125 0.151800 0.08055 0.16994 7 0.5771 0.061781 0.06827 0.13767 8 0.6026 0.109489 0.04612 0.08958 9 0.5720 0.040683 0.05234 0.07722 10 0.5873 0.068367 0.06475 0.12345 11 0.5925 0.090122 0.08299 0.16154 12 0.6330 0.170201 0.06264 0.13263 * 13 0.6065 0.114480 0.07006 0.14639 14 0.6127 0.108859 0.05277 0.09469 15 0.6072 0.098785 0.07341 0.14428 16 0.6071 0.103419 0.04935 0.09138 17 0.6029 0.081999 0.08389 0.15749 18 0.5873 0.039596 0.06967 0.14111 19 0.6026 0.073475 0.04977 0.09186 20 0.5768 0.016008 0.05989 0.11586 21 0.5921 0.053496 0.05603 0.10286 22 0.5720 -0.004524 0.05461 0.09602 23 0.5971 0.047868 0.06087 0.15491 24 0.5716 -0.004501 0.06081 0.16414 25 0.5821 0.016942 0.09356 0.20994 26 0.5921 0.032677 0.06162 0.14406 27 0.6021 0.069249 0.05385 0.11294 28 0.6021 0.063564 0.07579 0.18132 29 0.6075 0.076964 0.08013 0.19190 30 0.5970 0.034508 0.05647 0.14608 31 0.6023 0.063193 0.07915 0.18785 32 0.5923 0.035122 0.07383 0.17317 33 0.5972 0.037266 0.05974 0.15294 34 0.5717 0.007598 0.07413 0.18323 35 0.5768 0.010207 0.06804 0.14280 36 0.5717 -0.017236 0.05960 0.15949 37 0.5925 0.048441 0.05951 0.13423 38 0.5872 0.050712 0.04281 0.08985 39 0.5664 -0.024739 0.04829 0.12470 40 0.5922 0.034795 0.04229 0.09658 41 0.5464 -0.057138 0.07178 0.16204 42 0.5671 -0.013115 0.08397 0.18277 43 0.5973 0.039397 0.05046 0.12734 44 0.5667 -0.008717 0.06046 0.13167 45 0.5821 0.030147 0.09313 0.23207 46 0.5616 -0.029096 0.05086 0.10129 47 0.5616 -0.045476 0.07979 0.20020 48 0.5664 -0.027357 0.03289 0.06675 49 0.5822 0.013793 0.06300 0.14218 50 0.5972 0.052083 0.04534 0.12702 51 0.5770 -0.001785 0.05880 0.11818 52 0.5717 -0.017743 0.05133 0.10642 53 0.5669 -0.016792 0.09497 0.19554 54 0.6021 0.051495 0.01999 0.06237 55 0.5920 0.041713 0.03299 0.05847 56 0.5820 0.023597 0.05800 0.12223 57 0.5922 0.051110 0.06087 0.13779 58 0.5922 0.043630 0.06066 0.10882 59 0.5717 0.013332 0.05678 0.11378 60 0.5666 -0.020565 0.05589 0.10679 61 0.5770 -0.003902 0.04716 0.10438 62 0.5718 0.002587 0.06197 0.11297 63 0.5767 0.007880 0.03491 0.08410 64 0.5616 -0.040783 0.08303 0.17573 65 0.5513 -0.065384 0.06478 0.13000 66 0.5873 0.031705 0.06478 0.11312 67 0.5563 -0.065080 0.02357 0.04884 68 0.5822 0.015843 0.06300 0.10923 69 0.6025 0.046159 0.05690 0.10527 70 0.5921 0.023564 0.07102 0.15448 The top 5 variables (out of 12): ns.2.s..Channel.MachineAxis.aaTorque.u1.1.5, ns.2.s..Channel.MachineAxis.aaLoad.u1.2.3, ns.2.s..Channel.MachineAxis.aaTorque.u1.3.5, ns.2.s..Channel.MachineAxis.aaLoad.u1.1.2, ns.2.s..Channel.MachineAxis.aaTorque.u1.2.1 > predictors(results) [1] "ns.2.s..Channel.MachineAxis.aaTorque.u1.1.5" "ns.2.s..Channel.MachineAxis.aaLoad.u1.2.3" "ns.2.s..Channel.MachineAxis.aaTorque.u1.3.5" "ns.2.s..Channel.MachineAxis.aaLoad.u1.1.2" [5] "ns.2.s..Channel.MachineAxis.aaTorque.u1.2.1" "ns.2.s..Channel.MachineAxis.aaTorque.u1.1.4" "ns.2.s..Channel.MachineAxis.aaLeadP.u1.1.4" "ns.2.s..Channel.MachineAxis.aaLoad.u1.1.3" [9] "ns.2.s..Channel.MachineAxis.aaLoad.u1.2.5" "ns.2.s..Channel.MachineAxis.aaTorque.u1.1.3" "ns.2.s..Channel.MachineAxis.aaVactB.u1.3.5" "ns.2.s..Channel.MachineAxis.aaTorque.u1.2.5" > plot(results, type=c("g", "o")) > reduceddata <- data.frame(kr2konzFrame$ns.2.s..Channel.MachineAxis.aaTorque.u1.1.5, kr2konzFrame$ns.2.s..Channel.MachineAxis.aaLoad.u1.2.3, kr2konzFrame$ns.2.s..Channel.MachineAxis.aaTorque.u1.3.5, kr2konzFrame$ns.2.s..Channel.MachineAxis.aaLoad.u1.1.2, kr2konzFrame$ns.2.s..Channel.MachineAxis.aaTorque.u1.2.1, kr2konzFrame$ns.2.s..Channel.MachineAxis.aaTorque.u1.1.4, kr2konzFrame$ns.2.s..Channel.MachineAxis.aaLeadP.u1.1.4, kr2konzFrame$ns.2.s..Channel.MachineAxis.aaLoad.u1.1.3, kr2konzFrame$ns.2.s..Channel.MachineAxis.aaLoad.u1.2.5, kr2konzFrame$ns.2.s..Channel.MachineAxis.aaTorque.u1.1.3, kr2konzFrame$ns.2.s..Channel.MachineAxis.aaVactB.u1.3.5, kr2konzFrame$ns.2.s..Channel.MachineAxis.aaTorque.u1.2.5, kr2konzFrame$success) > #Splitting data into test and training data 75/25 > set.seed(600) > reduceddata[,"train"] <- ifelse(runif(nrow(reduceddata))<0.75,1,0) > trainset <- reduceddata[reduceddata$train==1,] > testset <- reduceddata[reduceddata$train==0,] > trainColNum <- grep("train",names(trainset)) > trainset <- trainset[,-trainColNum] > testset <- testset[,-trainColNum] > typeColNum <- grep("success",names(reduceddata)) > #SVM > #https://eight2late.wordpress.com/2017/02/07/a-gentle-introduction-to-support-vector-machines-using-r/ > #Linear > set.seed(600) > svm_model <- svm(kr2konzFrame.success~., data=trainset, method="C-classification", kernel="linear") > svm_model Call: svm(formula = kr2konzFrame.success ~ ., data = trainset, method = "C-classification", kernel = "linear") Parameters: SVM-Type: C-classification SVM-Kernel: linear cost: 1 gamma: 0.08333333 Number of Support Vectors: 103 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$kr2konzFrame.success) [1] 0.6923077 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$kr2konzFrame.success) [1] 0.6226415 > confusion(pred_test,testset$kr2konzFrame.success) true predicted FALSE TRUE FALSE 27 14 TRUE 6 6 > > #Radial > set.seed(600) > svm_model <- svm(kr2konzFrame.success~ ., data=trainset, method="C-classification", kernel="radial") > svm_model Call: svm(formula = kr2konzFrame.success ~ ., data = trainset, method = "C-classification", kernel = "radial") Parameters: SVM-Type: C-classification SVM-Kernel: radial cost: 1 gamma: 0.08333333 Number of Support Vectors: 125 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$kr2konzFrame.success) [1] 0.7692308 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$kr2konzFrame.success) [1] 0.5660377 > confusion(pred_test,testset$kr2konzFrame.success) true predicted FALSE TRUE FALSE 29 19 TRUE 4 1 > > #Sigmoid > set.seed(600) > svm_model <- svm(kr2konzFrame.success~ ., data=trainset, method="C-classification", kernel="sigmoid") > svm_model Call: svm(formula = kr2konzFrame.success ~ ., data = trainset, method = "C-classification", kernel = "sigmoid") Parameters: SVM-Type: C-classification SVM-Kernel: sigmoid cost: 1 gamma: 0.08333333 coef.0: 0 Number of Support Vectors: 110 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$kr2konzFrame.success) [1] 0.5874126 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$kr2konzFrame.success) [1] 0.6226415 > confusion(pred_test,testset$kr2konzFrame.success) true predicted FALSE TRUE FALSE 30 17 TRUE 3 3 > > #Polynomial > set.seed(600) > svm_model <- svm(kr2konzFrame.success~ ., data=trainset, method="C-classification", kernel="polynomial") > svm_model Call: svm(formula = kr2konzFrame.success ~ ., data = trainset, method = "C-classification", kernel = "polynomial") Parameters: SVM-Type: C-classification SVM-Kernel: polynomial cost: 1 degree: 3 gamma: 0.08333333 coef.0: 0 Number of Support Vectors: 113 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$kr2konzFrame.success) [1] 0.7342657 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$kr2konzFrame.success) [1] 0.6037736 > confusion(pred_test,testset$kr2konzFrame.success) true predicted FALSE TRUE FALSE 32 20 TRUE 1 0 > > #Tuning for radial > set.seed(600) > tune_out <- tune.svm(x=trainset[,-typeColNum],y=trainset[,typeColNum],gamma=10^(-3:3),cost=c(0.01,0.1,1,10,100,1000),kernel="radial") > tune_out$best.parameters$cost [1] 1 > tune_out$best.parameters$gamma [1] 0.01 > svm_model <- svm(kr2konzFrame.success~ ., data=trainset, method="C-classification", kernel="radial",cost=tune_out$best.parameters$cost,gamma=tune_out$best.parameters$gamma) > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$kr2konzFrame.success) [1] 0.6433566 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$kr2konzFrame.success) [1] 0.6226415 > confusion(pred_test,testset$kr2konzFrame.success) true predicted FALSE TRUE FALSE 33 20 TRUE 0 0 > > > #https://www.r-bloggers.com/understanding-naive-bayes-classifier-using-r/ > #Naive Bayes > set.seed(600) > nb_model <- naiveBayes(kr2konzFrame.success ~ ., data =trainset) > summary(nb_model) Length Class Mode apriori 2 table numeric tables 12 -none- list levels 2 -none- character call 4 -none- call > pred_train <-predict(nb_model,trainset) > mean(pred_train==trainset$kr2konzFrame.success) [1] 0.6713287 > pred_test <-predict(nb_model,testset) > mean(pred_test==testset$kr2konzFrame.success) [1] 0.6792453 > confusion(pred_test,testset$kr2konzFrame.success) true predicted FALSE TRUE FALSE 28 12 TRUE 5 8 kreis1konz middle 5: > set.seed(600) > kr1konzFrame<-data.frame(gooddata[,1:70],gooddata[,79]) > colnames(kr1konzFrame)[71]<-"success" > kr1konzFrame$success<-as.factor(as.logical(kr1konzFrame$success)) > > set.seed(600) > kr1konzFrame[,"train"] <- ifelse(runif(nrow(kr1konzFrame))<0.75,1,0) > trainset <- kr1konzFrame[kr1konzFrame$train==1,] > testset <- kr1konzFrame[kr1konzFrame$train==0,] > trainColNum <- grep("train",names(trainset)) > trainset <- trainset[,-trainColNum] > testset <- testset[,-trainColNum] > typeColNum <- grep("success",names(kr1konzFrame)) > > #SVM > #https://eight2late.wordpress.com/2017/02/07/a-gentle-introduction-to-support-vector-machines-using-r/ > #Linear > set.seed(600) > svm_model <- svm(success~., data=trainset, method="C-classification", kernel="linear") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "linear") Parameters: SVM-Type: C-classification SVM-Kernel: linear cost: 1 gamma: 0.01428571 Number of Support Vectors: 92 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.8811189 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.490566 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 19 12 TRUE 15 7 > > #Radial > set.seed(600) > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="radial") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "radial") Parameters: SVM-Type: C-classification SVM-Kernel: radial cost: 1 gamma: 0.01428571 Number of Support Vectors: 135 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.7692308 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.6603774 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 34 18 TRUE 0 1 > > #Sigmoid > set.seed(600) > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="sigmoid") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "sigmoid") Parameters: SVM-Type: C-classification SVM-Kernel: sigmoid cost: 1 gamma: 0.01428571 coef.0: 0 Number of Support Vectors: 118 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.6013986 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.6415094 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 32 17 TRUE 2 2 > > #Polynomial > set.seed(600) > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="polynomial") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "polynomial") Parameters: SVM-Type: C-classification SVM-Kernel: polynomial cost: 1 degree: 3 gamma: 0.01428571 coef.0: 0 Number of Support Vectors: 136 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.7272727 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.5849057 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 31 19 TRUE 3 0 > > #Tuning for radial > set.seed(600) > tune_out <- tune.svm(x=trainset[,-typeColNum],y=trainset[,typeColNum],gamma=10^(-3:3),cost=c(0.01,0.1,1,10,100,1000),kernel="radial") > tune_out$best.parameters$cost [1] 1 > tune_out$best.parameters$gamma [1] 0.01 > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="radial",cost=tune_out$best.parameters$cost,gamma=tune_out$best.parameters$gamma) > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.7132867 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.6415094 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 34 19 TRUE 0 0 > > #https://www.r-bloggers.com/understanding-naive-bayes-classifier-using-r/ > #Naive Bayes > set.seed(600) > nb_model <- naiveBayes(success ~ ., data =trainset) > summary(nb_model) Length Class Mode apriori 2 table numeric tables 70 -none- list levels 2 -none- character call 4 -none- call > pred_train <-predict(nb_model,trainset) > mean(pred_train==trainset$success) [1] 0.6363636 > pred_test <-predict(nb_model,testset) > mean(pred_test==testset$success) [1] 0.5283019 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 19 10 TRUE 15 9 gesamt last 5: > set.seed(600) > acceptFrame[,"train"] <- ifelse(runif(nrow(acceptFrame))<0.75,1,0) > trainset <- acceptFrame[acceptFrame$train==1,] > testset <- acceptFrame[acceptFrame$train==0,] > trainColNum <- grep("train",names(trainset)) > trainset <- trainset[,-trainColNum] > testset <- testset[,-trainColNum] > typeColNum <- grep("success",names(acceptFrame)) > > #SVM > #https://eight2late.wordpress.com/2017/02/07/a-gentle-introduction-to-support-vector-machines-using-r/ > #Linear > set.seed(600) > svm_model <- svm(success~., data=trainset, method="C-classification", kernel="linear") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "linear") Parameters: SVM-Type: C-classification SVM-Kernel: linear cost: 1 gamma: 0.01428571 Number of Support Vectors: 89 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.8601399 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.6415094 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 32 13 TRUE 6 2 > > #Radial > set.seed(600) > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="radial") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "radial") Parameters: SVM-Type: C-classification SVM-Kernel: radial cost: 1 gamma: 0.01428571 Number of Support Vectors: 125 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.7762238 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.7169811 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 38 15 TRUE 0 0 > > #Sigmoid > set.seed(600) > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="sigmoid") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "sigmoid") Parameters: SVM-Type: C-classification SVM-Kernel: sigmoid cost: 1 gamma: 0.01428571 coef.0: 0 Number of Support Vectors: 91 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.7062937 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.6981132 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 37 15 TRUE 1 0 > > #Polynomial > set.seed(600) > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="polynomial") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "polynomial") Parameters: SVM-Type: C-classification SVM-Kernel: polynomial cost: 1 degree: 3 gamma: 0.01428571 coef.0: 0 Number of Support Vectors: 121 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.8181818 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.6792453 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 36 15 TRUE 2 0 > > #Tuning for radial > set.seed(600) > tune_out <- tune.svm(x=trainset[,-typeColNum],y=trainset[,typeColNum],gamma=10^(-3:3),cost=c(0.01,0.1,1,10,100,1000),kernel="radial") > tune_out$best.parameters$cost [1] 0.01 > tune_out$best.parameters$gamma [1] 0.001 > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="radial",cost=tune_out$best.parameters$cost,gamma=tune_out$best.parameters$gamma) > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.7202797 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.7169811 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 38 15 TRUE 0 0 > > > #https://www.r-bloggers.com/understanding-naive-bayes-classifier-using-r/ > #Naive Bayes > set.seed(600) > nb_model <- naiveBayes(success ~ ., data =trainset) > summary(nb_model) Length Class Mode apriori 2 table numeric tables 70 -none- list levels 2 -none- character call 4 -none- call > pred_train <-predict(nb_model,trainset) > mean(pred_train==trainset$success) [1] 0.7062937 > pred_test <-predict(nb_model,testset) > mean(pred_test==testset$success) [1] 0.6603774 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 32 12 TRUE 6 3 gesamt middle 5: > set.seed(600) > acceptFrame<-data.frame(gooddata[,1:70],gooddata[,86]) > colnames(acceptFrame)[71]<-"success" > acceptFrame$success<-as.factor(as.logical(acceptFrame$success)) > > set.seed(600) > acceptFrame[,"train"] <- ifelse(runif(nrow(acceptFrame))<0.75,1,0) > trainset <- acceptFrame[acceptFrame$train==1,] > testset <- acceptFrame[acceptFrame$train==0,] > trainColNum <- grep("train",names(trainset)) > trainset <- trainset[,-trainColNum] > testset <- testset[,-trainColNum] > typeColNum <- grep("success",names(acceptFrame)) > > #SVM > #https://eight2late.wordpress.com/2017/02/07/a-gentle-introduction-to-support-vector-machines-using-r/ > #Linear > set.seed(600) > svm_model <- svm(success~., data=trainset, method="C-classification", kernel="linear") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "linear") Parameters: SVM-Type: C-classification SVM-Kernel: linear cost: 1 gamma: 0.01428571 Number of Support Vectors: 83 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.8881119 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.6037736 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 29 12 TRUE 9 3 > > #Radial > set.seed(600) > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="radial") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "radial") Parameters: SVM-Type: C-classification SVM-Kernel: radial cost: 1 gamma: 0.01428571 Number of Support Vectors: 131 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.7762238 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.7169811 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 38 15 TRUE 0 0 > > #Sigmoid > set.seed(600) > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="sigmoid") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "sigmoid") Parameters: SVM-Type: C-classification SVM-Kernel: sigmoid cost: 1 gamma: 0.01428571 coef.0: 0 Number of Support Vectors: 91 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.7202797 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.754717 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 38 13 TRUE 0 2 > > #Polynomial > set.seed(600) > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="polynomial") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "polynomial") Parameters: SVM-Type: C-classification SVM-Kernel: polynomial cost: 1 degree: 3 gamma: 0.01428571 coef.0: 0 Number of Support Vectors: 121 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.8041958 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.6792453 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 36 15 TRUE 2 0 > > #Tuning for radial > set.seed(600) > tune_out <- tune.svm(x=trainset[,-typeColNum],y=trainset[,typeColNum],gamma=10^(-3:3),cost=c(0.01,0.1,1,10,100,1000),kernel="radial") > tune_out$best.parameters$cost [1] 0.01 > tune_out$best.parameters$gamma [1] 0.001 > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="radial",cost=tune_out$best.parameters$cost,gamma=tune_out$best.parameters$gamma) > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.7202797 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.7169811 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 38 15 TRUE 0 0 > > > #https://www.r-bloggers.com/understanding-naive-bayes-classifier-using-r/ > #Naive Bayes > set.seed(600) > nb_model <- naiveBayes(success ~ ., data =trainset) > summary(nb_model) Length Class Mode apriori 2 table numeric tables 70 -none- list levels 2 -none- character call 4 -none- call > pred_train <-predict(nb_model,trainset) > mean(pred_train==trainset$success) [1] 0.6433566 > pred_test <-predict(nb_model,testset) > mean(pred_test==testset$success) [1] 0.509434 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 18 6 TRUE 20 9 gesamt first 5: > set.seed(600) > acceptFrame<-data.frame(gooddata[,1:70],gooddata[,86]) > colnames(acceptFrame)[71]<-"success" > acceptFrame$success<-as.factor(as.logical(acceptFrame$success)) > > set.seed(600) > acceptFrame[,"train"] <- ifelse(runif(nrow(acceptFrame))<0.75,1,0) > trainset <- acceptFrame[acceptFrame$train==1,] > testset <- acceptFrame[acceptFrame$train==0,] > trainColNum <- grep("train",names(trainset)) > trainset <- trainset[,-trainColNum] > testset <- testset[,-trainColNum] > typeColNum <- grep("success",names(acceptFrame)) > > #SVM > #https://eight2late.wordpress.com/2017/02/07/a-gentle-introduction-to-support-vector-machines-using-r/ > #Linear > set.seed(600) > svm_model <- svm(success~., data=trainset, method="C-classification", kernel="linear") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "linear") Parameters: SVM-Type: C-classification SVM-Kernel: linear cost: 1 gamma: 0.01428571 Number of Support Vectors: 78 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.9090909 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.6792453 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 32 11 TRUE 6 4 > > #Radial > set.seed(600) > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="radial") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "radial") Parameters: SVM-Type: C-classification SVM-Kernel: radial cost: 1 gamma: 0.01428571 Number of Support Vectors: 121 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.8111888 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.7169811 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 38 15 TRUE 0 0 > > #Sigmoid > set.seed(600) > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="sigmoid") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "sigmoid") Parameters: SVM-Type: C-classification SVM-Kernel: sigmoid cost: 1 gamma: 0.01428571 coef.0: 0 Number of Support Vectors: 86 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.7202797 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.6981132 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 37 15 TRUE 1 0 > > #Polynomial > set.seed(600) > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="polynomial") > svm_model Call: svm(formula = success ~ ., data = trainset, method = "C-classification", kernel = "polynomial") Parameters: SVM-Type: C-classification SVM-Kernel: polynomial cost: 1 degree: 3 gamma: 0.01428571 coef.0: 0 Number of Support Vectors: 133 > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.7832168 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.7169811 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 38 15 TRUE 0 0 > > #Tuning for radial > set.seed(600) > tune_out <- tune.svm(x=trainset[,-typeColNum],y=trainset[,typeColNum],gamma=10^(-3:3),cost=c(0.01,0.1,1,10,100,1000),kernel="radial") > tune_out$best.parameters$cost [1] 0.01 > tune_out$best.parameters$gamma [1] 0.001 > svm_model <- svm(success~ ., data=trainset, method="C-classification", kernel="radial",cost=tune_out$best.parameters$cost,gamma=tune_out$best.parameters$gamma) > pred_train <-predict(svm_model,trainset) > mean(pred_train==trainset$success) [1] 0.7202797 > pred_test <-predict(svm_model,testset) > mean(pred_test==testset$success) [1] 0.7169811 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 38 15 TRUE 0 0 > > > #https://www.r-bloggers.com/understanding-naive-bayes-classifier-using-r/ > #Naive Bayes > set.seed(600) > nb_model <- naiveBayes(success ~ ., data =trainset) > summary(nb_model) Length Class Mode apriori 2 table numeric tables 70 -none- list levels 2 -none- character call 4 -none- call > pred_train <-predict(nb_model,trainset) > mean(pred_train==trainset$success) [1] 0.3636364 > pred_test <-predict(nb_model,testset) > mean(pred_test==testset$success) [1] 0.3207547 > confusion(pred_test,testset$success) true predicted FALSE TRUE FALSE 3 1 TRUE 35 14