This file contains hidden or 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
import os | |
import pickle | |
import caffe | |
import cv2 | |
import numpy as np | |
# ====================================================================================================================== | |
# Off load params for each net in a pickle file | |
# ====================================================================================================================== |
This file contains hidden or 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
# Connect DB function | |
connect_db <- function() { | |
pgsql <- RJDBC::JDBC("com.amazon.redshift.jdbc42.Driver", | |
"./jdbc_driver/RedshiftJDBC42-1.2.16.1027.jar", | |
"`") | |
host <- "redshift-cluster-1.abc1234.us-east-2.redshift.amazonaws.com" | |
port <- '5439' | |
user <- 'abc1234' |
This file contains hidden or 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
.First <- function(){ | |
# Set Java Heap Space | |
options(java.parameters = "-Xmx25g") | |
# Load common packages | |
library(ggplot2) | |
library(tidyverse) | |
library(data.table) |
This file contains hidden or 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(survival) | |
library(data.table) | |
library(ggplot2) | |
data = read.csv('https://raw.githubusercontent.com/IBM/invoke-wml-using-cognos-custom-control/master/data/Telco-Customer-Churn.csv') | |
setDT(data) | |
churn_data <- data[, churn_flag := ifelse(Churn == 'Yes', 1, 0)] | |
km_curve <- survfit(Surv(tenure, churn_flag) ~ 1, data=churn_data) |
This file contains hidden or 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(survival) | |
library(data.table) | |
library(ggplot2) | |
data = read.csv('https://raw.githubusercontent.com/IBM/invoke-wml-using-cognos-custom-control/master/data/Telco-Customer-Churn.csv') | |
setDT(data) | |
churn_data <- data[, churn_flag := ifelse(Churn == 'Yes', 1, 0)] | |
km_curve <- survfit(Surv(tenure, churn_flag) ~ 1, data=churn_data) |
This file contains hidden or 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(survival) | |
library(data.table) | |
library(ggplot2) | |
data = fread('https://raw.githubusercontent.com/IBM/invoke-wml-using-cognos-custom-control/master/data/Telco-Customer-Churn.csv') | |
churn_data <- data[, .(churn_flag = ifelse(Churn == 'Yes', 1, 0), tenure)] | |
km_curve <- survfit(Surv(tenure, churn_flag) ~ 1, data=churn_data) | |
# Calculate Survival and Churn Rate |
This file contains hidden or 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(survival) | |
library(data.table) | |
library(ggplot2) | |
data <- fread('https://raw.githubusercontent.com/IBM/invoke-wml-using-cognos-custom-control/master/data/Telco-Customer-Churn.csv') | |
churn_data <- data[, .(churn_flag = ifelse(Churn == 'Yes', 1, 0), tenure)] | |
km_curve <- survfit(Surv(tenure, churn_flag) ~ 1, data=churn_data) | |
# Calculate Survival and Churn Rate |
This file contains hidden or 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
h2o_start <- function() { | |
h2o::h2o.init(nthreads = -1, enable_assertions = FALSE, min_mem_size = '8g', | |
strict_version_check = FALSE, port = 54321) | |
} | |
h2o_stop <- function() { | |
h2o::h2o.shutdown(prompt = FALSE) | |
} |
This file contains hidden or 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
cc <- function(df) { | |
print(df %>% is.na() %>% colSums()) | |
} | |
cd <- function(df) { | |
print(df %>% is.na() %>% colMeans()) | |
} |
This file contains hidden or 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
quick_date <- function(x, …) { | |
if (anyDuplicated(x)) { | |
ux <- unique(x) | |
idx <- match(x, ux) | |
y <- as.Date.character(ux, …) | |
return(y[idx]) | |
} | |
as.Date.character(x, …) | |
} |
NewerOlder