December 17, 2017

Background

Prediction Model Example

The prediction model for the application is below, here the inputs have been simulated for a car weighing 1000 lbs with a 4 cylinder engine thats 90hp with an automatic transmission. The output of the model is also printed as 28.313 MPG

modelMul <- lm(mpg ~ wt + cyl + hp + am, data=mtcars)
mpgP <- predict(modelMul, newdata = 
    data.frame(wt = 1, cyl = 4, hp = 90, am = 0))
print(mpgP)
##        1 
## 28.31383

Data Table Example

Data Table output based on prediction

dataTable <- cbind(names = rownames(mtcars), mtcars)
dataTableSelect <- dataTable[, c("names", "mpg", 
                              "cyl", "hp", "wt", "qsec")] 
modelQ <- lm(qsec ~ wt + cyl + hp + am, data=mtcars)
qsecP <- predict(modelQ, 
newdata = data.frame(wt = 1, cyl = 4, hp = 90, am = 0))
dataTableSelect[dataTableSelect$qsec >=  qsecP,]
##                         names  mpg cyl  hp    wt  qsec
## Hornet 4 Drive Hornet 4 Drive 21.4   6 110 3.215 19.44
## Valiant               Valiant 18.1   6 105 3.460 20.22
## Merc 240D           Merc 240D 24.4   4  62 3.190 20.00
## Merc 230             Merc 230 22.8   4  95 3.150 22.90
## Fiat 128             Fiat 128 32.4   4  66 2.200 19.47
## Toyota Corolla Toyota Corolla 33.9   4  65 1.835 19.90
## Toyota Corona   Toyota Corona 21.5   4  97 2.465 20.01

Conclusion

  • This application revolutionizes the car design and buying process
  • Uses histroical data to help shape future decisions