Skip to content

Instantly share code, notes, and snippets.

View jphall663's full-sized avatar

ph_ jphall663

View GitHub Profile
% Copyright Patrick Hall XXXX
\documentclass[fleqn]{article}
\renewcommand\refname{}
\title{XXXX}
\author{\copyright Patrick Hall XXXX}
\usepackage{graphicx}
\usepackage{fullpage}
\usepackage{pdfpages}
@jphall663
jphall663 / h2o_glm_grid.py
Last active August 9, 2018 16:25
Grid search for H2O penalized GLM
def glm_grid(X, y, train, valid, family):
""" Wrapper function for penalized GLM with alpha and lambda search.
:param X: List of inputs.
:param y: Name of target variable.
:param train: Name of training H2OFrame.
:param valid: Name of validation H2OFrame.
:param: family: 'gaussian' for linear regression; 'binomial' for logistic.
:return: Best H2Omodel from H2OGeneralizedLinearEstimator
@jphall663
jphall663 / xgb_grid.py
Created August 6, 2018 14:19
Manual XGBoost grid search (Python)
iter_ = 0
best_error = 0
best_iter = 0
best_model = None
col_sample_rates = [0.1, 0.5, 0.9]
subsamples = [0.1, 0.5, 0.9]
etas = [0.01, 0.001]
max_depths = [3, 6, 12, 15, 18]
reg_alphas = [0.01, 0.001]
@jphall663
jphall663 / h2o_gbm_1.R
Last active March 20, 2017 15:50
h2o r gbm sample 1
# load h2o library
library(h2o)
### set global constants ######################################################
ip = 'localhost' # host to connect connect to h2o server
port = 54321 # port to connect connect to h2o server
nthreads = - 1 # number of threads to use, -1 indicates max. threads
max_mem_size = '12G' # defines amount of available memory, per node
dat = NULL # input data location
col.types = NULL # vector containing the column types, ['numeric', 'enum', ...]
@jphall663
jphall663 / replace.py
Last active January 17, 2017 18:49
python re string replace
import re
replace_char = '_'
source = 'he"l*&l# o@@'
target = re.sub(r'[-\/\\;,\s\.\/<>&\!:\"\)\(\*\+\?\|=#@]', replace_char, source)
target = re.sub(r"\'", replace_char, target)
print(target)
@jphall663
jphall663 / rm_cached.sh
Created July 31, 2015 20:55
git ignore not working?
git rm -r --cached .
@jphall663
jphall663 / escape.sas
Last active November 2, 2019 00:08
sas macro recursion escape
*'; *"; *); */; %mend; run;
@jphall663
jphall663 / discrim_v_pmbr.sas
Last active August 29, 2015 14:22
PROC DISCRIM vs. the MBR node in Enterprise Miner
*** clear any previous results;
ods html close;
ods html;
*** display resolution of macro variables in log;
option symbolgen;
*** request detailed performance info;
options fullstimer;