Skip to content

Instantly share code, notes, and snippets.

View wlinInspire's full-sized avatar
🏠
Hustle

Wei Lin wlinInspire

🏠
Hustle
View GitHub Profile
@wlinInspire
wlinInspire / churn_logistic_regression.R
Last active August 19, 2019 04:21
Calculating Life Time Value for Subscription Products
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)
@wlinInspire
wlinInspire / churn_logistic_regression_w_special_cycle.R
Created August 19, 2019 04:31
Calculating Life Time Value for Subscription Products
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)
@wlinInspire
wlinInspire / .Rprofile
Last active August 25, 2019 18:52
Tricks in R to Boost Your Productivity (Part 2)
.First <- function(){
# Set Java Heap Space
options(java.parameters = "-Xmx25g")
# Load common packages
library(ggplot2)
library(tidyverse)
library(data.table)
@wlinInspire
wlinInspire / db_query.R
Last active August 25, 2019 20:29
Tricks in R to Boost Your Productivity (Part 2)
# 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'
import os
import pickle
import caffe
import cv2
import numpy as np
# ======================================================================================================================
# Off load params for each net in a pickle file
# ======================================================================================================================