Skip to content

Instantly share code, notes, and snippets.

View hcho3's full-sized avatar

Philip Hyunsu Cho hcho3

View GitHub Profile
# Check for open appointments in the current month at Las Vegas DMV
# Currently, the script looks for appointments of type "Multiple Services - DL/Vehicle"
import datetime
import time
import boto3
import requests
# List of Nevada DMV locations in the Las Vegas metro area
las_dmv = { # site_id, servicetype_id
@hcho3
hcho3 / fil_vs_hummingbird.py
Last active October 10, 2024 20:41
Comparing performance of FIL vs Hummingbird
import pickle
import time
from argparse import ArgumentParser
import numpy as np
from cuml import ForestInference
from cuml.experimental import ForestInference as ForestInferenceNG
from hummingbird.ml import convert, load
@hcho3
hcho3 / ps1271.cc
Created July 17, 2023 05:31
PS 1271
// Solution for https://www.acmicpc.net/problem/1271
#include <algorithm>
#include <iostream>
#include <string>
#include <stdexcept>
#include <utility>
#include <sstream>
@hcho3
hcho3 / ltr_with_fil.py
Last active June 3, 2023 01:29
Predicting with learning-to-rank using FIL
import numpy as np
import treelite
import xgboost as xgb
from sklearn.datasets import make_classification
from cuml.experimental import ForestInference
X, y = make_classification(
n_samples=100,
n_features=5,
@hcho3
hcho3 / setup-nvidia-docker.sh
Created July 20, 2022 19:34
Set up NVIDIA docker on Amazon Linux 2
#!/bin/bash
sudo yum groupinstall -y "Development tools"
sudo yum install -y kernel-devel-$(uname -r)
aws s3 cp --recursive s3://ec2-linux-nvidia-drivers/latest/ .
chmod +x NVIDIA-Linux-x86_64*.run
sudo CC=/usr/bin/gcc10-cc ./NVIDIA-Linux-x86_64*.run --silent
sudo amazon-linux-extras install docker
sudo systemctl --now enable docker
import numpy as np
import scipy.optimize as opt
import xgboost as xgb
import time
import argparse
import sys
from sksurv.util import Surv
from sksurv.metrics import concordance_index_ipcw
from sklearn.model_selection import KFold
import optuna
@hcho3
hcho3 / cv_early_stopping_xgboost.py
Created May 24, 2020 07:43
Early stopping in XGBoost with cross-validation
import xgboost as xgb
import numpy as np
from sklearn.model_selection import KFold
from sklearn.datasets import load_boston
nfold = 5 # number of cross-validation (CV) folds
nround = 10000 # number of boosting rounds
# Validation metric needs to improve at least once in every early_stopping_rounds rounds to
# continue training.
early_stopping_rounds = 100
@hcho3
hcho3 / benchmark_treelite_protobuf_roundtrip.c
Last active April 22, 2020 21:11
Benchmark script to measure round-trip serialization performance of Treelite using Protobuf
/**
* Benchmark script to measure round-trip serialization performance of Treelite using Protobuf.
* Author: Hyunsu Cho ([email protected])
*/
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
#include <time.h>
@hcho3
hcho3 / test.cc
Last active November 14, 2018 05:24
Borrowing C++ string into Python safely
#include <string>
class Foo {
public:
Foo() : bar("foobar") {}
std::string bar;
};
extern "C" void CreateFoo(void** handle) {
*handle = static_cast<void*>(new Foo());
@hcho3
hcho3 / compile_libhdfs_mac_osx.sh
Created November 9, 2018 05:11
How to compile libHDFS and XGBoost on Mac OS X
#!/bin/bash
# Compile HDFS native library from source
cd
wget http://mirrors.advancedhosters.com/apache/hadoop/common/hadoop-3.1.1/hadoop-3.1.1-src.tar.gz
tar xvf hadoop-3.1.1-src.tar.gz
cd hadoop-3.1.1-src/hadoop-hdfs-project/hadoop-hdfs-native-client
CC=gcc-8 CXX=g++-8 mvn compile -Pnative # Use Homebrew GCC
# Create HDFS home under the home directory