Skip to content

Instantly share code, notes, and snippets.

View abmathewks's full-sized avatar

Abraham Mathew abmathewks

View GitHub Profile
############################################################################
### FUNCTION TO EXTRACT DATA FROM SQL
get_sql_data <- function(driver = "SQL Server",
server = "sdl02-vm161",
db_name = "OpsDW",
query_text = which_query){
-- VM 25
----------------------------------------------------------
----------------------------------------------------------
DROP TABLE #AllCHA
### text_extraction.py
#################################################################################
#################################################################################
### PRELIMINARIES
import os
os.chdir("/Users/abrahammathew/Desktop/LZ_demo_poc/test_data")
import re
### EXECUTE ANALYSIS WITH AVERAGES AND IDEALIZED SLOTS
### PREDICT FOR 2020
#################################################################################################
### SET PARAMETERS
data_path = "K:/Data Excellence/4 - Reducing Direct Clinical Costs/ATM/NP_Supply/NP_Supply_Estimation_V3/data/NP_Supply_Data_With_2020.csv"
use_these_packages <- c("dplyr", "ggplot2", "data.table", "lubridate", "stringr", "boot")
#' GET_NETWORK_SUMMARY
#'
#' @param DATA_DT The name of the data table
#' @param USE_THESE_FEATURES a vector of all variable names
#' @param DO_SAMPLE Logical value for if the data should be sampled
#' @param DO_SAMPLE_FRAC If Do Sample is set to true, what percentage
AddMissingDates <- function(
AGG_TS_DATA = FINAL_DATA[data_type == "TRAIN"],
DATE_COLUMN = "date_ymd",
TARGET_COLUMN = "visits",
OTHER_COLUMNS = c("revenue_segment", "line", "serviceline_segment",
"finance_group", "finance_sub_group"),
DEBUG = TRUE){
if(DEBUG) message("AddMissingDates: Function Initialized \n")
RunAllModels <- function(USE_THESE_FORMULAS = all_formulas,
MODEL_DATA = model_data,
DATA_DIMENSION = dim_name,
DATE_COLUMN = "date_ymd",
TARGET_COLUMN = "visits",
DEBUG = TRUE){
if(DEBUG) message("RunAllModels: Function Initialized \n")
import datetime
import calendar
def AddMonths(DATE_VAL,
ADD_N,
DATE_FORMAT = "%Y-%m-%d"):
print("AddMonths: Function initalized")
AddMonths <- function(DATE_VAL,
ADD_N = NULL,
DEBUG = TRUE){
if(DEBUG) message("AddMonths: Function initialized \n")
if(!lubridate::is.Date(DATE_VAL)){
stop("AddMonths: DATE_VAL is not a date format \n")
}
CreateProjectFiles <- function(PROJECT_PATH = rstudioapi::getActiveProject(),
FOLDERS_TO_CREATE = c("data", "docs", "figs", "logs",
"output", "queries", "R", "tests"),
OPEN_NEW_SESSION = TRUE,
DEBUG = TRUE){
if(DEBUG) message("CreateProjectFiles: Function initialized \n")
if(!dir.exists(PROJECT_PATH)){