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
<span class="rating"> | |
<input id="star-5" name="radioradio" type="radio" value="5"><label for="star-5"></label> | |
<input id="star-4" name="radioradio" type="radio" value="4"><label for="star-4"></label> | |
<input id="star-3" name="radioradio" type="radio" value="3"><label for="star-3"></label> | |
<input id="star-2" name="radioradio" type="radio" value="2"><label for="star-2"></label> | |
<input id="star-1" name="radioradio" type="radio" value="1"><label for="star-1"></label> | |
</span> | |
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 | |
import scipy.linalg as LA | |
def comparison_loss(metric, comparisons): | |
loss = 0. | |
for weight, xa, xb, xc, xd in comparisons: | |
vab = xa - xb | |
vcd = xc - xd | |
dab = np.dot(vab.T, np.dot(metric, vab)) | |
dcd = np.dot(vcd.T, np.dot(metric, vcd)) |
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.covariance import graph_lasso | |
from sklearn.utils.extmath import pinvh | |
def compute_K(n, S, D): | |
K = np.zeros((n,n)) | |
for a, b in S: | |
K[a,b] = 1 | |
#K[b,a] = 1 | |
for a, b in D: |
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 collections import OrderedDict | |
from boto.mturk.connection import MTurkConnection | |
from dateutil.parser import parse as dateparse | |
mtc = MTurkConnection(host='mechanicalturk.amazonaws.com') | |
def responses(hit_group_id): | |
responses = [] | |
for hit in mtc.get_all_hits(): |
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 sys | |
from six import iteritems | |
from six.moves import zip as izip | |
from six.moves import xrange | |
from itertools import chain, repeat, islice |
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
# | |
# SPI driver (using spidev device) | |
# | |
# Copyright (c) 2013 Kenneth Arnold <[email protected]> | |
# Copyright (c) 2007 MontaVista Software, Inc. | |
# Copyright (c) 2007 Anton Vorontsov <[email protected]> | |
# | |
# This program is free software; you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation; either version 2 of the License. |
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 pandas as pd | |
import sys | |
filename, outfile = sys.argv[1:3] | |
responses = pd.read_csv(filename) | |
def format_row(row): | |
return '\n'.join(["<p><b>{}</b><br>{}</p>".format(k, v.replace('\n', '<br>')) for k, v in row.iteritems()]) | |
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
def reconstruct_lkj_cholesky(ell, R2): | |
num_items = len(R2) + 1 | |
L = np.zeros((num_items, num_items)) | |
L[0, 0] = 1. | |
L[1, 0] = 2. * R2[0] - 1.0 | |
L[1, 1] = np.sqrt(1.0 - L[1, 0]) | |
start = 0 | |
for i in range(2, num_items): | |
ell_row = ell[start:start+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
.mturk-ari { | |
border: 1px solid black; | |
padding: 4px; | |
} | |
.mturk-ari th { | |
padding-right: 5px; | |
text-align: right; | |
} |
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 | |
import sys | |
def read_stored(num_dims, names_filename, data_filename): | |
import pandas as pd | |
names = pd.Index(line.strip() for line in open(names_filename)) | |
num_terms = len(names) | |
data = np.memmap(data_filename, dtype=np.float32, mode='r', shape=(num_terms, num_dims)) | |
return names, data |