This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## DR Set up | |
# predict on all 65M rows of DRPrimaryv4.csv | |
# using deployment [BOOKED predcitons] (634728e0ba6623c209179662) | |
# using model [eXtreme Gradient Boosted Trees Classifier with Early Stopping (learning rate =0.01) (Fast Feature Binning) M60 BP52] (63457d2fcc011ba8bee7ec78) | |
# from project Test1004 created by Adam | |
## Post-processing (R & SQL) | |
# load predictions (result-6356a08dabe595d288af9a3e.csv) into SQLite DB | |
sqlite_file <- "AMN.sqlite" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(readr) | |
library(tidyverse) | |
library(glue) | |
library(DataRobotColors) | |
pred <- read.csv("DATA/Predictions/[MDH]_DRPrimaryV3_10pcnt_SF_20221003_eXtreme_Gradient_Boosted_Trees_Classifier_with_Ear_(57)_79.93_IF_-_MDH_Reduced_v2_holdout.csv") | |
pred_rank <- pred %>% | |
group_by(TRAVELERID) %>% | |
arrange(TRAVELERID, desc(Cross.Validation.Prediction)) %>% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# google distance example | |
library(tidyverse) | |
library(googleway) | |
api_key <- "GET A GOOGLE API KEY" | |
## set up a data.frame of locations | |
## can also use 'lat/lon' coordinates as the origin/destination | |
df_locations <- data.frame( | |
origin = c("Melbourne, Australia", "Sydney, Australia","Canberra, Australia") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dat <- data.frame(Response = c("Yes","No"), Value = c(0.32,0.68)) | |
ggplot(dat, aes(x = Response, y = Value)) + | |
geom_bar(stat = "identity", width = 0.5) + | |
xlab("") + | |
ylab("") + | |
theme_bw() + | |
scale_y_continuous(limits = c(0,1)) + | |
geom_text(aes(label = paste0(Value*100,"%")), vjust = -1, | |
hjust = 0.5, face = "bold", size = 6) + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lancCounty <- st_read("C:/Users/matthew.d.harris/Documents/GitHub/Public-Policy-Analytics-Landing/DATA/Chapter2/LancasterCountyBoundary.geojson") %>% | |
st_transform('ESRI:102728') | |
uga <- st_read("C:/Users/matthew.d.harris/Documents/GitHub/Public-Policy-Analytics-Landing/DATA/Chapter2/Urban_Growth_Boundary.geojson") %>% | |
st_transform('ESRI:102728') | |
studyAreaTowns <- st_read("C:/Users/matthew.d.harris/Documents/GitHub/Public-Policy-Analytics-Landing/DATA/Chapter2/StudyAreaTowns.geojson") %>% | |
st_transform('ESRI:102728') | |
buildings <- st_read("C:/Users/matthew.d.harris/Documents/GitHub/Public-Policy-Analytics-Landing/DATA/Chapter2/LancasterCountyBuildings.geojson") %>% st_transform('ESRI:102728') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
library(shinydashboard) | |
# devtools::install_github("nik01010/dashboardthemes") | |
library(dashboardthemes) | |
library(tidyverse) | |
library(sf) | |
library(leaflet) | |
library(usmap) # us counties and states as table | |
library(leaflet) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##### Your code leading up to this point ###### | |
# initialize active cases | |
SWDetail$active_cases <- 0 | |
SWDetail[1,"active_cases"] <- 1 | |
# initialize most recent cases | |
SWDetail$last_case_given <- 0 | |
SWDetail[1,"last_case_given"] <- 1 | |
# resorting this by date | |
cps_test_assignment <- cps_test_assignment[order(cps_test_assignment$assignment_date),] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Package installs ------------------------------------------------------------- | |
load.fun <- function(x) { | |
x <- as.character(x) | |
if(isTRUE(x %in% .packages(all.available=TRUE))) { | |
eval(parse(text=paste("require(", x, ")", sep=""))) | |
print(paste(c(x, " : already installed; requiring"), collapse='')) | |
} else { | |
#update.packages() | |
print(paste(c(x, " : not installed; installing"), collapse='')) | |
eval(parse(text=paste("install.packages('", x, "')", sep=""))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(brms) | |
library(tidyverse) | |
library(caret) | |
rstan_options(auto_write=TRUE) | |
options(mc.cores=parallel::detectCores ()) # Run on multiple cores | |
set.seed(3875) | |
ir <- data.frame (scale (iris[, -5]), Species=iris[, 5]) | |
system.time (b2 <- brm (Species ~ Petal.Length + Petal.Width + Sepal.Length + Sepal.Width, |
NewerOlder