The number of car accidents is increasing constranly, one of the main causes is due to the use of cell phones. The reaction time to external events can be affected by the use of cel phones
We are using the dataset reaction.time from the package Using R (1). The dataset was divided 70 % for training and 30 % for testing purposes, using in both cases random sampling without replacements. We used Shiny, UsingR and caret packages
library(shiny)
library(UsingR)
library(caret)
data(reaction.time)
process<-function(features) {
reaction<-subset(reaction.time,select=c(features,"time"))
set.seed(123)
nsample<-sample(1:nrow(reaction), 18)
train_set<-reaction[-nsample,]
test_set<-reaction[nsample,]
modFit<-train(time~.,method="rpart",data=train_set)
fit<-modFit$finalModel
pred<-predict(modFit,subset(reaction,select=features))
mse<-mean((pred-test_set$time)^2)
return(list(mse=mse, data=head(test_set),model=fit))
}
We are usinging partinioning for classification. Each time the user select or unselect an attribute the algorithm is retrained with the update attributes and calculates MSE (Mean Square error) on the testing data.
mse<-process(c("age","gender","control"))[1]
test<-process(c("age","gender","control"))[2]
model<-process(c("age","gender","control"))[3]
For this presentation we used the three attributes (age,gender and control) in order to determine the MSE (Mean Square Error).
For this presentation we used the three attributes (age,gender and control) in order to determine the MSE (Mean Square Error).
test
$data
age gender control time
18 16-24 M T 1.352
47 25+ F C 1.523
24 25+ M C 1.595
51 25+ M T 1.445
53 25+ M T 1.517
3 16-24 M T 1.512
For this presentation we used the three attributes (age,gender and control) in order to determine the MSE (Mean Square Error).
model
$model
n= 42
node), split, n, deviance, yval
* denotes terminal node
1) root 42 0.29030 1.415
2) controlT< 0.5 15 0.10790 1.364 *
3) controlT>=0.5 27 0.12120 1.444
6) age25+< 0.5 11 0.03181 1.391 *
7) age25+>=0.5 16 0.03802 1.480 *
For this presentation we used the three attributes (age,gender and control) in order to determine the MSE (Mean Square Error).
mse
$mse
[1] 0.0115
A Specific combination of attributes gives more meaningful results than using a single attributeor even using the whole set of features.