Skip to content

Instantly share code, notes, and snippets.

View madisonmay's full-sized avatar

Madison May madisonmay

View GitHub Profile
@madisonmay
madisonmay / confidences.json
Created November 16, 2020 18:40
Confidences
{"negative": [0.7401444395271548, 0.28408478157420025, 0.0, 0.06104001736239428, 0.052829689608438674, 0.9631350435736623, 0.5655241352304745, 0.3679754384302407, 0.0, 0.3010526604746881, 0.0, 0.049003323253499376, 0.0, 0.3623349850554368, 0.0, 0.10201364624894066, 0.3699260265480315, 0.0, 0.0, 0.2873237222303052, 0.0, 0.0, 0.22599129803989196, 0.090218287970653, 0.281288272371325, 0.3114189846769092, 0.2567905368634442, 0.2336614633799683, 0.0051746546399171756, 0.20433062590490317, 0.3567373180001101, 0.0, 0.0, 0.06136738950275861, 0.48047753484164246, 0.11005137789240804, 0.26666696243911037, 0.07755409812205752, 0.21090605870812276, 0.5047718563195722, 0.0, 0.13487756118596553, 0.20700081782289187, 0.11511649315792956, 0.4930083318674049, 0.46939962236241345, 0.4799421694511274, 0.4043727993172107, 0.21706460801023178, 0.4991243945059197], "positive": [1.0, 0.8094221524927675, 0.7589542882620298, 0.49541068835885216, 0.8574337542075641, 0.7191642685843241, 0.7265150611484562, 0.5180262959691256, 0.7425010
@madisonmay
madisonmay / named_einsum.py
Last active December 12, 2021 16:36
Named Einsum
import numpy as np
from string import ascii_lowercase, ascii_uppercase
def _translate_axes_names(seq: str, translation_table: dict=None):
if translation_table is None:
translation_table = {}
if not seq:
return "", translation_table
@madisonmay
madisonmay / indico.js
Created October 3, 2015 22:12
Indico API + jQuery
$.ajax({
url: "https://apiv2.indico.io/sentiment/batch?key=YOUR_API_KEY",
type: "POST",
data: JSON.stringify({"data": ["text", "more text"]}),
success: function (data) {
console.log(data);
}, error: function(err) {
console.log(err);
}
})
@madisonmay
madisonmay / 1083.yaml
Created August 22, 2014 03:46
Reproduce behavior described in pylearn2 issue #1083: https://github.com/lisa-lab/pylearn2/issues/1083
!obj:pylearn2.train.Train {
dataset: &train !obj:pylearn2.datasets.mnist.MNIST {
which_set: 'train',
start: 0,
stop: 50000
},
model: !obj:pylearn2.models.mlp.MLP {
layers: [
@madisonmay
madisonmay / plot_channels.py
Created July 27, 2014 17:53
Live plotting of pylearn2 channels
from collections import defaultdict
from pylearn2.train_extensions import TrainExtension
import matplotlib.pyplot as plt
class PlotChannels(TrainExtension):
def __init__(self, channels, legend_loc='upper right'):
self.channels = channels
self.legend_loc = legend_loc
@madisonmay
madisonmay / gist:6408842
Created September 2, 2013 02:53
Random weighted choice generator function
import itertools, bisect
def weighted_choice(seq, weights):
cumulative_dist = itertools.accumulate(weights)
while True:
x = random.random() * cumdist[-1]
i = [bisect.bisect(cumulative_dist, x)]
yield seq[i]
@madisonmay
madisonmay / sortBy.js
Last active December 18, 2015 07:39
Sorts an array in javascript by the given property
Array.prototype.sortBy = function(p){
//sorts an array of objects by property p
return this.sort(function(a,b){
return (a[p] > b[p]) ? 1 : (a[p] < b[p]) ? -1 : 0;
});
}