Here we present a summary of the output results after running the greedy algorithm code as well as bruteforce for the UCI dataset.
##When N=5
linearBFfive<-read.csv("/Users/uzma/Downloads/Bruteforceoutput5items.csv",header=TRUE)
linearGreedyfive<-read.csv("/Users/uzma/Downloads/Greedyoutput5items.csv",header=TRUE)
summary(linearBFfive)
## X Replication.number Customer.ID alpha
## Min. : 1.0 Min. :1 Min. :12347 Min. :0.01
## 1st Qu.: 304.5 1st Qu.:2 1st Qu.:12358 1st Qu.:0.01
## Median : 608.0 Median :3 Median :12367 Median :0.10
## Mean : 608.0 Mean :3 Mean :12367 Mean :0.37
## 3rd Qu.: 911.5 3rd Qu.:4 3rd Qu.:12377 3rd Qu.:1.00
## Max. :1215.0 Max. :5 Max. :12384 Max. :1.00
## z System.Time NA. NA..1
## Min. : 0 Min. :0.002493 Min. : 0 Min. : 0
## 1st Qu.: 0 1st Qu.:0.003002 1st Qu.: 0 1st Qu.: 0
## Median : 5 Median :0.003491 Median : 0 Median : 0
## Mean : 5 Mean :0.004193 Mean : 4244 Mean : 4418
## 3rd Qu.:10 3rd Qu.:0.004002 3rd Qu.: 0 3rd Qu.: 0
## Max. :10 Max. :0.661523 Max. :21218 Max. :22090
## NA..2 NA..3 NA..4
## Min. : 0.0 Min. : 0 0 :730
## 1st Qu.: 0.0 1st Qu.: 0 23316 :242
## Median : 0.0 Median : 0 47590A:243
## Mean : 764.4 Mean : 4654
## 3rd Qu.: 0.0 3rd Qu.: 0
## Max. :22113.0 Max. :23174
head(linearBFfive)
## X Replication.number Customer.ID alpha z System.Time NA. NA..1 NA..2
## 1 1 1 12347 0.01 0 0.003508091 0 0 0
## 2 2 1 12347 0.10 0 0.003001928 0 0 0
## 3 3 1 12347 1.00 0 0.003501892 0 0 0
## 4 4 1 12347 0.01 5 0.003503084 0 0 0
## 5 5 1 12347 0.10 5 0.003503084 0 0 0
## 6 6 1 12347 1.00 5 0.003003120 0 0 0
## NA..3 NA..4
## 1 0 47590A
## 2 0 47590A
## 3 0 47590A
## 4 0 47590A
## 5 0 47590A
## 6 0 47590A
tail(linearBFfive)
## X Replication.number Customer.ID alpha z System.Time NA. NA..1
## 1210 1210 5 12384 0.01 5 0.004003048 21218 0
## 1211 1211 5 12384 0.10 5 0.003002167 21218 0
## 1212 1212 5 12384 1.00 5 0.003002167 21218 0
## 1213 1213 5 12384 0.01 10 0.003991127 21218 0
## 1214 1214 5 12384 0.10 10 0.003001928 21218 0
## 1215 1215 5 12384 1.00 10 0.004002094 21218 0
## NA..2 NA..3 NA..4
## 1210 22113 0 0
## 1211 22113 0 0
## 1212 0 0 0
## 1213 22113 0 0
## 1214 0 0 0
## 1215 0 0 0
summary(linearGreedyfive)
## X Replication.number Customer.ID alpha
## Min. : 1.0 Min. :1 Min. :12347 Min. :0.01
## 1st Qu.: 304.5 1st Qu.:2 1st Qu.:12358 1st Qu.:0.01
## Median : 608.0 Median :3 Median :12367 Median :0.10
## Mean : 608.0 Mean :3 Mean :12367 Mean :0.37
## 3rd Qu.: 911.5 3rd Qu.:4 3rd Qu.:12377 3rd Qu.:1.00
## Max. :1215.0 Max. :5 Max. :12384 Max. :1.00
## z System.Time NA. NA..1
## Min. : 0 Min. :0.0000000 21218 :243 Min. : 0.0
## 1st Qu.: 0 1st Qu.:0.0000000 22090 :243 1st Qu.: 0.0
## Median : 5 Median :0.0005009 22939 : 1 Median : 0.0
## Mean : 5 Mean :0.0005721 23174 :243 Mean : 764.4
## 3rd Qu.:10 3rd Qu.:0.0010002 23316 :242 3rd Qu.: 0.0
## Max. :10 Max. :0.0110190 47590A:243 Max. :22113.0
## NA..2 NA..3 NA..4
## Min. :0 Min. :0 Min. :0
## 1st Qu.:0 1st Qu.:0 1st Qu.:0
## Median :0 Median :0 Median :0
## Mean :0 Mean :0 Mean :0
## 3rd Qu.:0 3rd Qu.:0 3rd Qu.:0
## Max. :0 Max. :0 Max. :0
head(linearGreedyfive)
## X Replication.number Customer.ID alpha z System.Time NA. NA..1 NA..2
## 1 1 1 12347 0.01 0 0.0000000000 47590A 0 0
## 2 2 1 12347 0.10 0 0.0004999638 47590A 0 0
## 3 3 1 12347 1.00 0 0.0005002022 47590A 0 0
## 4 4 1 12347 0.01 5 0.0005009174 47590A 0 0
## 5 5 1 12347 0.10 5 0.0005009174 47590A 0 0
## 6 6 1 12347 1.00 5 0.0004999638 47590A 0 0
## NA..3 NA..4
## 1 0 0
## 2 0 0
## 3 0 0
## 4 0 0
## 5 0 0
## 6 0 0
tail(linearGreedyfive)
## X Replication.number Customer.ID alpha z System.Time NA. NA..1
## 1210 1210 5 12384 0.01 5 0.001000881 21218 22113
## 1211 1211 5 12384 0.10 5 0.000000000 21218 22113
## 1212 1212 5 12384 1.00 5 0.000000000 21218 0
## 1213 1213 5 12384 0.01 10 0.001013041 21218 22113
## 1214 1214 5 12384 0.10 10 0.001001120 21218 0
## 1215 1215 5 12384 1.00 10 0.001000881 21218 0
## NA..2 NA..3 NA..4
## 1210 0 0 0
## 1211 0 0 0
## 1212 0 0 0
## 1213 0 0 0
## 1214 0 0 0
## 1215 0 0 0
## When N=10
linearBFten<-read.csv("/Users/uzma/Downloads/Bruteforceoutput10items.csv",header=TRUE)
linearGreedyten<-read.csv("/Users/uzma/Downloads/Greedyoutput10items.csv",header=TRUE)
## When N=12
linearBFtwelve<-read.csv("/Users/uzma/Downloads/Bruteforceoutput12items.csv",header=TRUE)
linearGreedytwelve<-read.csv("/Users/uzma/Downloads/Greedyoutput12items.csv",header=TRUE)
## When N=14
linearBFfourteen<-read.csv("/Users/uzma/Downloads/Bruteforceoutput14items.csv",header=TRUE)
linearGreedyfourteen<-read.csv("/Users/uzma/Downloads/Greedyoutput14items.csv",header=TRUE)
## When N=16
linearBFsixteen<-read.csv("/Users/uzma/Downloads/Bruteforceoutput16items.csv",header=TRUE)
linearGreedysixteen<-read.csv("/Users/uzma/Downloads/Greedyoutput16items.csv",header=TRUE)
## When N=18
linearBFeighteen<-read.csv("/Users/uzma/Downloads/Bruteforceoutput18items.csv",header=TRUE)
linearGreedyeighteen<-read.csv("/Users/uzma/Downloads/Greedyoutput18items.csv",header=TRUE)
v1<-which(linearBFfive != linearGreedyfive, arr.ind=TRUE)
v2<-which(linearBFten != linearGreedyten, arr.ind=TRUE)
v3<-which(linearBFtwelve != linearGreedytwelve, arr.ind=TRUE)
v4<-which(linearBFfourteen != linearGreedyfourteen, arr.ind=TRUE)
#v5<-which(linearBFsixteen != linearGreedysixteen, arr.ind=TRUE)
v6<-which(linearBFeighteen != linearGreedyeighteen, arr.ind=TRUE)
The above output indicates that only the system time differs for both algorithms which is presented below:
##When N=5
x<-linearBFfive$X
y1<-linearGreedyfive$System.Time
y2<-linearBFfive$System.Time
test.data10<-cbind(x,y1,y2)
boxplot(y1,y2)
##Difference in the mean of the two boxplots above
diffmean5<-mean(y2)-mean(y1)
## The difference is positive Brute Force- Greedy
diffmean5
## [1] 0.0036212
##When N=10
x1<-linearBFten$X
y3<-linearGreedyten$System.Time
y4<-linearBFten$System.Time
test.data11<-cbind(x1,y3,y4)
boxplot(y3,y4)
##Difference in the mean of the two boxplots above
diffmean10<-mean(y4)-mean(y3)
## The difference is positive Brute Force- Greedy
diffmean10
## [1] 0.2117733
## When N=12
x2<-linearBFtwelve$X
y5<-linearGreedytwelve$System.Time
y6<-linearBFtwelve$System.Time
test.data12<-cbind(x2,y5,y6)
boxplot(y5,y6)
##Difference in the mean of the two boxplots above
diffmean12<-mean(y6)-mean(y5)
## The difference is positive Brute Force- Greedy
diffmean12
## [1] 1.328324
## When N=14
x3<-linearBFfourteen$X
y7<-linearGreedyfourteen$System.Time
y8<-linearBFfourteen$System.Time
test.data13<-cbind(x3,y7,y8)
boxplot(y7,y8)
##Difference in the mean of the two boxplots above
diffmean14<-mean(y8)-mean(y7)
## The difference is positive Brute Force- Greedy
diffmean14
## [1] 13.13718
## When N=16
x4<-linearBFsixteen$X
y9<-linearGreedysixteen$System.Time
y10<-linearBFsixteen$System.Time
test.data14<-cbind(x4,y9,y10)
## Warning in cbind(x4, y9, y10): number of rows of result is not a multiple
## of vector length (arg 1)
boxplot(y9,y10)
##Difference in the mean of the two boxplots above
diffmean16<-mean(y10)-mean(y9)
## The difference is positive Brute Force- Greedy
diffmean16
## [1] 16.54385
## When N=18
x5<-linearBFeighteen$X
y11<-linearGreedyeighteen$System.Time
y12<-linearBFeighteen$System.Time
test.data15<-cbind(x5,y11,y12)
boxplot(y11,y12)
##Difference in the mean of the two boxplots above
diffmean18<-mean(y12)-mean(y11)
## The difference is positive Brute Force- Greedy
diffmean18
## [1] 20
## Final line plot
dfplot<-c(diffmean5,diffmean10,diffmean12,diffmean14,diffmean16,diffmean18)
plot(dfplot,type='l',xaxt = "n",xlab="Assortment Size Offered to Users", ylab="Time Difference in seconds", main="Time Difference: Brute Force - Greedy Algorithm")
axis(1,at=1:6,labels=c(5,10,12,14,16,18))