Skip to content

Instantly share code, notes, and snippets.

Jan Tilly jtilly

Block or report user

Report or block jtilly

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jtilly
jtilly / install-gcc-4.9.3.sh
Last active Aug 16, 2019
Install GCC 4.9.3
View install-gcc-4.9.3.sh
#!/bin/bash
# this script installs GCC 4.9.3
# to use it navigate to your home directory and type:
# sh install-gcc-4.9.3.sh
# download and install gcc 4.9.3
wget https://ftp.gnu.org/gnu/gcc/gcc-4.9.3/gcc-4.9.3.tar.gz
tar xzf gcc-4.9.3.tar.gz
cd gcc-4.9.3
@jtilly
jtilly / install.sh
Last active Feb 19, 2019
Install qcachegrind on Ubuntu
View install.sh
#!/bin/bash
sudo apt-get install qt5-default
wget http://kcachegrind.sourceforge.net/kcachegrind-0.7.4.tar.gz
tar xvf kcachegrind-0.7.4.tar.gz
cd kcachegrind-0.7.4
qmake && make
sudo install -m 755 qcachegrind/qcachegrind /usr/local/bin
sudo install -m 644 qcachegrind/qcachegrind.desktop \
/usr/local/share/applications/
@jtilly
jtilly / xgb-missings.md
Last active Oct 11, 2018
Treatment of missing values with and without sparse matrices
View xgb-missings.md
library(xgboost)
library(dplyr)

params = list(min_child_weight = 0.00001, lambda = 0 )
nrounds = 1

# sparse ---
@jtilly
jtilly / timer.h
Created Nov 29, 2016
Simple C++ Profiler Class
View timer.h
// timer.h
#include <iostream>
#include <sstream>
#ifndef timer_h
#define timer_h
class timer {
private:
@jtilly
jtilly / check-lgb-multiclass.R
Last active May 12, 2018
dim(preds) vs. dim(predict(...)): what the hell is LightGBM doing?
View check-lgb-multiclass.R
library(lightgbm)
library(tidyverse)
rm(list = ls())
# We load the default iris dataset shipped with R
data(iris)
iris = as_data_frame(iris) %>%
mutate(Species = as.numeric(factor(Species)) - 1) %>%
@jtilly
jtilly / install_dep.R
Last active Feb 3, 2018
Install Package Dependencies in R
View install_dep.R
#' Install Dependent Packages
#'
#' @param pkg.dir refers to the package directory that contains the
#' \code{Description} file
#' @param dependencies defines which dependencies of the dependent packages are
#' to be installed
#' @param repos is the (CRAN) repository used to install dependencies
#' @param lib is the library to which packages are installed
install_dep = function(pkg.dir = ".", dependencies = TRUE, repos = getOption("repos")[1], lib = .libPaths()[1]) {
View test_xgboost_missings.R
library(xgboost)
set.seed(1234)
N = 1000
x1 <- runif(N)
x <- ifelse(x1 <= 0.2, as.numeric(NA), x1)
y <- as.numeric(x1 >= 0.9)
bst <- xgboost(data = matrix(x, ncol=1), label = y,
objective = "binary:logistic", eval_metric = "logloss",
View textmessage.R
rm(list = ls())
dict.orig = unique(readLines("https://raw.githubusercontent.com/first20hours/google-10000-english/master/google-10000-english.txt"))
txt2numeric = function(word.orig, return.orig = TRUE) {
word = tolower(word.orig)
word = gsub("([^a-z]){1}", 1, word)
word = gsub("(a|b|c){1}", 2, word)
word = gsub("(d|e|f){1}", 3, word)
word = gsub("(g|h|i){1}", 4, word)
@jtilly
jtilly / print_mat.h
Created Nov 29, 2016
Simple helper function to print armadillo matrices
View print_mat.h
#ifndef print_mat_h
#define print_mat_h
void print_mat(arma::mat my_matrix) {
uint cols = my_matrix.n_cols;
uint rows = my_matrix.n_rows;
Rcout << "--------\n";
for(uint rX = 0; rX < rows; rX++) {
@jtilly
jtilly / robust_mixture.R
Created Nov 28, 2016
Use log/exp transformation to make the log likelihood computation of a simple mixture model more robust.
View robust_mixture.R
# making mixture models numerically robust
set.seed(4)
rm(list = ls())
nobs = 1000
alpha = 0.1
p = runif(nobs, min = 0.0, max = 1.0)
q = runif(nobs, min = 0.0, max = 1.0)
# naive computation of log-likelihood contribution
You can’t perform that action at this time.