Skip to content

Instantly share code, notes, and snippets.

Ieva Zarina IevaZarina

View GitHub Profile
IevaZarina /
Created Jun 16, 2017
Simple supervised KNN classification in Python 2.7
# knn
import math
from collections import defaultdict
from operator import itemgetter
# Some handmade train/test data
X_train = [
[1, 1],
IevaZarina /
Created Nov 24, 2016
Simple test case for aho-corasick automata for keyword search.
import ahocorasick as ahc
keywords = [
('he', 1),
('she', 1),
('hers', 1),
('her', 1)
text = [
IevaZarina /
Created Nov 7, 2016
Simple depth-first searcher in Python 2.7
Depth-first searcher
/ \
b c
/|\ \
d e f g
import matplotlib.pyplot as plt
from sklearn import datasets
from sklearn.decomposition import TruncatedSVD
# Enable saving plot to png file without UI
iris = datasets.load_iris()
X =
y =
View animals.json
"'{\"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\"}]}'"
IevaZarina /
Last active May 28, 2020
Simple demo script for running Xgboost
# 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
IevaZarina /
Last active Feb 8, 2018
Cleaning lines of text
# -*- coding: utf-8 -*-
# Ieva Zarina, 2016, licensed under the Apache 2.0 licnece
import re
def is_digit(word):
return True
except ValueError:
# -*- 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:
You can’t perform that action at this time.