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 numpy import * | |
from scipy.stats import beta | |
class BetaBandit(object): | |
def __init__(self, num_options=2, prior=(1.0,1.0)): | |
self.trials = zeros(shape=(num_options,), dtype=int) | |
self.successes = zeros(shape=(num_options,), dtype=int) | |
self.num_options = num_options | |
self.prior = prior |
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 numpy import * | |
from scipy.stats import beta | |
import random | |
class BetaBandit(object): | |
def __init__(self, num_options=2, prior=None): | |
self.trials = zeros(shape=(num_options,), dtype=int) | |
self.successes = zeros(shape=(num_options,), dtype=int) | |
self.num_options = num_options |
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
# -*- coding: utf-8 -*- | |
""" | |
example use of pandas with oracle mysql postgresql sqlite | |
- updated 9/18/2012 with better column name handling; couple of bug fixes. | |
- used ~20 times for various ETL jobs. Mostly MySQL, but some Oracle. | |
to do: | |
save/restore index (how to check table existence? just do select count(*)?), | |
finish odbc, | |
add booleans?, |
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 | |
# calling : python snap_to_comp_coloring.py <snap_components> <snap_singletons> <comp_coloring> | |
# in: [size] [node ID] [node ID] [...] and [singleton ID] | |
# out: [node ID] [comp ID] | |
# [node ID] [comp ID] | |
# ... | |
# [singleton ID] [comp ID] | |
# IMPORT MODULES |
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
%% Read Netflix dataset | |
A = readSMAT('/scratch/dgleich/netflix/netflix.smat'); | |
k = [10 25 50 100 150 200]; | |
l = size(k,2); | |
%% Matlab's SVDS | |
for i= 1:l | |
tic; | |
[U,S,V] = svds(A,k(i)); |
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 numpy import * | |
from scipy.stats import beta | |
import random | |
class BetaBandit(object): | |
def __init__(self, num_options=2, prior=None): | |
self.trials = zeros(shape=(num_options,), dtype=int) | |
self.successes = zeros(shape=(num_options,), dtype=int) | |
self.num_options = num_options |
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
import theano | |
from pylearn2.models import mlp | |
from pylearn2.train_extensions import best_params | |
from pylearn2.training_algorithms import sgd, learning_rule | |
from pylearn2.utils import serial | |
from pylearn2.termination_criteria import MonitorBased | |
from pylearn2.datasets.dense_design_matrix import DenseDesignMatrix | |
from sklearn.preprocessing import StandardScaler | |
import numpy as np | |
from random import randint |
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
### MATPLOTLIBRC FORMAT | |
# This is a sample matplotlib configuration file - you can find a copy | |
# of it on your system in | |
# site-packages/matplotlib/mpl-data/matplotlibrc. If you edit it | |
# there, please note that it will be overridden in your next install. | |
# If you want to keep a permanent local copy that will not be | |
# over-written, place it in HOME/.matplotlib/matplotlibrc (unix/linux | |
# like systems) and C:\Documents and Settings\yourname\.matplotlib | |
# (win32 systems). |
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
import numpy as np | |
from sklearn.feature_extraction import image | |
from sklearn.cluster import MiniBatchKMeans | |
from sklearn import cross_validation, svm, datasets | |
from sklearn.datasets import fetch_olivetti_faces, fetch_mldata | |
from matplotlib import pylab as pl | |
def HIK_kernel(X,Y): | |
return np.array([[np.sum(np.minimum(x,y)) for y in Y] for x in X]) | |
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 scipy.stats import rv_continuous | |
from scipy.special import gammaln, gammaincinv, gammainc | |
from numpy import log,exp | |
class igamma_gen(rv_continuous): | |
def _pdf(self, x, a, b): | |
return exp(self._logpdf(x,a,b)) | |
def _logpdf(self, x, a, b): | |
return a*log(b) - gammaln(a) -(a+1)*log(x) - b/x | |
def _cdf(self, x, a, b): |