Skip to content

Instantly share code, notes, and snippets.

View xgfs's full-sized avatar

Anton Tsitsulin xgfs

View GitHub Profile
colorbrewer_accent = [[127, 201, 127], [190, 174, 212], [253, 192, 134], [255, 255, 153], [56, 108, 176], [240, 2, 127], [191, 91, 23], [102, 102, 102]]
colorbrewer_dark2 = [[27, 158, 119], [217, 95, 2], [117, 112, 179], [231, 41, 138], [102, 166, 30], [230, 171, 2], [166, 118, 29], [102, 102, 102]]
colorbrewer_paired = [[166, 206, 227], [31, 120, 180], [178, 223, 138], [51, 160, 44], [251, 154, 153], [227, 26, 28], [253, 191, 111], [255, 127, 0], [202, 178, 214], [106, 61, 154], [255, 255, 153], [177, 89, 40]]
colorbrewer_pastel1 = [[251, 180, 174], [179, 205, 227], [204, 235, 197], [222, 203, 228], [254, 217, 166], [255, 255, 204], [229, 216, 189], [253, 218, 236], [242, 242, 242]]
colorbrewer_pastel2 = [[179, 226, 205], [253, 205, 172], [203, 213, 232], [244, 202, 228], [230, 245, 201], [255, 242, 174], [241, 226, 204], [204, 204, 204]]
colorbrewer_set1 = [[228, 26, 28], [55, 126, 184], [77, 175, 74], [152, 78, 163], [255, 127, 0], [255, 255, 51], [166, 86, 40], [247, 129, 191], [153, 153, 153]]
colorbrewe
@xgfs
xgfs / pallettes.py
Last active December 21, 2021 08:33
xgfs_normal6 = [(64, 83, 211), (221, 179, 16), (181, 29, 20), (0, 190, 255), (251, 73, 176), (0, 178, 93), (202, 202, 202)]
xgfs_normal12 = [(235, 172, 35), (184, 0, 88), (0, 140, 249), (0, 110, 0), (0, 187, 173), (209, 99, 230), (178, 69, 2), (255, 146, 135), (89, 84, 214), (0, 198, 248), (135, 133, 0), (0, 167, 108), (189, 189, 189)]
xgfs_bright6 = [(239, 230, 69), (233, 53, 161), (0, 227, 255), (225, 86, 44), (83, 126, 255), (0, 203, 133), (238, 238, 238)]
xgfs_dark6 = [(0, 89, 0), (0, 0, 120), (73, 13, 0), (138, 3, 79), (0, 90, 138), (68, 53, 0), (88, 88, 88)]
xgfs_fancy6 = [(86, 100, 26), (192, 175, 251), (230, 161, 118), (0, 103, 138), (152, 68, 100), (94, 204, 171), (205, 205, 205)]
xgfs_tarnish6 = [(39, 77, 82), (199, 162, 166), (129, 139, 112), (96, 78, 60), (140, 159, 183), (121, 104, 128), (192, 192, 192)]
@xgfs
xgfs / results.md
Last active May 3, 2019 14:29
Graph kernel datasets performance with simple features
name graph size node labels max. class prob
AIDS 99.69 99.54 80.00
BZR 80.12 83.65 78.77
BZR_MD 62.19 66.28 51.31
COIL-DEL 7.95 nan 1.00
COIL-RAG 5.48 nan 1.00
COLLAB 68.20 nan 52.00
COX2 77.85 77.85 78.16
COX2_MD 50.30 64.51 51.16
@xgfs
xgfs / simrank.py
Created April 18, 2017 11:01
A O(n^3) SimRank algorithm with caching
import networkx as nx
import numpy as np
def simrank_fast(G, c=0.9, max_iter=100, epsilon=1e-4):
if type(G) == nx.MultiGraph or type(G) == nx.MultiDiGraph:
raise Exception("simrank() not defined for graphs with multiedges.")
if G.is_directed():
raise Exception("simrank() not defined for directed graphs.")
def line_to_pgn(line, white, black, result):
return '[White "{}"]\n[Black "{}"] \n[Result "{}"]\n\n{}*\n\n'.format(white, black, result, line)
with open('games-all.pgn', 'w') as outf:
first_line = True
with open('white-moves.txt', 'r') as inf:
for line in inf:
if first_line:
first_line = False
continue

Keybase proof

I hereby claim:

  • I am xgfs on github.
  • I am xgfs (https://keybase.io/xgfs) on keybase.
  • I have a public key whose fingerprint is CDCF B4E5 49EA DC0F 0F63 BBD7 298A AF5C 2502 F97F

To claim this, I am signing this object:

@xgfs
xgfs / ndcg.py
Created March 12, 2016 10:15
graph ndcg
import numpy as np
def dcg(values):
gains = np.exp2(values) - 1
discounts = np.log2(np.arange(len(values)) + 2)
return np.sum(gains / discounts)
def ndcg(actual, predicted):
return dcg(np.in1d(actual, predicted).astype(np.int)) / dcg(np.ones(len(actual)))
@xgfs
xgfs / reading.py
Last active June 5, 2016 14:43
How do i read that binary file
from struct import unpack
fname = r'D:\vk_1015\group_data_inv.bin'
buffer_size = 1024
last_node = 1
user_subs = {1: []}
stop = False
with open(fname, 'rb') as f:
while True:
bytes = f.read(4*buffer_size)