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
# knn | |
import math | |
from collections import defaultdict | |
from operator import itemgetter | |
# Some handmade train/test data | |
X_train = [ | |
[1, 1], |
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 ahocorasick as ahc | |
keywords = [ | |
('he', 1), | |
('she', 1), | |
('hers', 1), | |
('her', 1) | |
] | |
text = [ |
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
''' | |
Depth-first searcher | |
Tree: | |
a | |
/ \ | |
b c | |
/|\ \ | |
d e f g | |
| |
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 matplotlib.pyplot as plt | |
from sklearn import datasets | |
from sklearn.decomposition import TruncatedSVD | |
# Enable saving plot to png file without UI | |
plt.switch_backend('agg') | |
iris = datasets.load_iris() | |
X = iris.data | |
y = iris.target |
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
"'{\"animal_list\": [{\"type\": \"mammal\", \"description\": \"Tall, with brown spots, lives in Savanna\", \"name\": \"Giraffa camelopardalis\"},{\"type\": \"mammal\", \"description\": \"Big, grey, with big ears, smart\", \"name\": \"Loxodonta africana\"},{\"type\": \"reptile\", \"description\": \"Green, changes color, lives in \"East Africa\"\", \"name\": \"Trioceros jacksonii\"}]}'" |
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
# Ieva Zarina, 2016, licensed under the Apache 2.0 licnese | |
import numpy as np | |
import xgboost as xgb | |
from sklearn import datasets | |
from sklearn.cross_validation import train_test_split | |
from sklearn.datasets import dump_svmlight_file | |
from sklearn.externals import joblib | |
from sklearn.metrics import precision_score |
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
# -*- coding: utf-8 -*- | |
# Ieva Zarina, 2016, licensed under the Apache 2.0 licnece | |
import re | |
def is_digit(word): | |
try: | |
int(word) | |
return True | |
except ValueError: |
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
# -*- coding: utf-8 -*- | |
import random | |
def getRandomPerson(ppl): | |
return ppl[random.randint(0,len(ppl)-1)] | |
def good_pair(ignore_ppl, chosen1, chosen2): | |
for pair in ignore_ppl: |