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
{"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 |
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 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 |
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
$.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); | |
} | |
}) |
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
!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: [ |
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 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 |
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 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] |
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
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; | |
}); | |
} |