Skip to content

Instantly share code, notes, and snippets.

@doobwa
doobwa / submission1.py
Created March 17, 2015 20:19
Starter code for Otto Group Product Classification
import graphlab as gl
# Load the data
train = gl.SFrame.read_csv('data/train.csv')
test = gl.SFrame.read_csv('data/test.csv')
sample = gl.SFrame.read_csv('data/sampleSubmission.csv')
del train['id']
# Train a model
@doobwa
doobwa / strace_julia_segfault
Created September 29, 2013 14:57
strace output for Julia segfault
execve("/home/chris/julia/usr/bin/julia-debug-readline", ["/home/chris/julia/usr/bin/julia-"..., "-bf", "sysimg.jl"], [/* 24 vars */]) = 0
brk(0) = 0x1e1a000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f38696c6000
readlink("/proc/self/exe", "/home/chris/julia/usr/bin/julia-debug-readline", 4096) = 46
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/home/chris/julia/usr/bin/../lib/julia/tls/x86_64/libtinfo.so.5", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/home/chris/julia/usr/bin/../lib/julia/tls/x86_64", 0x7fffcd562cd0) = -1 ENOENT (No such file or directory)
open("/home/chris/julia/usr/bin/../lib/julia/tls/libtinfo.so.5", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/home/chris/julia/usr/bin/../lib/julia/tls", 0x7fffcd562cd0) = -1 ENOENT (No such file or directory)
@doobwa
doobwa / proc_info_ubuntu
Created September 29, 2013 14:36
Personal processor information.
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 60
model name : Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
stepping : 3
microcode : 0x9
cpu MHz : 800.000
cache size : 8192 KB
physical id : 0
@doobwa
doobwa / gdb_backtrace_julia_segfault_139
Created September 29, 2013 14:32
GDB Backtrace for segfault during bootstrap (sysimg.jl) on Ubuntu
NU gdb (GDB) 7.5.91.20130417-cvs-ubuntu
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
[Thread debugging using libthread_db enabled]
@doobwa
doobwa / mbandit.r
Created April 7, 2013 07:05
Quick example of multi-armed bandits.
# Multi-armed bandit example
# Each arm has some (unknown) probability of reward=1.
# Using beta priors we can update our posterior after each pull
# The following uses Thompson sampling, where we sample probabilities
# from our posterior and choose the arm with the largest expected reward.
set.seed(2)
J <- 3
probs <- rbeta(J,1,1) # True probability
@doobwa
doobwa / dlm2dict.jl
Created September 25, 2012 01:01
An attempt at faster Julia IO
# Chris DuBois
# September 2012
# Inspired by: http://vijayinterviewquestions.blogspot.com/2007/07/write-your-own-c-program-to-implement.html
function atoi(s)
i = 0
L = strlen(s)
# skip preceding whitespaece
a = 1
@doobwa
doobwa / matmult.jl
Created June 26, 2012 04:45
Sparse matrix multiplication in julia
# "Fast matrix multiply" written in Julia
#
# Method below implements the algorithm described in [Gustavson, 1978]:
# http://www.cse.iitb.ac.in/graphics/~anand/website/include/papers/matrix/fast_matrix_mul.pdf
#
# Copyright (C) 2012 Christopher DuBois
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
@doobwa
doobwa / listn()
Created May 27, 2012 04:56
Create named lists quickly in R
##' Quickly create a named list using one or more variables
##'
##' Example:
##' > a <- 1; b <- 2
##' > listn(a,b)
##' $a
##' [1] 1
##' $b
##' [1] 2
listn <- function(...) {
@doobwa
doobwa / example.openmp.r
Created February 1, 2012 05:35
OpenMP Rcpp example
#!/usr/bin/r
library(inline)
library(rbenchmark)
## openMPCode example from Rcpp/examples/OpenMP/ by Dirk E.
openMPCode <- '
// assign to C++ vector
std::vector<double> x = Rcpp::as<std::vector< double > >(xs);
@doobwa
doobwa / example.openmp.r
Created February 1, 2012 05:35
OpenMP Rcpp example
#!/usr/bin/r
library(inline)
library(rbenchmark)
## lastly via OpenMP for parallel use
openMPCode <- '
// assign to C++ vector
std::vector<double> x = Rcpp::as<std::vector< double > >(xs);