Skip to content

Instantly share code, notes, and snippets.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import sys
import numpy as np
from sklearn.datasets import load_svmlight_file
from sklearn.ensemble import GradientBoostingClassifier
from sklearn.externals.joblib import Parallel, delayed
from sklearn.utils import array2d
from sklearn.tree._tree import DTYPE
@laughing
laughing / test_ts.py
Created December 28, 2014 15:01
thompson sampling
execfile("core.py")
from ts import *
import random
random.seed(1)
means = [0.1, 0.1, 0.1, 0.1, 0.9]
n_arms = len(means)
random.shuffle(means)
arms = map(lambda (mu): BernoulliArm(mu), means)
print("Best arm is " + str(ind_max(means)))
import math
from collections import defaultdict
class LR_SGD(object):
def __init__(self, eta=1):
self.w = defaultdict(float)
self.eta = eta
self.t = 0
def sign(self, z):
# -*- coding: utf-8 -*-
import sys
import MeCab
import json
import unicodedata
m = MeCab.Tagger ("-Ochasen")
for l in sys.stdin:
l = json.loads(l)
l = l["comment"]