Skip to content

Instantly share code, notes, and snippets.

View jeongyoonlee's full-sized avatar
🏖️
Working from sunny Santa Monica

Jeong-Yoon Lee jeongyoonlee

🏖️
Working from sunny Santa Monica
View GitHub Profile
@jeongyoonlee
jeongyoonlee / Basic_CausalML.ipynb
Created May 2, 2020 06:42
causalml_baserlearner_issue/Basic_CausalML.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jeongyoonlee
jeongyoonlee / causal_tree_with_synthetic_data.ipynb
Last active December 14, 2019 00:13
CausalTreeRegressor with Synthetic Data after Impurity Fix
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jeongyoonlee
jeongyoonlee / causal_tree_with_synthetic_data.ipynb
Created December 13, 2019 22:50
A notebook to test CausalTreeRegressor with synthetic data
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jeongyoonlee
jeongyoonlee / write.libsvm.R
Created November 21, 2015 07:38
Save a sparse matrix as a libsvm format file
# written by 'y' @ kaggle - https://www.kaggle.com/tyi2000
write.libsvm <- function(data, target, filename="out.dat") {
out <- file(filename)
writeLines(paste(target, apply(data, 1, function( X ) paste(apply(cbind(which(X!=0), X[which(X!=0)]), 1, paste, collapse=":"), collapse=" "))), out)
close( out )
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jeongyoonlee
jeongyoonlee / prep_log.py
Created August 15, 2014 19:40
resampling and timezone conversion using Pandas
import pandas as pd
def prep_log(sec_file, min_file, src_tz='US/Pacific', dst_tz='US/Eastern', datetime_fmt='%m/%d/%y %H:%M'):
"""Preprocess a second level log file by aggregating it in a minute level and converting timezone if necessary.
Args:
sec_file: a second level CSV log file with timestamps in the first column
min_file: a minute level CSV output log file with timestamps in the first column
src_tz: a source timezone (default: EST)
@jeongyoonlee
jeongyoonlee / re_example.py
Created June 13, 2014 20:05
Python Regular Expression Example
'''
\s [ \n\t\f\r]
\S [^ \n\t\f\r]
\w [A-Za-z0-9_]
\d [0-9]
\D [^0-9]
\W [^A-Za-z0-9_]
\b word boundary
^ beginning of string
#!/usr/bin/env python
import argparse
import numpy as np
import pandas as pd
import scipy.sparse as sparse
from sklearn import cross_validation, metrics
from sklearn.datasets import dump_svmlight_file
from sklearn.linear_model import LogisticRegression
from sklearn.preprocessing import StandardScaler