This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import numpy as np | |
from scipy.io import savemat | |
from collections import defaultdict | |
def get_yields(rootdir, state, year): | |
yields = {} | |
yfile = 'yields-%s-%s.txt' % (state, year) | |
with open(os.path.join(rootdir, yfile), 'r') as f: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Implements the formula to compare models with the Nemenyi test. "The performance | |
of two classifiers is significantly different if the corresponding average ranks | |
differ by at least the critical difference" from: | |
Demsar, J. "Statistical comparisons of classifiers over multiple data sets." | |
The Journal of Machine Learning Research 7 (2006): 1-30. | |
Critical values taken from: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [examples classifications] = dataset_load(dataset_name) | |
% dataset_load(dataset_name) | |
% Returns the example feature vectors (as rows) and corresponding | |
% classifications. Automatically strips the first column (example ids). | |
% Load dataset into a structure array | |
mat_struct = load(dataset_name); | |
% Syntax to get the field of a structure array by name | |
% http://www.mathworks.com/help/matlab/ref/getfield.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
PAD = '.......................................................................................................................................................987654321' | |
if __name__ == '__main__': | |
from sys import argv | |
msg = argv[1] | |
print '%s%s' % (msg, PAD[(len(msg) - len(PAD)):]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import numpy as np | |
import pylab as pl | |
from scipy.spatial.distance import cdist | |
SAMPLES = 1.5e5 | |
SIGMA = 0.2 | |
def main(): | |
X = np.random.laplace(size=SAMPLES) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from cvxopt import matrix as cvxmat, sparse, spmatrix | |
from cvxopt.solvers import qp, options | |
import numpy as np | |
def quadprog(H, f, Aeq, beq, lb, ub): | |
""" | |
minimize: | |
(1/2)*x'*H*x + f'*x | |
subject to: | |
Aeq*x = beq |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.data | |
prime: .string "Prime.\n" | |
p_len = . - prime | |
not_prime: .string "Not Prime.\n" | |
np_len = . - not_prime | |
buffer: .string " " | |
.text | |
.globl main | |
main: | |
call _getinput |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from random import random | |
BE_EVIL = True | |
MAX_DEPTH = 20 | |
PROB_t = 0.05 | |
PROB_p = 0.4 | |
def production(depth): | |
depth += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: iso-8859-15 -*- | |
import string | |
import sys | |
def recurse(levels, path): | |
if levels == 0: | |
left = string.uppercase[path] | |
right = left + "′" |