The attached data has records of 444 employees in a firm. The variables are described below: -Build a model that best explains the employee???s decision to use cars as the main means of transport? What would your predictions regarding their choice of transport be for the following two employees?
library('ggplot2') # visualization
## Warning: package 'ggplot2' was built under R version 3.4.4
library('car') # visualization
## Warning: package 'car' was built under R version 3.4.4
## Loading required package: carData
## Warning: package 'carData' was built under R version 3.4.4
library('scales') # visualization
## Warning: package 'scales' was built under R version 3.4.4
library('AER') #Coefficients
## Loading required package: lmtest
## Warning: package 'lmtest' was built under R version 3.4.4
## Loading required package: zoo
## Warning: package 'zoo' was built under R version 3.4.4
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
## Loading required package: sandwich
## Warning: package 'sandwich' was built under R version 3.4.4
## Loading required package: survival
## Warning: package 'survival' was built under R version 3.4.4
require("tidyr")
## Loading required package: tidyr
## Warning: package 'tidyr' was built under R version 3.4.4
library('corrplot')
## Warning: package 'corrplot' was built under R version 3.4.2
## corrplot 0.84 loaded
#source("distance.R")
library('car')
library('caret')
## Warning: package 'caret' was built under R version 3.4.4
## Loading required package: lattice
## Warning in as.POSIXlt.POSIXct(Sys.time()): unknown timezone 'zone/tz/2018g.
## 1.0/zoneinfo/Asia/Kolkata'
##
## Attaching package: 'caret'
## The following object is masked from 'package:survival':
##
## cluster
library('purrr')
## Warning: package 'purrr' was built under R version 3.4.4
##
## Attaching package: 'purrr'
## The following object is masked from 'package:caret':
##
## lift
## The following object is masked from 'package:scales':
##
## discard
## The following object is masked from 'package:car':
##
## some
library('coefplot')
## Warning: package 'coefplot' was built under R version 3.4.3
library('psych')
## Warning: package 'psych' was built under R version 3.4.4
##
## Attaching package: 'psych'
## The following objects are masked from 'package:scales':
##
## alpha, rescale
## The following object is masked from 'package:car':
##
## logit
## The following objects are masked from 'package:ggplot2':
##
## %+%, alpha
library('MASS')
## Warning: package 'MASS' was built under R version 3.4.4
library('leaflet.extras')
## Warning: package 'leaflet.extras' was built under R version 3.4.4
## Loading required package: leaflet
## Warning: package 'leaflet' was built under R version 3.4.4
library("PerformanceAnalytics")
## Warning: package 'PerformanceAnalytics' was built under R version 3.4.3
## Loading required package: xts
## Warning: package 'xts' was built under R version 3.4.4
##
## Attaching package: 'xts'
## The following object is masked from 'package:leaflet':
##
## addLegend
##
## Attaching package: 'PerformanceAnalytics'
## The following object is masked from 'package:graphics':
##
## legend
library('GPArotation')
library('MVN')
## Warning: package 'MVN' was built under R version 3.4.4
## sROC 0.1-2 loaded
library('psych')
library('MASS')
library('psy')
##
## Attaching package: 'psy'
## The following object is masked from 'package:psych':
##
## wkappa
library('corpcor')
library('nnet')
library('plyr')
##
## Attaching package: 'plyr'
## The following object is masked from 'package:purrr':
##
## compact
library('car')
library("e1071")
## Warning: package 'e1071' was built under R version 3.4.4
##
## Attaching package: 'e1071'
## The following objects are masked from 'package:PerformanceAnalytics':
##
## kurtosis, skewness
## The following object is masked from 'package:coefplot':
##
## extractPath
library('ggcorrplot')
## Warning: package 'ggcorrplot' was built under R version 3.4.4
library('mlogit') # for multiple class logistic regression
## Warning: package 'mlogit' was built under R version 3.4.4
## Loading required package: Formula
## Warning: package 'Formula' was built under R version 3.4.4
## Loading required package: maxLik
## Loading required package: miscTools
##
## Please cite the 'maxLik' package as:
## Henningsen, Arne and Toomet, Ott (2011). maxLik: A package for maximum likelihood estimation in R. Computational Statistics 26(3), 443-458. DOI 10.1007/s00180-010-0217-1.
##
## If you have questions, suggestions, or comments regarding the 'maxLik' package, please use a forum or 'tracker' at maxLik's R-Forge site:
## https://r-forge.r-project.org/projects/maxlik/
# library('InformationValue')
library('rpart.plot')
## Warning: package 'rpart.plot' was built under R version 3.4.4
## Loading required package: rpart
## Warning: package 'rpart' was built under R version 3.4.3
##
## Attaching package: 'rpart'
## The following object is masked from 'package:survival':
##
## solder
library('caTools')
## Warning: package 'caTools' was built under R version 3.4.4
library('ggplot2')
library('RColorBrewer')
# library('data.table')
# library('ROCR')
# library('maptree')
# library('tree')
library('dummies') # for converting categorical into dummy one
## dummies-1.5.6 provided by Decision Patterns
library('caret')
library('pscl') ## for McFadden R2
## Warning: package 'pscl' was built under R version 3.4.2
## Classes and Methods for R developed in the
## Political Science Computational Laboratory
## Department of Political Science
## Stanford University
## Simon Jackman
## hurdle and zeroinfl functions by Achim Zeileis
# library('randomForest')
library('StatMeasures')
library('sqldf')
## Warning: package 'sqldf' was built under R version 3.4.1
## Loading required package: gsubfn
## Warning: package 'gsubfn' was built under R version 3.4.4
## Loading required package: proto
## Loading required package: RSQLite
## Warning: package 'RSQLite' was built under R version 3.4.4
library('purrr')
library('tidyr')
library('caret')
library('ggplot2')
library('gains')
## Warning: package 'gains' was built under R version 3.4.1
library('lubridate')
## Warning: package 'lubridate' was built under R version 3.4.4
##
## Attaching package: 'lubridate'
## The following object is masked from 'package:plyr':
##
## here
## The following object is masked from 'package:base':
##
## date
library('dummies')
library('glmnet')
## Warning: package 'glmnet' was built under R version 3.4.4
## Loading required package: Matrix
## Warning: package 'Matrix' was built under R version 3.4.4
##
## Attaching package: 'Matrix'
## The following object is masked from 'package:tidyr':
##
## expand
## Loading required package: foreach
## Warning: package 'foreach' was built under R version 3.4.3
##
## Attaching package: 'foreach'
## The following objects are masked from 'package:purrr':
##
## accumulate, when
## Loaded glmnet 2.0-16
##
## Attaching package: 'glmnet'
## The following object is masked from 'package:StatMeasures':
##
## auc
library('gbm')
## Warning: package 'gbm' was built under R version 3.4.4
## Loaded gbm 2.1.4
library('VIM') ### This is for knn
## Loading required package: colorspace
## Loading required package: grid
## Loading required package: data.table
## Warning: package 'data.table' was built under R version 3.4.4
##
## Attaching package: 'data.table'
## The following objects are masked from 'package:lubridate':
##
## hour, isoweek, mday, minute, month, quarter, second, wday,
## week, yday, year
## The following objects are masked from 'package:xts':
##
## first, last
## The following object is masked from 'package:purrr':
##
## transpose
## VIM is ready to use.
## Since version 4.0.0 the GUI is in its own package VIMGUI.
##
## Please use the package to use the new (and old) GUI.
## Suggestions and bug-reports can be submitted at: https://github.com/alexkowa/VIM/issues
##
## Attaching package: 'VIM'
## The following object is masked from 'package:datasets':
##
## sleep
library('DMwR') ## package for SMOTE
##
## Attaching package: 'DMwR'
## The following object is masked from 'package:VIM':
##
## kNN
## The following object is masked from 'package:plyr':
##
## join
Data is already in csv file format and loaded into dataframe. summary of data analysis shows that MBA feature has one null values
transport_employee_aval <- read.csv('Cars.csv')
summary(transport_employee_aval)
## Age Gender Engineer MBA
## Min. :18.00 Female:128 Min. :0.0000 Min. :0.0000
## 1st Qu.:25.00 Male :316 1st Qu.:1.0000 1st Qu.:0.0000
## Median :27.00 Median :1.0000 Median :0.0000
## Mean :27.75 Mean :0.7545 Mean :0.2528
## 3rd Qu.:30.00 3rd Qu.:1.0000 3rd Qu.:1.0000
## Max. :43.00 Max. :1.0000 Max. :1.0000
## NA's :1
## Work.Exp Salary Distance license
## Min. : 0.0 Min. : 6.50 Min. : 3.20 Min. :0.0000
## 1st Qu.: 3.0 1st Qu.: 9.80 1st Qu.: 8.80 1st Qu.:0.0000
## Median : 5.0 Median :13.60 Median :11.00 Median :0.0000
## Mean : 6.3 Mean :16.24 Mean :11.32 Mean :0.2342
## 3rd Qu.: 8.0 3rd Qu.:15.72 3rd Qu.:13.43 3rd Qu.:0.0000
## Max. :24.0 Max. :57.00 Max. :23.40 Max. :1.0000
##
## Transport
## 2Wheeler : 83
## Car : 61
## Public Transport:300
##
##
##
##
nrow(transport_employee_aval)
## [1] 444
str(transport_employee_aval)
## 'data.frame': 444 obs. of 9 variables:
## $ Age : int 28 23 29 28 27 26 28 26 22 27 ...
## $ Gender : Factor w/ 2 levels "Female","Male": 2 1 2 1 2 2 2 1 2 2 ...
## $ Engineer : int 0 1 1 1 1 1 1 1 1 1 ...
## $ MBA : int 0 0 0 1 0 0 0 0 0 0 ...
## $ Work.Exp : int 4 4 7 5 4 4 5 3 1 4 ...
## $ Salary : num 14.3 8.3 13.4 13.4 13.4 12.3 14.4 10.5 7.5 13.5 ...
## $ Distance : num 3.2 3.3 4.1 4.5 4.6 4.8 5.1 5.1 5.1 5.2 ...
## $ license : int 0 0 0 0 0 1 0 0 0 0 ...
## $ Transport: Factor w/ 3 levels "2Wheeler","Car",..: 3 3 3 3 3 3 1 3 3 3 ...
hist(transport_employee_aval$Work.Exp, col = 'blue')
hist(transport_employee_aval$license, col = 'green')
vis_summary <- ggplot(transport_employee_aval, aes(x = transport_employee_aval$Salary, y = transport_employee_aval$Work.Exp)) +
facet_grid(~ transport_employee_aval$Gender + transport_employee_aval$Transport)+
geom_boxplot(na.rm = TRUE, colour = "#3366FF",outlier.colour = "red", outlier.shape = 1) +
labs(x = "Work Experience", y = "Salary") +
scale_x_continuous() +
scale_y_continuous() +
theme(legend.position="bottom", legend.direction="horizontal")
vis_summary
## Warning: Continuous x aesthetic -- did you forget aes(group=...)?
vis_summary$notchupper
## NULL
KNN is an algorithm that is useful for matching a point with its closest k neighbors in a multi-dimensional space. It can be used for data that are continuous, discrete, ordinal and categorical which makes it particularly useful for dealing with all kind of missing data. The assumption behind using KNN for missing values is that a point value can be approximated by the values of the points that are closest to it, based on other variables. It is seen here that MBA_imp new logical column has been created and it has one value set as TRUE. This means one null value has been imputed.
transport_employee_aval_imputed <- transport_employee_aval
summary(transport_employee_aval_imputed)
## Age Gender Engineer MBA
## Min. :18.00 Female:128 Min. :0.0000 Min. :0.0000
## 1st Qu.:25.00 Male :316 1st Qu.:1.0000 1st Qu.:0.0000
## Median :27.00 Median :1.0000 Median :0.0000
## Mean :27.75 Mean :0.7545 Mean :0.2528
## 3rd Qu.:30.00 3rd Qu.:1.0000 3rd Qu.:1.0000
## Max. :43.00 Max. :1.0000 Max. :1.0000
## NA's :1
## Work.Exp Salary Distance license
## Min. : 0.0 Min. : 6.50 Min. : 3.20 Min. :0.0000
## 1st Qu.: 3.0 1st Qu.: 9.80 1st Qu.: 8.80 1st Qu.:0.0000
## Median : 5.0 Median :13.60 Median :11.00 Median :0.0000
## Mean : 6.3 Mean :16.24 Mean :11.32 Mean :0.2342
## 3rd Qu.: 8.0 3rd Qu.:15.72 3rd Qu.:13.43 3rd Qu.:0.0000
## Max. :24.0 Max. :57.00 Max. :23.40 Max. :1.0000
##
## Transport
## 2Wheeler : 83
## Car : 61
## Public Transport:300
##
##
##
##
transport_employee_aval_imputed <- VIM::kNN(data=transport_employee_aval,variable =c("MBA"),k=7) ## here explictly package name has to be added bacauses the function name is conflicting with other package of SMOTE
summary(transport_employee_aval_imputed)
## Age Gender Engineer MBA
## Min. :18.00 Female:128 Min. :0.0000 Min. :0.0000
## 1st Qu.:25.00 Male :316 1st Qu.:1.0000 1st Qu.:0.0000
## Median :27.00 Median :1.0000 Median :0.0000
## Mean :27.75 Mean :0.7545 Mean :0.2523
## 3rd Qu.:30.00 3rd Qu.:1.0000 3rd Qu.:1.0000
## Max. :43.00 Max. :1.0000 Max. :1.0000
## Work.Exp Salary Distance license
## Min. : 0.0 Min. : 6.50 Min. : 3.20 Min. :0.0000
## 1st Qu.: 3.0 1st Qu.: 9.80 1st Qu.: 8.80 1st Qu.:0.0000
## Median : 5.0 Median :13.60 Median :11.00 Median :0.0000
## Mean : 6.3 Mean :16.24 Mean :11.32 Mean :0.2342
## 3rd Qu.: 8.0 3rd Qu.:15.72 3rd Qu.:13.43 3rd Qu.:0.0000
## Max. :24.0 Max. :57.00 Max. :23.40 Max. :1.0000
## Transport MBA_imp
## 2Wheeler : 83 Mode :logical
## Car : 61 FALSE:443
## Public Transport:300 TRUE :1
##
##
##
Null value is missing now. Original dataframe had 444 observations and new dataframe also has same number of record.
transport_employee_aval_final <- subset(transport_employee_aval_imputed, select = Age:Transport)
transport_employee_aval_final_boost <- subset(transport_employee_aval_imputed, select = Age:Transport)
transport_employee_aval_final_logit <- subset(transport_employee_aval_imputed, select = Age:Transport)
nrow(transport_employee_aval_final)
## [1] 444
It shows that data is biassed towards Public Transport
table(transport_employee_aval_final$Transport)
##
## 2Wheeler Car Public Transport
## 83 61 300
print(prop.table(table(transport_employee_aval_final$Transport)))
##
## 2Wheeler Car Public Transport
## 0.1869369 0.1373874 0.6756757
Here we have used the cost and epsillon value range to find out best model by using grid search which is being called by tune function
#transport_employee_aval_final$Age <- scale(transport_employee_aval_final$Age)
summary(transport_employee_aval_final)
## Age Gender Engineer MBA
## Min. :18.00 Female:128 Min. :0.0000 Min. :0.0000
## 1st Qu.:25.00 Male :316 1st Qu.:1.0000 1st Qu.:0.0000
## Median :27.00 Median :1.0000 Median :0.0000
## Mean :27.75 Mean :0.7545 Mean :0.2523
## 3rd Qu.:30.00 3rd Qu.:1.0000 3rd Qu.:1.0000
## Max. :43.00 Max. :1.0000 Max. :1.0000
## Work.Exp Salary Distance license
## Min. : 0.0 Min. : 6.50 Min. : 3.20 Min. :0.0000
## 1st Qu.: 3.0 1st Qu.: 9.80 1st Qu.: 8.80 1st Qu.:0.0000
## Median : 5.0 Median :13.60 Median :11.00 Median :0.0000
## Mean : 6.3 Mean :16.24 Mean :11.32 Mean :0.2342
## 3rd Qu.: 8.0 3rd Qu.:15.72 3rd Qu.:13.43 3rd Qu.:0.0000
## Max. :24.0 Max. :57.00 Max. :23.40 Max. :1.0000
## Transport
## 2Wheeler : 83
## Car : 61
## Public Transport:300
##
##
##
svm_tune <- tune(svm, Transport~., data = transport_employee_aval_final, ranges = list(cross = 7, epsilon = seq(0,1,0.01), cost = 2^(2:9)))
print(svm_tune)
##
## Parameter tuning of 'svm':
##
## - sampling method: 10-fold cross validation
##
## - best parameters:
## cross epsilon cost
## 7 0 4
##
## - best performance: 0.1981818
best_mod <- svm_tune$best.model
svm_tune$performances
## cross epsilon cost error dispersion
## 1 7 0.00 4 0.1981818 0.07217303
## 2 7 0.01 4 0.1981818 0.07217303
## 3 7 0.02 4 0.1981818 0.07217303
## 4 7 0.03 4 0.1981818 0.07217303
## 5 7 0.04 4 0.1981818 0.07217303
## 6 7 0.05 4 0.1981818 0.07217303
## 7 7 0.06 4 0.1981818 0.07217303
## 8 7 0.07 4 0.1981818 0.07217303
## 9 7 0.08 4 0.1981818 0.07217303
## 10 7 0.09 4 0.1981818 0.07217303
## 11 7 0.10 4 0.1981818 0.07217303
## 12 7 0.11 4 0.1981818 0.07217303
## 13 7 0.12 4 0.1981818 0.07217303
## 14 7 0.13 4 0.1981818 0.07217303
## 15 7 0.14 4 0.1981818 0.07217303
## 16 7 0.15 4 0.1981818 0.07217303
## 17 7 0.16 4 0.1981818 0.07217303
## 18 7 0.17 4 0.1981818 0.07217303
## 19 7 0.18 4 0.1981818 0.07217303
## 20 7 0.19 4 0.1981818 0.07217303
## 21 7 0.20 4 0.1981818 0.07217303
## 22 7 0.21 4 0.1981818 0.07217303
## 23 7 0.22 4 0.1981818 0.07217303
## 24 7 0.23 4 0.1981818 0.07217303
## 25 7 0.24 4 0.1981818 0.07217303
## 26 7 0.25 4 0.1981818 0.07217303
## 27 7 0.26 4 0.1981818 0.07217303
## 28 7 0.27 4 0.1981818 0.07217303
## 29 7 0.28 4 0.1981818 0.07217303
## 30 7 0.29 4 0.1981818 0.07217303
## 31 7 0.30 4 0.1981818 0.07217303
## 32 7 0.31 4 0.1981818 0.07217303
## 33 7 0.32 4 0.1981818 0.07217303
## 34 7 0.33 4 0.1981818 0.07217303
## 35 7 0.34 4 0.1981818 0.07217303
## 36 7 0.35 4 0.1981818 0.07217303
## 37 7 0.36 4 0.1981818 0.07217303
## 38 7 0.37 4 0.1981818 0.07217303
## 39 7 0.38 4 0.1981818 0.07217303
## 40 7 0.39 4 0.1981818 0.07217303
## 41 7 0.40 4 0.1981818 0.07217303
## 42 7 0.41 4 0.1981818 0.07217303
## 43 7 0.42 4 0.1981818 0.07217303
## 44 7 0.43 4 0.1981818 0.07217303
## 45 7 0.44 4 0.1981818 0.07217303
## 46 7 0.45 4 0.1981818 0.07217303
## 47 7 0.46 4 0.1981818 0.07217303
## 48 7 0.47 4 0.1981818 0.07217303
## 49 7 0.48 4 0.1981818 0.07217303
## 50 7 0.49 4 0.1981818 0.07217303
## 51 7 0.50 4 0.1981818 0.07217303
## 52 7 0.51 4 0.1981818 0.07217303
## 53 7 0.52 4 0.1981818 0.07217303
## 54 7 0.53 4 0.1981818 0.07217303
## 55 7 0.54 4 0.1981818 0.07217303
## 56 7 0.55 4 0.1981818 0.07217303
## 57 7 0.56 4 0.1981818 0.07217303
## 58 7 0.57 4 0.1981818 0.07217303
## 59 7 0.58 4 0.1981818 0.07217303
## 60 7 0.59 4 0.1981818 0.07217303
## 61 7 0.60 4 0.1981818 0.07217303
## 62 7 0.61 4 0.1981818 0.07217303
## 63 7 0.62 4 0.1981818 0.07217303
## 64 7 0.63 4 0.1981818 0.07217303
## 65 7 0.64 4 0.1981818 0.07217303
## 66 7 0.65 4 0.1981818 0.07217303
## 67 7 0.66 4 0.1981818 0.07217303
## 68 7 0.67 4 0.1981818 0.07217303
## 69 7 0.68 4 0.1981818 0.07217303
## 70 7 0.69 4 0.1981818 0.07217303
## 71 7 0.70 4 0.1981818 0.07217303
## 72 7 0.71 4 0.1981818 0.07217303
## 73 7 0.72 4 0.1981818 0.07217303
## 74 7 0.73 4 0.1981818 0.07217303
## 75 7 0.74 4 0.1981818 0.07217303
## 76 7 0.75 4 0.1981818 0.07217303
## 77 7 0.76 4 0.1981818 0.07217303
## 78 7 0.77 4 0.1981818 0.07217303
## 79 7 0.78 4 0.1981818 0.07217303
## 80 7 0.79 4 0.1981818 0.07217303
## 81 7 0.80 4 0.1981818 0.07217303
## 82 7 0.81 4 0.1981818 0.07217303
## 83 7 0.82 4 0.1981818 0.07217303
## 84 7 0.83 4 0.1981818 0.07217303
## 85 7 0.84 4 0.1981818 0.07217303
## 86 7 0.85 4 0.1981818 0.07217303
## 87 7 0.86 4 0.1981818 0.07217303
## 88 7 0.87 4 0.1981818 0.07217303
## 89 7 0.88 4 0.1981818 0.07217303
## 90 7 0.89 4 0.1981818 0.07217303
## 91 7 0.90 4 0.1981818 0.07217303
## 92 7 0.91 4 0.1981818 0.07217303
## 93 7 0.92 4 0.1981818 0.07217303
## 94 7 0.93 4 0.1981818 0.07217303
## 95 7 0.94 4 0.1981818 0.07217303
## 96 7 0.95 4 0.1981818 0.07217303
## 97 7 0.96 4 0.1981818 0.07217303
## 98 7 0.97 4 0.1981818 0.07217303
## 99 7 0.98 4 0.1981818 0.07217303
## 100 7 0.99 4 0.1981818 0.07217303
## 101 7 1.00 4 0.1981818 0.07217303
## 102 7 0.00 8 0.1982323 0.05738803
## 103 7 0.01 8 0.1982323 0.05738803
## 104 7 0.02 8 0.1982323 0.05738803
## 105 7 0.03 8 0.1982323 0.05738803
## 106 7 0.04 8 0.1982323 0.05738803
## 107 7 0.05 8 0.1982323 0.05738803
## 108 7 0.06 8 0.1982323 0.05738803
## 109 7 0.07 8 0.1982323 0.05738803
## 110 7 0.08 8 0.1982323 0.05738803
## 111 7 0.09 8 0.1982323 0.05738803
## 112 7 0.10 8 0.1982323 0.05738803
## 113 7 0.11 8 0.1982323 0.05738803
## 114 7 0.12 8 0.1982323 0.05738803
## 115 7 0.13 8 0.1982323 0.05738803
## 116 7 0.14 8 0.1982323 0.05738803
## 117 7 0.15 8 0.1982323 0.05738803
## 118 7 0.16 8 0.1982323 0.05738803
## 119 7 0.17 8 0.1982323 0.05738803
## 120 7 0.18 8 0.1982323 0.05738803
## 121 7 0.19 8 0.1982323 0.05738803
## 122 7 0.20 8 0.1982323 0.05738803
## 123 7 0.21 8 0.1982323 0.05738803
## 124 7 0.22 8 0.1982323 0.05738803
## 125 7 0.23 8 0.1982323 0.05738803
## 126 7 0.24 8 0.1982323 0.05738803
## 127 7 0.25 8 0.1982323 0.05738803
## 128 7 0.26 8 0.1982323 0.05738803
## 129 7 0.27 8 0.1982323 0.05738803
## 130 7 0.28 8 0.1982323 0.05738803
## 131 7 0.29 8 0.1982323 0.05738803
## 132 7 0.30 8 0.1982323 0.05738803
## 133 7 0.31 8 0.1982323 0.05738803
## 134 7 0.32 8 0.1982323 0.05738803
## 135 7 0.33 8 0.1982323 0.05738803
## 136 7 0.34 8 0.1982323 0.05738803
## 137 7 0.35 8 0.1982323 0.05738803
## 138 7 0.36 8 0.1982323 0.05738803
## 139 7 0.37 8 0.1982323 0.05738803
## 140 7 0.38 8 0.1982323 0.05738803
## 141 7 0.39 8 0.1982323 0.05738803
## 142 7 0.40 8 0.1982323 0.05738803
## 143 7 0.41 8 0.1982323 0.05738803
## 144 7 0.42 8 0.1982323 0.05738803
## 145 7 0.43 8 0.1982323 0.05738803
## 146 7 0.44 8 0.1982323 0.05738803
## 147 7 0.45 8 0.1982323 0.05738803
## 148 7 0.46 8 0.1982323 0.05738803
## 149 7 0.47 8 0.1982323 0.05738803
## 150 7 0.48 8 0.1982323 0.05738803
## 151 7 0.49 8 0.1982323 0.05738803
## 152 7 0.50 8 0.1982323 0.05738803
## 153 7 0.51 8 0.1982323 0.05738803
## 154 7 0.52 8 0.1982323 0.05738803
## 155 7 0.53 8 0.1982323 0.05738803
## 156 7 0.54 8 0.1982323 0.05738803
## 157 7 0.55 8 0.1982323 0.05738803
## 158 7 0.56 8 0.1982323 0.05738803
## 159 7 0.57 8 0.1982323 0.05738803
## 160 7 0.58 8 0.1982323 0.05738803
## 161 7 0.59 8 0.1982323 0.05738803
## 162 7 0.60 8 0.1982323 0.05738803
## 163 7 0.61 8 0.1982323 0.05738803
## 164 7 0.62 8 0.1982323 0.05738803
## 165 7 0.63 8 0.1982323 0.05738803
## 166 7 0.64 8 0.1982323 0.05738803
## 167 7 0.65 8 0.1982323 0.05738803
## 168 7 0.66 8 0.1982323 0.05738803
## 169 7 0.67 8 0.1982323 0.05738803
## 170 7 0.68 8 0.1982323 0.05738803
## 171 7 0.69 8 0.1982323 0.05738803
## 172 7 0.70 8 0.1982323 0.05738803
## 173 7 0.71 8 0.1982323 0.05738803
## 174 7 0.72 8 0.1982323 0.05738803
## 175 7 0.73 8 0.1982323 0.05738803
## 176 7 0.74 8 0.1982323 0.05738803
## 177 7 0.75 8 0.1982323 0.05738803
## 178 7 0.76 8 0.1982323 0.05738803
## 179 7 0.77 8 0.1982323 0.05738803
## 180 7 0.78 8 0.1982323 0.05738803
## 181 7 0.79 8 0.1982323 0.05738803
## 182 7 0.80 8 0.1982323 0.05738803
## 183 7 0.81 8 0.1982323 0.05738803
## 184 7 0.82 8 0.1982323 0.05738803
## 185 7 0.83 8 0.1982323 0.05738803
## 186 7 0.84 8 0.1982323 0.05738803
## 187 7 0.85 8 0.1982323 0.05738803
## 188 7 0.86 8 0.1982323 0.05738803
## 189 7 0.87 8 0.1982323 0.05738803
## 190 7 0.88 8 0.1982323 0.05738803
## 191 7 0.89 8 0.1982323 0.05738803
## 192 7 0.90 8 0.1982323 0.05738803
## 193 7 0.91 8 0.1982323 0.05738803
## 194 7 0.92 8 0.1982323 0.05738803
## 195 7 0.93 8 0.1982323 0.05738803
## 196 7 0.94 8 0.1982323 0.05738803
## 197 7 0.95 8 0.1982323 0.05738803
## 198 7 0.96 8 0.1982323 0.05738803
## 199 7 0.97 8 0.1982323 0.05738803
## 200 7 0.98 8 0.1982323 0.05738803
## 201 7 0.99 8 0.1982323 0.05738803
## 202 7 1.00 8 0.1982323 0.05738803
## 203 7 0.00 16 0.1983333 0.04441130
## 204 7 0.01 16 0.1983333 0.04441130
## 205 7 0.02 16 0.1983333 0.04441130
## 206 7 0.03 16 0.1983333 0.04441130
## 207 7 0.04 16 0.1983333 0.04441130
## 208 7 0.05 16 0.1983333 0.04441130
## 209 7 0.06 16 0.1983333 0.04441130
## 210 7 0.07 16 0.1983333 0.04441130
## 211 7 0.08 16 0.1983333 0.04441130
## 212 7 0.09 16 0.1983333 0.04441130
## 213 7 0.10 16 0.1983333 0.04441130
## 214 7 0.11 16 0.1983333 0.04441130
## 215 7 0.12 16 0.1983333 0.04441130
## 216 7 0.13 16 0.1983333 0.04441130
## 217 7 0.14 16 0.1983333 0.04441130
## 218 7 0.15 16 0.1983333 0.04441130
## 219 7 0.16 16 0.1983333 0.04441130
## 220 7 0.17 16 0.1983333 0.04441130
## 221 7 0.18 16 0.1983333 0.04441130
## 222 7 0.19 16 0.1983333 0.04441130
## 223 7 0.20 16 0.1983333 0.04441130
## 224 7 0.21 16 0.1983333 0.04441130
## 225 7 0.22 16 0.1983333 0.04441130
## 226 7 0.23 16 0.1983333 0.04441130
## 227 7 0.24 16 0.1983333 0.04441130
## 228 7 0.25 16 0.1983333 0.04441130
## 229 7 0.26 16 0.1983333 0.04441130
## 230 7 0.27 16 0.1983333 0.04441130
## 231 7 0.28 16 0.1983333 0.04441130
## 232 7 0.29 16 0.1983333 0.04441130
## 233 7 0.30 16 0.1983333 0.04441130
## 234 7 0.31 16 0.1983333 0.04441130
## 235 7 0.32 16 0.1983333 0.04441130
## 236 7 0.33 16 0.1983333 0.04441130
## 237 7 0.34 16 0.1983333 0.04441130
## 238 7 0.35 16 0.1983333 0.04441130
## 239 7 0.36 16 0.1983333 0.04441130
## 240 7 0.37 16 0.1983333 0.04441130
## 241 7 0.38 16 0.1983333 0.04441130
## 242 7 0.39 16 0.1983333 0.04441130
## 243 7 0.40 16 0.1983333 0.04441130
## 244 7 0.41 16 0.1983333 0.04441130
## 245 7 0.42 16 0.1983333 0.04441130
## 246 7 0.43 16 0.1983333 0.04441130
## 247 7 0.44 16 0.1983333 0.04441130
## 248 7 0.45 16 0.1983333 0.04441130
## 249 7 0.46 16 0.1983333 0.04441130
## 250 7 0.47 16 0.1983333 0.04441130
## 251 7 0.48 16 0.1983333 0.04441130
## 252 7 0.49 16 0.1983333 0.04441130
## 253 7 0.50 16 0.1983333 0.04441130
## 254 7 0.51 16 0.1983333 0.04441130
## 255 7 0.52 16 0.1983333 0.04441130
## 256 7 0.53 16 0.1983333 0.04441130
## 257 7 0.54 16 0.1983333 0.04441130
## 258 7 0.55 16 0.1983333 0.04441130
## 259 7 0.56 16 0.1983333 0.04441130
## 260 7 0.57 16 0.1983333 0.04441130
## 261 7 0.58 16 0.1983333 0.04441130
## 262 7 0.59 16 0.1983333 0.04441130
## 263 7 0.60 16 0.1983333 0.04441130
## 264 7 0.61 16 0.1983333 0.04441130
## 265 7 0.62 16 0.1983333 0.04441130
## 266 7 0.63 16 0.1983333 0.04441130
## 267 7 0.64 16 0.1983333 0.04441130
## 268 7 0.65 16 0.1983333 0.04441130
## 269 7 0.66 16 0.1983333 0.04441130
## 270 7 0.67 16 0.1983333 0.04441130
## 271 7 0.68 16 0.1983333 0.04441130
## 272 7 0.69 16 0.1983333 0.04441130
## 273 7 0.70 16 0.1983333 0.04441130
## 274 7 0.71 16 0.1983333 0.04441130
## 275 7 0.72 16 0.1983333 0.04441130
## 276 7 0.73 16 0.1983333 0.04441130
## 277 7 0.74 16 0.1983333 0.04441130
## 278 7 0.75 16 0.1983333 0.04441130
## 279 7 0.76 16 0.1983333 0.04441130
## 280 7 0.77 16 0.1983333 0.04441130
## 281 7 0.78 16 0.1983333 0.04441130
## 282 7 0.79 16 0.1983333 0.04441130
## 283 7 0.80 16 0.1983333 0.04441130
## 284 7 0.81 16 0.1983333 0.04441130
## 285 7 0.82 16 0.1983333 0.04441130
## 286 7 0.83 16 0.1983333 0.04441130
## 287 7 0.84 16 0.1983333 0.04441130
## 288 7 0.85 16 0.1983333 0.04441130
## 289 7 0.86 16 0.1983333 0.04441130
## 290 7 0.87 16 0.1983333 0.04441130
## 291 7 0.88 16 0.1983333 0.04441130
## 292 7 0.89 16 0.1983333 0.04441130
## 293 7 0.90 16 0.1983333 0.04441130
## 294 7 0.91 16 0.1983333 0.04441130
## 295 7 0.92 16 0.1983333 0.04441130
## 296 7 0.93 16 0.1983333 0.04441130
## 297 7 0.94 16 0.1983333 0.04441130
## 298 7 0.95 16 0.1983333 0.04441130
## 299 7 0.96 16 0.1983333 0.04441130
## 300 7 0.97 16 0.1983333 0.04441130
## 301 7 0.98 16 0.1983333 0.04441130
## 302 7 0.99 16 0.1983333 0.04441130
## 303 7 1.00 16 0.1983333 0.04441130
## 304 7 0.00 32 0.2119697 0.05354650
## 305 7 0.01 32 0.2119697 0.05354650
## 306 7 0.02 32 0.2119697 0.05354650
## 307 7 0.03 32 0.2119697 0.05354650
## 308 7 0.04 32 0.2119697 0.05354650
## 309 7 0.05 32 0.2119697 0.05354650
## 310 7 0.06 32 0.2119697 0.05354650
## 311 7 0.07 32 0.2119697 0.05354650
## 312 7 0.08 32 0.2119697 0.05354650
## 313 7 0.09 32 0.2119697 0.05354650
## 314 7 0.10 32 0.2119697 0.05354650
## 315 7 0.11 32 0.2119697 0.05354650
## 316 7 0.12 32 0.2119697 0.05354650
## 317 7 0.13 32 0.2119697 0.05354650
## 318 7 0.14 32 0.2119697 0.05354650
## 319 7 0.15 32 0.2119697 0.05354650
## 320 7 0.16 32 0.2119697 0.05354650
## 321 7 0.17 32 0.2119697 0.05354650
## 322 7 0.18 32 0.2119697 0.05354650
## 323 7 0.19 32 0.2119697 0.05354650
## 324 7 0.20 32 0.2119697 0.05354650
## 325 7 0.21 32 0.2119697 0.05354650
## 326 7 0.22 32 0.2119697 0.05354650
## 327 7 0.23 32 0.2119697 0.05354650
## 328 7 0.24 32 0.2119697 0.05354650
## 329 7 0.25 32 0.2119697 0.05354650
## 330 7 0.26 32 0.2119697 0.05354650
## 331 7 0.27 32 0.2119697 0.05354650
## 332 7 0.28 32 0.2119697 0.05354650
## 333 7 0.29 32 0.2119697 0.05354650
## 334 7 0.30 32 0.2119697 0.05354650
## 335 7 0.31 32 0.2119697 0.05354650
## 336 7 0.32 32 0.2119697 0.05354650
## 337 7 0.33 32 0.2119697 0.05354650
## 338 7 0.34 32 0.2119697 0.05354650
## 339 7 0.35 32 0.2119697 0.05354650
## 340 7 0.36 32 0.2119697 0.05354650
## 341 7 0.37 32 0.2119697 0.05354650
## 342 7 0.38 32 0.2119697 0.05354650
## 343 7 0.39 32 0.2119697 0.05354650
## 344 7 0.40 32 0.2119697 0.05354650
## 345 7 0.41 32 0.2119697 0.05354650
## 346 7 0.42 32 0.2119697 0.05354650
## 347 7 0.43 32 0.2119697 0.05354650
## 348 7 0.44 32 0.2119697 0.05354650
## 349 7 0.45 32 0.2119697 0.05354650
## 350 7 0.46 32 0.2119697 0.05354650
## 351 7 0.47 32 0.2119697 0.05354650
## 352 7 0.48 32 0.2119697 0.05354650
## 353 7 0.49 32 0.2119697 0.05354650
## 354 7 0.50 32 0.2119697 0.05354650
## 355 7 0.51 32 0.2119697 0.05354650
## 356 7 0.52 32 0.2119697 0.05354650
## 357 7 0.53 32 0.2119697 0.05354650
## 358 7 0.54 32 0.2119697 0.05354650
## 359 7 0.55 32 0.2119697 0.05354650
## 360 7 0.56 32 0.2119697 0.05354650
## 361 7 0.57 32 0.2119697 0.05354650
## 362 7 0.58 32 0.2119697 0.05354650
## 363 7 0.59 32 0.2119697 0.05354650
## 364 7 0.60 32 0.2119697 0.05354650
## 365 7 0.61 32 0.2119697 0.05354650
## 366 7 0.62 32 0.2119697 0.05354650
## 367 7 0.63 32 0.2119697 0.05354650
## 368 7 0.64 32 0.2119697 0.05354650
## 369 7 0.65 32 0.2119697 0.05354650
## 370 7 0.66 32 0.2119697 0.05354650
## 371 7 0.67 32 0.2119697 0.05354650
## 372 7 0.68 32 0.2119697 0.05354650
## 373 7 0.69 32 0.2119697 0.05354650
## 374 7 0.70 32 0.2119697 0.05354650
## 375 7 0.71 32 0.2119697 0.05354650
## 376 7 0.72 32 0.2119697 0.05354650
## 377 7 0.73 32 0.2119697 0.05354650
## 378 7 0.74 32 0.2119697 0.05354650
## 379 7 0.75 32 0.2119697 0.05354650
## 380 7 0.76 32 0.2119697 0.05354650
## 381 7 0.77 32 0.2119697 0.05354650
## 382 7 0.78 32 0.2119697 0.05354650
## 383 7 0.79 32 0.2119697 0.05354650
## 384 7 0.80 32 0.2119697 0.05354650
## 385 7 0.81 32 0.2119697 0.05354650
## 386 7 0.82 32 0.2119697 0.05354650
## 387 7 0.83 32 0.2119697 0.05354650
## 388 7 0.84 32 0.2119697 0.05354650
## 389 7 0.85 32 0.2119697 0.05354650
## 390 7 0.86 32 0.2119697 0.05354650
## 391 7 0.87 32 0.2119697 0.05354650
## 392 7 0.88 32 0.2119697 0.05354650
## 393 7 0.89 32 0.2119697 0.05354650
## 394 7 0.90 32 0.2119697 0.05354650
## 395 7 0.91 32 0.2119697 0.05354650
## 396 7 0.92 32 0.2119697 0.05354650
## 397 7 0.93 32 0.2119697 0.05354650
## 398 7 0.94 32 0.2119697 0.05354650
## 399 7 0.95 32 0.2119697 0.05354650
## 400 7 0.96 32 0.2119697 0.05354650
## 401 7 0.97 32 0.2119697 0.05354650
## 402 7 0.98 32 0.2119697 0.05354650
## 403 7 0.99 32 0.2119697 0.05354650
## 404 7 1.00 32 0.2119697 0.05354650
## 405 7 0.00 64 0.2119697 0.05125982
## 406 7 0.01 64 0.2119697 0.05125982
## 407 7 0.02 64 0.2119697 0.05125982
## 408 7 0.03 64 0.2119697 0.05125982
## 409 7 0.04 64 0.2119697 0.05125982
## 410 7 0.05 64 0.2119697 0.05125982
## 411 7 0.06 64 0.2119697 0.05125982
## 412 7 0.07 64 0.2119697 0.05125982
## 413 7 0.08 64 0.2119697 0.05125982
## 414 7 0.09 64 0.2119697 0.05125982
## 415 7 0.10 64 0.2119697 0.05125982
## 416 7 0.11 64 0.2119697 0.05125982
## 417 7 0.12 64 0.2119697 0.05125982
## 418 7 0.13 64 0.2119697 0.05125982
## 419 7 0.14 64 0.2119697 0.05125982
## 420 7 0.15 64 0.2119697 0.05125982
## 421 7 0.16 64 0.2119697 0.05125982
## 422 7 0.17 64 0.2119697 0.05125982
## 423 7 0.18 64 0.2119697 0.05125982
## 424 7 0.19 64 0.2119697 0.05125982
## 425 7 0.20 64 0.2119697 0.05125982
## 426 7 0.21 64 0.2119697 0.05125982
## 427 7 0.22 64 0.2119697 0.05125982
## 428 7 0.23 64 0.2119697 0.05125982
## 429 7 0.24 64 0.2119697 0.05125982
## 430 7 0.25 64 0.2119697 0.05125982
## 431 7 0.26 64 0.2119697 0.05125982
## 432 7 0.27 64 0.2119697 0.05125982
## 433 7 0.28 64 0.2119697 0.05125982
## 434 7 0.29 64 0.2119697 0.05125982
## 435 7 0.30 64 0.2119697 0.05125982
## 436 7 0.31 64 0.2119697 0.05125982
## 437 7 0.32 64 0.2119697 0.05125982
## 438 7 0.33 64 0.2119697 0.05125982
## 439 7 0.34 64 0.2119697 0.05125982
## 440 7 0.35 64 0.2119697 0.05125982
## 441 7 0.36 64 0.2119697 0.05125982
## 442 7 0.37 64 0.2119697 0.05125982
## 443 7 0.38 64 0.2119697 0.05125982
## 444 7 0.39 64 0.2119697 0.05125982
## 445 7 0.40 64 0.2119697 0.05125982
## 446 7 0.41 64 0.2119697 0.05125982
## 447 7 0.42 64 0.2119697 0.05125982
## 448 7 0.43 64 0.2119697 0.05125982
## 449 7 0.44 64 0.2119697 0.05125982
## 450 7 0.45 64 0.2119697 0.05125982
## 451 7 0.46 64 0.2119697 0.05125982
## 452 7 0.47 64 0.2119697 0.05125982
## 453 7 0.48 64 0.2119697 0.05125982
## 454 7 0.49 64 0.2119697 0.05125982
## 455 7 0.50 64 0.2119697 0.05125982
## 456 7 0.51 64 0.2119697 0.05125982
## 457 7 0.52 64 0.2119697 0.05125982
## 458 7 0.53 64 0.2119697 0.05125982
## 459 7 0.54 64 0.2119697 0.05125982
## 460 7 0.55 64 0.2119697 0.05125982
## 461 7 0.56 64 0.2119697 0.05125982
## 462 7 0.57 64 0.2119697 0.05125982
## 463 7 0.58 64 0.2119697 0.05125982
## 464 7 0.59 64 0.2119697 0.05125982
## 465 7 0.60 64 0.2119697 0.05125982
## 466 7 0.61 64 0.2119697 0.05125982
## 467 7 0.62 64 0.2119697 0.05125982
## 468 7 0.63 64 0.2119697 0.05125982
## 469 7 0.64 64 0.2119697 0.05125982
## 470 7 0.65 64 0.2119697 0.05125982
## 471 7 0.66 64 0.2119697 0.05125982
## 472 7 0.67 64 0.2119697 0.05125982
## 473 7 0.68 64 0.2119697 0.05125982
## 474 7 0.69 64 0.2119697 0.05125982
## 475 7 0.70 64 0.2119697 0.05125982
## 476 7 0.71 64 0.2119697 0.05125982
## 477 7 0.72 64 0.2119697 0.05125982
## 478 7 0.73 64 0.2119697 0.05125982
## 479 7 0.74 64 0.2119697 0.05125982
## 480 7 0.75 64 0.2119697 0.05125982
## 481 7 0.76 64 0.2119697 0.05125982
## 482 7 0.77 64 0.2119697 0.05125982
## 483 7 0.78 64 0.2119697 0.05125982
## 484 7 0.79 64 0.2119697 0.05125982
## 485 7 0.80 64 0.2119697 0.05125982
## 486 7 0.81 64 0.2119697 0.05125982
## 487 7 0.82 64 0.2119697 0.05125982
## 488 7 0.83 64 0.2119697 0.05125982
## 489 7 0.84 64 0.2119697 0.05125982
## 490 7 0.85 64 0.2119697 0.05125982
## 491 7 0.86 64 0.2119697 0.05125982
## 492 7 0.87 64 0.2119697 0.05125982
## 493 7 0.88 64 0.2119697 0.05125982
## 494 7 0.89 64 0.2119697 0.05125982
## 495 7 0.90 64 0.2119697 0.05125982
## 496 7 0.91 64 0.2119697 0.05125982
## 497 7 0.92 64 0.2119697 0.05125982
## 498 7 0.93 64 0.2119697 0.05125982
## 499 7 0.94 64 0.2119697 0.05125982
## 500 7 0.95 64 0.2119697 0.05125982
## 501 7 0.96 64 0.2119697 0.05125982
## 502 7 0.97 64 0.2119697 0.05125982
## 503 7 0.98 64 0.2119697 0.05125982
## 504 7 0.99 64 0.2119697 0.05125982
## 505 7 1.00 64 0.2119697 0.05125982
## 506 7 0.00 128 0.1984848 0.05627531
## 507 7 0.01 128 0.1984848 0.05627531
## 508 7 0.02 128 0.1984848 0.05627531
## 509 7 0.03 128 0.1984848 0.05627531
## 510 7 0.04 128 0.1984848 0.05627531
## 511 7 0.05 128 0.1984848 0.05627531
## 512 7 0.06 128 0.1984848 0.05627531
## 513 7 0.07 128 0.1984848 0.05627531
## 514 7 0.08 128 0.1984848 0.05627531
## 515 7 0.09 128 0.1984848 0.05627531
## 516 7 0.10 128 0.1984848 0.05627531
## 517 7 0.11 128 0.1984848 0.05627531
## 518 7 0.12 128 0.1984848 0.05627531
## 519 7 0.13 128 0.1984848 0.05627531
## 520 7 0.14 128 0.1984848 0.05627531
## 521 7 0.15 128 0.1984848 0.05627531
## 522 7 0.16 128 0.1984848 0.05627531
## 523 7 0.17 128 0.1984848 0.05627531
## 524 7 0.18 128 0.1984848 0.05627531
## 525 7 0.19 128 0.1984848 0.05627531
## 526 7 0.20 128 0.1984848 0.05627531
## 527 7 0.21 128 0.1984848 0.05627531
## 528 7 0.22 128 0.1984848 0.05627531
## 529 7 0.23 128 0.1984848 0.05627531
## 530 7 0.24 128 0.1984848 0.05627531
## 531 7 0.25 128 0.1984848 0.05627531
## 532 7 0.26 128 0.1984848 0.05627531
## 533 7 0.27 128 0.1984848 0.05627531
## 534 7 0.28 128 0.1984848 0.05627531
## 535 7 0.29 128 0.1984848 0.05627531
## 536 7 0.30 128 0.1984848 0.05627531
## 537 7 0.31 128 0.1984848 0.05627531
## 538 7 0.32 128 0.1984848 0.05627531
## 539 7 0.33 128 0.1984848 0.05627531
## 540 7 0.34 128 0.1984848 0.05627531
## 541 7 0.35 128 0.1984848 0.05627531
## 542 7 0.36 128 0.1984848 0.05627531
## 543 7 0.37 128 0.1984848 0.05627531
## 544 7 0.38 128 0.1984848 0.05627531
## 545 7 0.39 128 0.1984848 0.05627531
## 546 7 0.40 128 0.1984848 0.05627531
## 547 7 0.41 128 0.1984848 0.05627531
## 548 7 0.42 128 0.1984848 0.05627531
## 549 7 0.43 128 0.1984848 0.05627531
## 550 7 0.44 128 0.1984848 0.05627531
## 551 7 0.45 128 0.1984848 0.05627531
## 552 7 0.46 128 0.1984848 0.05627531
## 553 7 0.47 128 0.1984848 0.05627531
## 554 7 0.48 128 0.1984848 0.05627531
## 555 7 0.49 128 0.1984848 0.05627531
## 556 7 0.50 128 0.1984848 0.05627531
## 557 7 0.51 128 0.1984848 0.05627531
## 558 7 0.52 128 0.1984848 0.05627531
## 559 7 0.53 128 0.1984848 0.05627531
## 560 7 0.54 128 0.1984848 0.05627531
## 561 7 0.55 128 0.1984848 0.05627531
## 562 7 0.56 128 0.1984848 0.05627531
## 563 7 0.57 128 0.1984848 0.05627531
## 564 7 0.58 128 0.1984848 0.05627531
## 565 7 0.59 128 0.1984848 0.05627531
## 566 7 0.60 128 0.1984848 0.05627531
## 567 7 0.61 128 0.1984848 0.05627531
## 568 7 0.62 128 0.1984848 0.05627531
## 569 7 0.63 128 0.1984848 0.05627531
## 570 7 0.64 128 0.1984848 0.05627531
## 571 7 0.65 128 0.1984848 0.05627531
## 572 7 0.66 128 0.1984848 0.05627531
## 573 7 0.67 128 0.1984848 0.05627531
## 574 7 0.68 128 0.1984848 0.05627531
## 575 7 0.69 128 0.1984848 0.05627531
## 576 7 0.70 128 0.1984848 0.05627531
## 577 7 0.71 128 0.1984848 0.05627531
## 578 7 0.72 128 0.1984848 0.05627531
## 579 7 0.73 128 0.1984848 0.05627531
## 580 7 0.74 128 0.1984848 0.05627531
## 581 7 0.75 128 0.1984848 0.05627531
## 582 7 0.76 128 0.1984848 0.05627531
## 583 7 0.77 128 0.1984848 0.05627531
## 584 7 0.78 128 0.1984848 0.05627531
## 585 7 0.79 128 0.1984848 0.05627531
## 586 7 0.80 128 0.1984848 0.05627531
## 587 7 0.81 128 0.1984848 0.05627531
## 588 7 0.82 128 0.1984848 0.05627531
## 589 7 0.83 128 0.1984848 0.05627531
## 590 7 0.84 128 0.1984848 0.05627531
## 591 7 0.85 128 0.1984848 0.05627531
## 592 7 0.86 128 0.1984848 0.05627531
## 593 7 0.87 128 0.1984848 0.05627531
## 594 7 0.88 128 0.1984848 0.05627531
## 595 7 0.89 128 0.1984848 0.05627531
## 596 7 0.90 128 0.1984848 0.05627531
## 597 7 0.91 128 0.1984848 0.05627531
## 598 7 0.92 128 0.1984848 0.05627531
## 599 7 0.93 128 0.1984848 0.05627531
## 600 7 0.94 128 0.1984848 0.05627531
## 601 7 0.95 128 0.1984848 0.05627531
## 602 7 0.96 128 0.1984848 0.05627531
## 603 7 0.97 128 0.1984848 0.05627531
## 604 7 0.98 128 0.1984848 0.05627531
## 605 7 0.99 128 0.1984848 0.05627531
## 606 7 1.00 128 0.1984848 0.05627531
## 607 7 0.00 256 0.2098485 0.06508961
## 608 7 0.01 256 0.2098485 0.06508961
## 609 7 0.02 256 0.2098485 0.06508961
## 610 7 0.03 256 0.2098485 0.06508961
## 611 7 0.04 256 0.2098485 0.06508961
## 612 7 0.05 256 0.2098485 0.06508961
## 613 7 0.06 256 0.2098485 0.06508961
## 614 7 0.07 256 0.2098485 0.06508961
## 615 7 0.08 256 0.2098485 0.06508961
## 616 7 0.09 256 0.2098485 0.06508961
## 617 7 0.10 256 0.2098485 0.06508961
## 618 7 0.11 256 0.2098485 0.06508961
## 619 7 0.12 256 0.2098485 0.06508961
## 620 7 0.13 256 0.2098485 0.06508961
## 621 7 0.14 256 0.2098485 0.06508961
## 622 7 0.15 256 0.2098485 0.06508961
## 623 7 0.16 256 0.2098485 0.06508961
## 624 7 0.17 256 0.2098485 0.06508961
## 625 7 0.18 256 0.2098485 0.06508961
## 626 7 0.19 256 0.2098485 0.06508961
## 627 7 0.20 256 0.2098485 0.06508961
## 628 7 0.21 256 0.2098485 0.06508961
## 629 7 0.22 256 0.2098485 0.06508961
## 630 7 0.23 256 0.2098485 0.06508961
## 631 7 0.24 256 0.2098485 0.06508961
## 632 7 0.25 256 0.2098485 0.06508961
## 633 7 0.26 256 0.2098485 0.06508961
## 634 7 0.27 256 0.2098485 0.06508961
## 635 7 0.28 256 0.2098485 0.06508961
## 636 7 0.29 256 0.2098485 0.06508961
## 637 7 0.30 256 0.2098485 0.06508961
## 638 7 0.31 256 0.2098485 0.06508961
## 639 7 0.32 256 0.2098485 0.06508961
## 640 7 0.33 256 0.2098485 0.06508961
## 641 7 0.34 256 0.2098485 0.06508961
## 642 7 0.35 256 0.2098485 0.06508961
## 643 7 0.36 256 0.2098485 0.06508961
## 644 7 0.37 256 0.2098485 0.06508961
## 645 7 0.38 256 0.2098485 0.06508961
## 646 7 0.39 256 0.2098485 0.06508961
## 647 7 0.40 256 0.2098485 0.06508961
## 648 7 0.41 256 0.2098485 0.06508961
## 649 7 0.42 256 0.2098485 0.06508961
## 650 7 0.43 256 0.2098485 0.06508961
## 651 7 0.44 256 0.2098485 0.06508961
## 652 7 0.45 256 0.2098485 0.06508961
## 653 7 0.46 256 0.2098485 0.06508961
## 654 7 0.47 256 0.2098485 0.06508961
## 655 7 0.48 256 0.2098485 0.06508961
## 656 7 0.49 256 0.2098485 0.06508961
## 657 7 0.50 256 0.2098485 0.06508961
## 658 7 0.51 256 0.2098485 0.06508961
## 659 7 0.52 256 0.2098485 0.06508961
## 660 7 0.53 256 0.2098485 0.06508961
## 661 7 0.54 256 0.2098485 0.06508961
## 662 7 0.55 256 0.2098485 0.06508961
## 663 7 0.56 256 0.2098485 0.06508961
## 664 7 0.57 256 0.2098485 0.06508961
## 665 7 0.58 256 0.2098485 0.06508961
## 666 7 0.59 256 0.2098485 0.06508961
## 667 7 0.60 256 0.2098485 0.06508961
## 668 7 0.61 256 0.2098485 0.06508961
## 669 7 0.62 256 0.2098485 0.06508961
## 670 7 0.63 256 0.2098485 0.06508961
## 671 7 0.64 256 0.2098485 0.06508961
## 672 7 0.65 256 0.2098485 0.06508961
## 673 7 0.66 256 0.2098485 0.06508961
## 674 7 0.67 256 0.2098485 0.06508961
## 675 7 0.68 256 0.2098485 0.06508961
## 676 7 0.69 256 0.2098485 0.06508961
## 677 7 0.70 256 0.2098485 0.06508961
## 678 7 0.71 256 0.2098485 0.06508961
## 679 7 0.72 256 0.2098485 0.06508961
## 680 7 0.73 256 0.2098485 0.06508961
## 681 7 0.74 256 0.2098485 0.06508961
## 682 7 0.75 256 0.2098485 0.06508961
## 683 7 0.76 256 0.2098485 0.06508961
## 684 7 0.77 256 0.2098485 0.06508961
## 685 7 0.78 256 0.2098485 0.06508961
## 686 7 0.79 256 0.2098485 0.06508961
## 687 7 0.80 256 0.2098485 0.06508961
## 688 7 0.81 256 0.2098485 0.06508961
## 689 7 0.82 256 0.2098485 0.06508961
## 690 7 0.83 256 0.2098485 0.06508961
## 691 7 0.84 256 0.2098485 0.06508961
## 692 7 0.85 256 0.2098485 0.06508961
## 693 7 0.86 256 0.2098485 0.06508961
## 694 7 0.87 256 0.2098485 0.06508961
## 695 7 0.88 256 0.2098485 0.06508961
## 696 7 0.89 256 0.2098485 0.06508961
## 697 7 0.90 256 0.2098485 0.06508961
## 698 7 0.91 256 0.2098485 0.06508961
## 699 7 0.92 256 0.2098485 0.06508961
## 700 7 0.93 256 0.2098485 0.06508961
## 701 7 0.94 256 0.2098485 0.06508961
## 702 7 0.95 256 0.2098485 0.06508961
## 703 7 0.96 256 0.2098485 0.06508961
## 704 7 0.97 256 0.2098485 0.06508961
## 705 7 0.98 256 0.2098485 0.06508961
## 706 7 0.99 256 0.2098485 0.06508961
## 707 7 1.00 256 0.2098485 0.06508961
## 708 7 0.00 512 0.2121212 0.07327353
## 709 7 0.01 512 0.2121212 0.07327353
## 710 7 0.02 512 0.2121212 0.07327353
## 711 7 0.03 512 0.2121212 0.07327353
## 712 7 0.04 512 0.2121212 0.07327353
## 713 7 0.05 512 0.2121212 0.07327353
## 714 7 0.06 512 0.2121212 0.07327353
## 715 7 0.07 512 0.2121212 0.07327353
## 716 7 0.08 512 0.2121212 0.07327353
## 717 7 0.09 512 0.2121212 0.07327353
## 718 7 0.10 512 0.2121212 0.07327353
## 719 7 0.11 512 0.2121212 0.07327353
## 720 7 0.12 512 0.2121212 0.07327353
## 721 7 0.13 512 0.2121212 0.07327353
## 722 7 0.14 512 0.2121212 0.07327353
## 723 7 0.15 512 0.2121212 0.07327353
## 724 7 0.16 512 0.2121212 0.07327353
## 725 7 0.17 512 0.2121212 0.07327353
## 726 7 0.18 512 0.2121212 0.07327353
## 727 7 0.19 512 0.2121212 0.07327353
## 728 7 0.20 512 0.2121212 0.07327353
## 729 7 0.21 512 0.2121212 0.07327353
## 730 7 0.22 512 0.2121212 0.07327353
## 731 7 0.23 512 0.2121212 0.07327353
## 732 7 0.24 512 0.2121212 0.07327353
## 733 7 0.25 512 0.2121212 0.07327353
## 734 7 0.26 512 0.2121212 0.07327353
## 735 7 0.27 512 0.2121212 0.07327353
## 736 7 0.28 512 0.2121212 0.07327353
## 737 7 0.29 512 0.2121212 0.07327353
## 738 7 0.30 512 0.2121212 0.07327353
## 739 7 0.31 512 0.2121212 0.07327353
## 740 7 0.32 512 0.2121212 0.07327353
## 741 7 0.33 512 0.2121212 0.07327353
## 742 7 0.34 512 0.2121212 0.07327353
## 743 7 0.35 512 0.2121212 0.07327353
## 744 7 0.36 512 0.2121212 0.07327353
## 745 7 0.37 512 0.2121212 0.07327353
## 746 7 0.38 512 0.2121212 0.07327353
## 747 7 0.39 512 0.2121212 0.07327353
## 748 7 0.40 512 0.2121212 0.07327353
## 749 7 0.41 512 0.2121212 0.07327353
## 750 7 0.42 512 0.2121212 0.07327353
## 751 7 0.43 512 0.2121212 0.07327353
## 752 7 0.44 512 0.2121212 0.07327353
## 753 7 0.45 512 0.2121212 0.07327353
## 754 7 0.46 512 0.2121212 0.07327353
## 755 7 0.47 512 0.2121212 0.07327353
## 756 7 0.48 512 0.2121212 0.07327353
## 757 7 0.49 512 0.2121212 0.07327353
## 758 7 0.50 512 0.2121212 0.07327353
## 759 7 0.51 512 0.2121212 0.07327353
## 760 7 0.52 512 0.2121212 0.07327353
## 761 7 0.53 512 0.2121212 0.07327353
## 762 7 0.54 512 0.2121212 0.07327353
## 763 7 0.55 512 0.2121212 0.07327353
## 764 7 0.56 512 0.2121212 0.07327353
## 765 7 0.57 512 0.2121212 0.07327353
## 766 7 0.58 512 0.2121212 0.07327353
## 767 7 0.59 512 0.2121212 0.07327353
## 768 7 0.60 512 0.2121212 0.07327353
## 769 7 0.61 512 0.2121212 0.07327353
## 770 7 0.62 512 0.2121212 0.07327353
## 771 7 0.63 512 0.2121212 0.07327353
## 772 7 0.64 512 0.2121212 0.07327353
## 773 7 0.65 512 0.2121212 0.07327353
## 774 7 0.66 512 0.2121212 0.07327353
## 775 7 0.67 512 0.2121212 0.07327353
## 776 7 0.68 512 0.2121212 0.07327353
## 777 7 0.69 512 0.2121212 0.07327353
## 778 7 0.70 512 0.2121212 0.07327353
## 779 7 0.71 512 0.2121212 0.07327353
## 780 7 0.72 512 0.2121212 0.07327353
## 781 7 0.73 512 0.2121212 0.07327353
## 782 7 0.74 512 0.2121212 0.07327353
## 783 7 0.75 512 0.2121212 0.07327353
## 784 7 0.76 512 0.2121212 0.07327353
## 785 7 0.77 512 0.2121212 0.07327353
## 786 7 0.78 512 0.2121212 0.07327353
## 787 7 0.79 512 0.2121212 0.07327353
## 788 7 0.80 512 0.2121212 0.07327353
## 789 7 0.81 512 0.2121212 0.07327353
## 790 7 0.82 512 0.2121212 0.07327353
## 791 7 0.83 512 0.2121212 0.07327353
## 792 7 0.84 512 0.2121212 0.07327353
## 793 7 0.85 512 0.2121212 0.07327353
## 794 7 0.86 512 0.2121212 0.07327353
## 795 7 0.87 512 0.2121212 0.07327353
## 796 7 0.88 512 0.2121212 0.07327353
## 797 7 0.89 512 0.2121212 0.07327353
## 798 7 0.90 512 0.2121212 0.07327353
## 799 7 0.91 512 0.2121212 0.07327353
## 800 7 0.92 512 0.2121212 0.07327353
## 801 7 0.93 512 0.2121212 0.07327353
## 802 7 0.94 512 0.2121212 0.07327353
## 803 7 0.95 512 0.2121212 0.07327353
## 804 7 0.96 512 0.2121212 0.07327353
## 805 7 0.97 512 0.2121212 0.07327353
## 806 7 0.98 512 0.2121212 0.07327353
## 807 7 0.99 512 0.2121212 0.07327353
## 808 7 1.00 512 0.2121212 0.07327353
svm_tune$best.parameters$epsilon
## [1] 0
svm_tune$best.parameters$cost
## [1] 4
svm_tune$best.parameters$cross
## [1] 7
If we have labeled data, SVM can be used to generate multiple separating hyperplanes such that the data space is divided into segments and each segment contains only one kind of data. SVM technique is generally useful for data which has non-regularity which means, data whose distribution is unknown. Response variable has multiple levels and this is being addressed with k(k-1)/2 binary classifiers followed by voting approach. 5 Fold cross validation has resulted accuracy of 77.92793 and all the fold has accuracy of 76.13636 82.02247 78.65169 77.52809 75.2809
svm.2<-svm(transport_employee_aval_final$Transport~., data=transport_employee_aval_final, kernel="linear", tolerance=0.0001, shrinking=TRUE, cross=7, fitted=TRUE)
summary(svm.2)
##
## Call:
## svm(formula = transport_employee_aval_final$Transport ~ ., data = transport_employee_aval_final,
## kernel = "linear", tolerance = 1e-04, shrinking = TRUE, cross = 7,
## fitted = TRUE)
##
##
## Parameters:
## SVM-Type: C-classification
## SVM-Kernel: linear
## cost: 1
## gamma: 0.1111111
##
## Number of Support Vectors: 199
##
## ( 95 83 21 )
##
##
## Number of Classes: 3
##
## Levels:
## 2Wheeler Car Public Transport
##
## 7-fold cross-validation on training data:
##
## Total Accuracy: 78.15315
## Single Accuracies:
## 74.60317 79.36508 84.375 79.36508 78.125 77.77778 73.4375
First here we will run the model on the same dataset. We have used to predict on same trainng data and accuracy is 87.5% . Key observation here are following from confusion matrix??? ???Model has been able to predict only 5 2Wheeler out of 83 2Wheeler which is quite bad ???Model has been able to predict 53 Car out of 61 Car which is quite good ???Model has been able to predict 295 Public Transport out of 300 Public Transport which is quite bad
pred <- predict(svm.2, transport_employee_aval_final)
transport_employee_aval_final$TransportPredicted <- pred
EmployeeTransport <- table(actualclass=transport_employee_aval_final$Transport, predictedclass=transport_employee_aval_final$TransportPredicted)
EmployeeTransport
## predictedclass
## actualclass 2Wheeler Car Public Transport
## 2Wheeler 5 4 74
## Car 1 53 7
## Public Transport 0 5 295
confusionMatrix(EmployeeTransport)
## Confusion Matrix and Statistics
##
## predictedclass
## actualclass 2Wheeler Car Public Transport
## 2Wheeler 5 4 74
## Car 1 53 7
## Public Transport 0 5 295
##
## Overall Statistics
##
## Accuracy : 0.795
## 95% CI : (0.7545, 0.8316)
## No Information Rate : 0.8468
## P-Value [Acc > NIR] : 0.9986
##
## Kappa : 0.4953
## Mcnemar's Test P-Value : <2e-16
##
## Statistics by Class:
##
## Class: 2Wheeler Class: Car Class: Public Transport
## Sensitivity 0.83333 0.8548 0.7846
## Specificity 0.82192 0.9791 0.9265
## Pos Pred Value 0.06024 0.8689 0.9833
## Neg Pred Value 0.99723 0.9765 0.4375
## Prevalence 0.01351 0.1396 0.8468
## Detection Rate 0.01126 0.1194 0.6644
## Detection Prevalence 0.18694 0.1374 0.6757
## Balanced Accuracy 0.82763 0.9169 0.8555
First here we will run the model on the same dataset. We have used to predict on same trainng data and accuracy is 79.5%.
The use of this plot is to determine the possible range where we can narrow down our search to and try further tuning if required.For instance, this plot shows that I can run tuning for epsilon in the new range of 0.19 to 0.20.
Key observation here are following from confusion matrix of model developped from tuned one??? #Observation from Untuned SVM Model Confusion Matrix:
???Model has been able to predict only 5 2Wheeler out of 83 2Wheeler which is quite bad ???Model has been able to predict 53 Car out of 61 Car which is quite good ???Model has been able to predict 295 Public Transport out of 300 Public Transport which is quite bad #Observation from tuned with CV SVM Model Confusion Matrix:
???Model has been able to predict only 43 2Wheeler out of 83 2Wheeler which is quite good and shows remarkable improvement from non-tuned one ???Model has been able to predict 58 Car out of 61 Car which is quite good and shows improvement from non-tuned model ???Model has been able to predict 292 Public Transport out of 300 Public Transport which is still good but there has been slight detoriation from non-tuned model
#plot(svm_tune)
mysvm <- svm(transport_employee_aval_final$Transport~., data=transport_employee_aval_final, cost = svm_tune$best.parameters$cost, epsilon = svm_tune$best.parameters$epsilon)
summary(mysvm)
##
## Call:
## svm(formula = transport_employee_aval_final$Transport ~ ., data = transport_employee_aval_final,
## cost = svm_tune$best.parameters$cost, epsilon = svm_tune$best.parameters$epsilon)
##
##
## Parameters:
## SVM-Type: C-classification
## SVM-Kernel: radial
## cost: 4
## gamma: 0.09090909
##
## Number of Support Vectors: 216
##
## ( 110 79 27 )
##
##
## Number of Classes: 3
##
## Levels:
## 2Wheeler Car Public Transport
pred_tuned <- predict(best_mod, transport_employee_aval_final)
transport_employee_aval_final$TransportPredictedTuned <- pred_tuned
EmployeeTransportTuned <- table(actualclass=transport_employee_aval_final$Transport, predictedclass=transport_employee_aval_final$TransportPredictedTuned)
EmployeeTransportTuned
## predictedclass
## actualclass 2Wheeler Car Public Transport
## 2Wheeler 34 0 49
## Car 0 54 7
## Public Transport 6 1 293
confusionMatrix(EmployeeTransportTuned)
## Confusion Matrix and Statistics
##
## predictedclass
## actualclass 2Wheeler Car Public Transport
## 2Wheeler 34 0 49
## Car 0 54 7
## Public Transport 6 1 293
##
## Overall Statistics
##
## Accuracy : 0.8581
## 95% CI : (0.8221, 0.8892)
## No Information Rate : 0.786
## P-Value [Acc > NIR] : 6.983e-05
##
## Kappa : 0.6738
## Mcnemar's Test P-Value : NA
##
## Statistics by Class:
##
## Class: 2Wheeler Class: Car Class: Public Transport
## Sensitivity 0.85000 0.9818 0.8395
## Specificity 0.87871 0.9820 0.9263
## Pos Pred Value 0.40964 0.8852 0.9767
## Neg Pred Value 0.98338 0.9974 0.6111
## Prevalence 0.09009 0.1239 0.7860
## Detection Rate 0.07658 0.1216 0.6599
## Detection Prevalence 0.18694 0.1374 0.6757
## Balanced Accuracy 0.86436 0.9819 0.8829
Predicted mode of transport from SVM mode is ???Public Teansport???
transport_employee_aval_test <- read.csv('Cars2.csv')
## Warning in read.table(file = file, header = header, sep = sep, quote =
## quote, : incomplete final line found by readTableHeader on 'Cars2.csv'
transport_employee_aval_test_addl <- transport_employee_aval_test
transport_employee_aval_test$PredictedTransport <- predict(svm.2, transport_employee_aval_test)
transport_employee_aval_test
## Age Gender Engineer MBA Work.Exp Salary Distance license
## 1 25 Male 0 0 2 10 5 1
## 2 25 Female 1 0 2 10 5 0
## PredictedTransport
## 1 Public Transport
## 2 Public Transport
levels(transport_employee_aval_test$PredictedTransport)
## [1] "2Wheeler" "Car" "Public Transport"
multinom function allows to have logistic regression based on multiple class.p-value of the model has also been calcualted below. First transport has been relevlled so that base can be taken as ???Public Transport???. Test data with multinom function alsows reveals ???Public Transport??? as preferred mode for test data
transport_employee_aval_final_logit$Transport <- relevel(transport_employee_aval_final_logit$Transport, ref = "Public Transport")
mldata.mullogi1 <- multinom(Transport ~. , data=transport_employee_aval_final_logit)
## # weights: 30 (18 variable)
## initial value 487.783856
## iter 10 value 271.055393
## iter 20 value 205.836918
## iter 30 value 190.838699
## final value 190.553721
## converged
summary(mldata.mullogi1)
## Call:
## multinom(formula = Transport ~ ., data = transport_employee_aval_final_logit)
##
## Coefficients:
## (Intercept) Age GenderMale Engineer MBA
## 2Wheeler 5.88295 -0.370013 -1.341381 -0.008517348 -0.5310482
## Car -67.90478 2.130984 -1.921248 0.880957544 -1.9051619
## Work.Exp Salary Distance license
## 2Wheeler 0.06725612 0.05844737 0.1828228 1.883906
## Car -1.16749276 0.20088355 0.5337289 3.044013
##
## Std. Errors:
## (Intercept) Age GenderMale Engineer MBA Work.Exp
## 2Wheeler 1.982265 0.08483373 0.3117731 0.3171927 0.3466816 0.1173394
## Car 15.533262 0.52369922 0.8420679 0.9039385 0.9257862 0.3624858
## Salary Distance license
## 2Wheeler 0.05459352 0.04569778 0.3798156
## Car 0.07480403 0.14147989 0.8724632
##
## Residual Deviance: 381.1074
## AIC: 417.1074
# now get the p values by first getting the t values
coeftest(mldata.mullogi1)
##
## z test of coefficients:
##
## Estimate Std. Error z value Pr(>|z|)
## 2Wheeler:(Intercept) 5.8829503 1.9822652 2.9678 0.0029995 **
## 2Wheeler:Age -0.3700130 0.0848337 -4.3616 1.291e-05 ***
## 2Wheeler:GenderMale -1.3413806 0.3117731 -4.3024 1.689e-05 ***
## 2Wheeler:Engineer -0.0085173 0.3171927 -0.0269 0.9785776
## 2Wheeler:MBA -0.5310482 0.3466816 -1.5318 0.1255708
## 2Wheeler:Work.Exp 0.0672561 0.1173394 0.5732 0.5665255
## 2Wheeler:Salary 0.0584474 0.0545935 1.0706 0.2843530
## 2Wheeler:Distance 0.1828228 0.0456978 4.0007 6.316e-05 ***
## 2Wheeler:license 1.8839059 0.3798156 4.9601 7.047e-07 ***
## Car:(Intercept) -67.9047820 15.5332620 -4.3716 1.234e-05 ***
## Car:Age 2.1309839 0.5236992 4.0691 4.720e-05 ***
## Car:GenderMale -1.9212478 0.8420679 -2.2816 0.0225140 *
## Car:Engineer 0.8809575 0.9039385 0.9746 0.3297702
## Car:MBA -1.9051619 0.9257862 -2.0579 0.0396011 *
## Car:Work.Exp -1.1674928 0.3624858 -3.2208 0.0012784 **
## Car:Salary 0.2008836 0.0748040 2.6855 0.0072429 **
## Car:Distance 0.5337289 0.1414799 3.7725 0.0001616 ***
## Car:license 3.0440130 0.8724632 3.4890 0.0004849 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
transport_employee_aval_test_addl$transportPredict<- predict(mldata.mullogi1, transport_employee_aval_test_addl) # predict on new data
SVM Repported following variables are key for determining the transport mode (descending priority).
Age, Work Experience, Gender, Distance, Sales, GenderFemale, License, Engineer and MBA
So SVM reported Age and Work Exp as most important criteria for determining trasnport mode.
cat('SVM model case:\n')
## SVM model case:
weightV <- t(svm.2$coefs) %*% svm.2$SV # weight vectors
wkk <- apply(weightV, 2, function(v){sqrt(sum(v^2))}) # weight
wkkFinal <- sort(wkk, decreasing = T)
print(wkkFinal)
## Age Work.Exp GenderMale Distance Salary
## 20.573947 17.652933 15.228503 11.630566 10.742283
## GenderFemale license Engineer MBA
## 8.476371 5.928937 3.296868 1.230640
Our aim here is to understand why car is being selected as transport. So we are not interested into three level of transport ???2Wheeler???,???Car??? and ???Public Transport???. Our aim which will be ???Car??? and ???NoCar??? Data is biassed towards non-car
transport_employee_aval_final_boost$Transport <- ifelse(transport_employee_aval_final_boost$Transport == "Car",1,0)
table(transport_employee_aval_final_boost$Transport )
##
## 0 1
## 383 61
summary(transport_employee_aval_final_boost)
## Age Gender Engineer MBA
## Min. :18.00 Female:128 Min. :0.0000 Min. :0.0000
## 1st Qu.:25.00 Male :316 1st Qu.:1.0000 1st Qu.:0.0000
## Median :27.00 Median :1.0000 Median :0.0000
## Mean :27.75 Mean :0.7545 Mean :0.2523
## 3rd Qu.:30.00 3rd Qu.:1.0000 3rd Qu.:1.0000
## Max. :43.00 Max. :1.0000 Max. :1.0000
## Work.Exp Salary Distance license
## Min. : 0.0 Min. : 6.50 Min. : 3.20 Min. :0.0000
## 1st Qu.: 3.0 1st Qu.: 9.80 1st Qu.: 8.80 1st Qu.:0.0000
## Median : 5.0 Median :13.60 Median :11.00 Median :0.0000
## Mean : 6.3 Mean :16.24 Mean :11.32 Mean :0.2342
## 3rd Qu.: 8.0 3rd Qu.:15.72 3rd Qu.:13.43 3rd Qu.:0.0000
## Max. :24.0 Max. :57.00 Max. :23.40 Max. :1.0000
## Transport
## Min. :0.0000
## 1st Qu.:0.0000
## Median :0.0000
## Mean :0.1374
## 3rd Qu.:0.0000
## Max. :1.0000
transport_employee_aval_final_boost <- dummy.data.frame(transport_employee_aval_final_boost, sep = ".")
summary(transport_employee_aval_final_boost)
## Age Gender.Female Gender.Male Engineer
## Min. :18.00 Min. :0.0000 Min. :0.0000 Min. :0.0000
## 1st Qu.:25.00 1st Qu.:0.0000 1st Qu.:0.0000 1st Qu.:1.0000
## Median :27.00 Median :0.0000 Median :1.0000 Median :1.0000
## Mean :27.75 Mean :0.2883 Mean :0.7117 Mean :0.7545
## 3rd Qu.:30.00 3rd Qu.:1.0000 3rd Qu.:1.0000 3rd Qu.:1.0000
## Max. :43.00 Max. :1.0000 Max. :1.0000 Max. :1.0000
## MBA Work.Exp Salary Distance
## Min. :0.0000 Min. : 0.0 Min. : 6.50 Min. : 3.20
## 1st Qu.:0.0000 1st Qu.: 3.0 1st Qu.: 9.80 1st Qu.: 8.80
## Median :0.0000 Median : 5.0 Median :13.60 Median :11.00
## Mean :0.2523 Mean : 6.3 Mean :16.24 Mean :11.32
## 3rd Qu.:1.0000 3rd Qu.: 8.0 3rd Qu.:15.72 3rd Qu.:13.43
## Max. :1.0000 Max. :24.0 Max. :57.00 Max. :23.40
## license Transport
## Min. :0.0000 Min. :0.0000
## 1st Qu.:0.0000 1st Qu.:0.0000
## Median :0.0000 Median :0.0000
## Mean :0.2342 Mean :0.1374
## 3rd Qu.:0.0000 3rd Qu.:0.0000
## Max. :1.0000 Max. :1.0000
We will take initially all the variables into regression and then will further reliminate through stepAIC
reg_transport <- glm(transport_employee_aval_final_boost$Transport ~.,family=binomial(link='logit'),data=transport_employee_aval_final_boost)
summary(reg_transport)
##
## Call:
## glm(formula = transport_employee_aval_final_boost$Transport ~
## ., family = binomial(link = "logit"), data = transport_employee_aval_final_boost)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.99451 -0.04226 -0.00732 -0.00051 2.27156
##
## Coefficients: (1 not defined because of singularities)
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -72.7701 16.0018 -4.548 5.43e-06 ***
## Age 2.2608 0.5263 4.296 1.74e-05 ***
## Gender.Female 1.7067 0.8336 2.047 0.040632 *
## Gender.Male NA NA NA NA
## Engineer 0.8573 0.9137 0.938 0.348139
## MBA -1.9360 0.9094 -2.129 0.033261 *
## Work.Exp -1.1991 0.3616 -3.316 0.000913 ***
## Salary 0.1853 0.0720 2.573 0.010074 *
## Distance 0.4907 0.1409 3.483 0.000497 ***
## license 2.7089 0.8634 3.137 0.001705 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 355.371 on 443 degrees of freedom
## Residual deviance: 63.263 on 435 degrees of freedom
## AIC: 81.263
##
## Number of Fisher Scoring iterations: 10
We will run stepAIC for finding out optimal ones and then will use the optimised one for final regression model
stepAIC(reg_transport, direction='both', steps = 1000, trace=TRUE)
## Start: AIC=81.26
## transport_employee_aval_final_boost$Transport ~ Age + Gender.Female +
## Gender.Male + Engineer + MBA + Work.Exp + Salary + Distance +
## license
##
##
## Step: AIC=81.26
## transport_employee_aval_final_boost$Transport ~ Age + Gender.Female +
## Engineer + MBA + Work.Exp + Salary + Distance + license
##
## Df Deviance AIC
## - Engineer 1 64.191 80.191
## <none> 63.263 81.263
## - Gender.Female 1 67.824 83.824
## - MBA 1 68.517 84.517
## - Salary 1 70.993 86.993
## - license 1 75.969 91.969
## - Work.Exp 1 78.307 94.307
## - Distance 1 82.049 98.049
## - Age 1 105.784 121.784
##
## Step: AIC=80.19
## transport_employee_aval_final_boost$Transport ~ Age + Gender.Female +
## MBA + Work.Exp + Salary + Distance + license
##
## Df Deviance AIC
## <none> 64.191 80.191
## + Engineer 1 63.263 81.263
## - Gender.Female 1 68.430 82.430
## - MBA 1 68.831 82.831
## - Salary 1 71.735 85.735
## - license 1 76.163 90.163
## - Work.Exp 1 78.953 92.953
## - Distance 1 82.699 96.699
## - Age 1 106.513 120.513
##
## Call: glm(formula = transport_employee_aval_final_boost$Transport ~
## Age + Gender.Female + MBA + Work.Exp + Salary + Distance +
## license, family = binomial(link = "logit"), data = transport_employee_aval_final_boost)
##
## Coefficients:
## (Intercept) Age Gender.Female MBA Work.Exp
## -70.7149 2.2175 1.6249 -1.7524 -1.1768
## Salary Distance license
## 0.1820 0.4853 2.5705
##
## Degrees of Freedom: 443 Total (i.e. Null); 436 Residual
## Null Deviance: 355.4
## Residual Deviance: 64.19 AIC: 80.19
reg_transport_final <- glm(formula = transport_employee_aval_final_boost$Transport ~
Age + Gender.Female + MBA + Work.Exp + Salary + Distance +
license, family = binomial(link = "logit"), data = transport_employee_aval_final_boost)
coefficients(reg_transport_final)
## (Intercept) Age Gender.Female MBA Work.Exp
## -70.7148756 2.2174697 1.6249315 -1.7524099 -1.1768197
## Salary Distance license
## 0.1820395 0.4853110 2.5704541
coefplot.glm(reg_transport_final,parm = -1)
Testing multi colinearity of the model If VIF is more than 10, multicolinearity is strongly suggested and here we see there are two variable Age and Work Exp are having values more than 10
vif(reg_transport_final)
## Age Gender.Female MBA Work.Exp Salary
## 11.474191 1.437833 1.368433 16.645167 3.981423
## Distance license
## 1.718773 1.731569
Result shows that Age, Gender.Female, MBA and license are the key factor for determining transport as Car
#convert training data to matrix format
xInput_transport <- model.matrix(transport_employee_aval_final_boost$Transport~.,transport_employee_aval_final_boost)
yResponse <- transport_employee_aval_final_boost$Transport
#perform grid search to find optimal value of lambda #family= binomial => logistic regression, alpha=1 => lasso
Transport.out <- cv.glmnet(xInput_transport,yResponse, alpha=1, family="binomial", type.measure = "class")
#plot result
plot(Transport.out)
#min value of lambda
lambda_min <- Transport.out$lambda.min
#best value of lambda
lambda_1se <- Transport.out$lambda.1se
lambda_1se
## [1] 0.005286429
#regression coefficients
coef(Transport.out,s=lambda_1se)
## 11 x 1 sparse Matrix of class "dgCMatrix"
## 1
## (Intercept) -25.3306976
## (Intercept) .
## Age 0.6549398
## Gender.Female 0.3537164
## Gender.Male .
## Engineer .
## MBA -0.8498076
## Work.Exp .
## Salary .
## Distance 0.2460050
## license 1.4410941
boxplot(transport_employee_aval_final_boost$Age ~ transport_employee_aval_final_boost$Transport)
boxplot(transport_employee_aval_final_boost$Work.Exp ~ transport_employee_aval_final_boost$Transport)
boxplot(transport_employee_aval_final_boost$Distance ~ transport_employee_aval_final_boost$Transport)
boxplot(transport_employee_aval_final_boost$Salary ~ transport_employee_aval_final_boost$Transport)
ggplot(data=transport_employee_aval_final_boost, aes(x= transport_employee_aval_final_boost$Gender.Female)) +
geom_histogram(col="red",fill="green", bins = 25) +
facet_grid(~ transport_employee_aval_final_boost$Transport)+
theme_bw()