Skip to content

Instantly share code, notes, and snippets.

import nltk
from nltk.corpus import stopwords
from collections import Counter
from sklearn.feature_extraction.text import TfidfVectorizer
def get_tokens(no_punctuation):
tokens = nltk.word_tokenize(no_punctuation)
return tokens
def remove_stop_words(tokens):
import threading
from Queue import Queue
NUMBER_THREADS = 2
work = range(1,11)
q = Queue()
def queue_work():
while True:
number = q.get()
if not number:
break
def next_candidate(current_x, bounds):
found = False
while not found:
candidate = [np.random.randint(np.max([x-1, b[0]]), high=np.min([x+2, b[1]+1])) for x, b in zip(current_x, bounds)]
if np.sum(np.abs(np.subtract(current_x, candidate))) >= 1:
found = True
return candidate
def likelihood_ratio(chi1, chi2, sigma):
return np.exp((-chi2+chi1)/(2.0*(sigma**2.0)))
create function
prob_b_beat_a
(total_a int, conv_a int, total_b int, conv_b int)
--INPUTS:
-- total_a = total number that saw A
-- conv_a = converters for version A
-- total_b = total number that saw B
-- conv_b = converters for version B
create function
ztest_proportion_two_samples
(total_a float, conv_a float, total_b float, conv_b float, one_sided boolean)
--INPUTS:
-- total_a = total number that saw A
-- conv_a = converters for version A
-- total_b = total number that saw B
-- conv_b = converters for version B
-- one_sided = one or two sided test
create function
zconf_interval_two_samples
(total_a float, conv_a float, total_b float, conv_b float, alpha float)
--INPUTS:
-- total_a = total number that saw A
-- conv_a = converters for version A
-- total_b = total number that saw B
-- conv_b = converters for version B
-- alpha = alpha value (0.05?)
create function
prob_b_beat_a
(total_a int, conv_a int, total_b int, conv_b int)
--INPUTS:
-- total_a = total number that saw A
-- conv_a = converters for version A
-- total_b = total number that saw B
-- conv_b = converters for version B
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.