options(knitr.table.format = "html")
options(max.print=100, scipen=999, width = 800)
knitr::opts_chunk$set(echo=FALSE,
                 cache=FALSE,
               prompt=FALSE,
                 eval = TRUE,
               tidy=TRUE,
               root.dir = "..",
               fig.height = 8,
               fig.width = 20,
               comment=NA,
               message=FALSE,
               warning=FALSE)
knitr::opts_knit$set(width=100, figr.prefix = T, figr.link = T)
knitr::knit_hooks$set(inline = function(x) {
  prettyNum(x, big.mark=",")
})
library(BAS)
library(broom)
library(caret)
library(corrplot)
library(data.table)
library(dplyr)
library(extrafont)
library(ggplot2)
library(graphics)
library(gridExtra)
library(reshape2)
library(statsr)
library(vcd)
source("../R/bestPredictions.R")
source("../R/bma.R")
source("../R/bmaAnalysis.R")
source("../R/bmaComplexity.R")
source("../R/bmaEvaluation.R")
source("../R/bmaPerformance.R")
source("../R/bmaPerformanceReport.R")
source("../R/bmaImage.R")
source("../R/bmaModel1.R")
source("../R/bmaModel1Plots.R")
source("../R/bmaPredict.R")
source("../R/bmaPredictModels.R")
source("../R/bmaPDC.R")
source("../R/bmaPIP.R")
source("../R/bmaPIPPlots.R")
source("../R/corrAssociation.R")
source("../R/preprocess.R")
source("../R/univariate.R")
source("../R/univariateQual.R")
source("../R/univariateQuant.R")
source("../R/bivariate.R")
source("../R/bivariateQual.R")
source("../R/bivariateQuant.R")
source("../R/summaryStats.R")
source("../R/visualization.R")
run <- FALSE
if (run == FALSE) {
  load("./analysis/yX.Rdata")
  load("./analysis/preprocessed.Rdata")
  load("./analysis/models.Rdata")
  load("./analysis/analysis.Rdata")
  load("./analysis/report.Rdata")
  load("./analysis/eval.Rdata")
  load("./analysis/performance.Rdata")
}
dir.create("./analysis", showWarnings = FALSE)
load("../inst/extdata/movies.RData")
preprocessed  <- preprocess(movies)
save(preprocessed, file = "./analysis/preprocessed.Rdata")
edaUni <- univariate(data = preprocessed)
edaBi <- bivariate(data = preprocessed)
if (run == TRUE)  {
  yX <- preprocessed %>% select(-title)
  save(yX, file = "./analysis/yX.Rdata")
}
if (isTRUE(run)) {
  models <- bma(yX = yX)
  save(models, file = "./analysis/models.Rdata")
}
analysis <- bmaAnalysis(models = models)
save(analysis, file = "./analysis/analysis.Rdata")
trials <- 400
if (run == TRUE) {
  performance <- bmaPerformance(yX, trials = trials) 
  save(performance, file = "./analysis/performance.Rdata")
}
if (isTRUE(run)) {
  report <- bmaPerformanceReport(performance = performance)
  save(report, file = "./analysis/report.Rdata")
}
eval <- bmaEvaluation(mList = models, candidates = report$best, top = 10)
save(eval, file = "./analysis/eval.Rdata")
cases <- read.csv(file = "../inst/extdata/movies2predict.csv", stringsAsFactors = FALSE)

predictions <- bestPredictions(best = report$best[c(1, 7, 8, 9),], models = models, newdata = cases)
save(predictions, file = "./analysis/predictions.Rdata")
run <- FALSE








References



DataScienceSalon/Bayesian-Regression documentation built on May 29, 2019, 12:06 a.m.