Skip to content

Instantly share code, notes, and snippets.

{"directed": true, "multigraph": false, "graph": {}, "nodes": [{"ppr_percentile": 39.937106918239, "weighted_degree": 6.0, "generic_tag": "method", "born_time": "b1", "id": "maximum_likelihood"}, {"ppr_percentile": 0.0, "weighted_degree": 0.0, "generic_tag": "pheno", "born_time": "b4", "id": "context-aware"}, {"ppr_percentile": 0.0, "weighted_degree": 0.0, "generic_tag": "pheno", "born_time": "b4", "id": "interactive_machine_translation"}, {"ppr_percentile": 0.0, "weighted_degree": 0.0, "generic_tag": "method", "born_time": "b5", "id": "neural_encoder-decoder"}, {"ppr_percentile": 36.477987421383645, "weighted_degree": 5.0, "generic_tag": "pheno", "born_time": "b0", "id": "lexicalized_tree-adjoining"}, {"ppr_percentile": 0.0, "weighted_degree": 0.0, "generic_tag": "pheno", "born_time": "b4", "id": "urdu"}, {"ppr_percentile": 44.077568134171905, "weighted_degree": 6.0, "generic_tag": "method", "born_time": "b0", "id": "class_based"}, {"ppr_percentile": 76.10062893081759, "weighted_degree": 28.0, "generic_tag":
{"directed": true, "multigraph": false, "graph": {}, "nodes": [{"ppr_percentile": 52.43393602225313, "weighted_degree": 8.0, "generic_tag": "method", "born_time": "b1", "id": "maximum_likelihood"}, {"ppr_percentile": 0.0, "weighted_degree": 0.0, "generic_tag": "pheno", "born_time": "b4", "id": "context-aware"}, {"ppr_percentile": 0.0, "weighted_degree": 0.0, "generic_tag": "pheno", "born_time": "b4", "id": "interactive_machine_translation"}, {"ppr_percentile": 0.0, "weighted_degree": 0.0, "generic_tag": "method", "born_time": "b5", "id": "neural_encoder-decoder"}, {"ppr_percentile": 36.578581363004176, "weighted_degree": 4.0, "generic_tag": "pheno", "born_time": "b0", "id": "lexicalized_tree-adjoining"}, {"ppr_percentile": 0.0, "weighted_degree": 0.0, "generic_tag": "pheno", "born_time": "b4", "id": "urdu"}, {"ppr_percentile": 22.670375521557716, "weighted_degree": 2.0, "generic_tag": "method", "born_time": "b0", "id": "class_based"}, {"ppr_percentile": 60.22253129346314, "weighted_degree": 7.0, "generic_tag"
{"directed": true, "multigraph": false, "graph": {}, "nodes": [{"ppr_percentile": 14.634146341463413, "weighted_degree": 1.0, "generic_tag": "method", "born_time": "b1", "id": "maximum_likelihood"}, {"ppr_percentile": 0.0, "weighted_degree": 0.0, "generic_tag": "pheno", "born_time": "b4", "id": "context-aware"}, {"ppr_percentile": 0.0, "weighted_degree": 0.0, "generic_tag": "pheno", "born_time": "b4", "id": "interactive_machine_translation"}, {"ppr_percentile": 0.0, "weighted_degree": 0.0, "generic_tag": "method", "born_time": "b5", "id": "neural_encoder-decoder"}, {"ppr_percentile": 41.707317073170735, "weighted_degree": 5.0, "generic_tag": "pheno", "born_time": "b0", "id": "lexicalized_tree-adjoining"}, {"ppr_percentile": 0.0, "weighted_degree": 0.0, "generic_tag": "pheno", "born_time": "b4", "id": "urdu"}, {"ppr_percentile": 23.04878048780488, "weighted_degree": 2.0, "generic_tag": "method", "born_time": "b0", "id": "class_based"}, {"ppr_percentile": 8.78048780487805, "weighted_degree": 1.0, "generic_tag":
{"directed": true, "multigraph": false, "graph": {}, "nodes": [{"ppr_percentile": 0.0, "weighted_degree": 0.0, "generic_tag": "method", "born_time": "b1", "id": "maximum_likelihood"}, {"ppr_percentile": 0.0, "weighted_degree": 0.0, "generic_tag": "pheno", "born_time": "b4", "id": "context-aware"}, {"ppr_percentile": 0.0, "weighted_degree": 0.0, "generic_tag": "pheno", "born_time": "b4", "id": "interactive_machine_translation"}, {"ppr_percentile": 0.0, "weighted_degree": 0.0, "generic_tag": "method", "born_time": "b5", "id": "neural_encoder-decoder"}, {"ppr_percentile": 26.848249027237355, "weighted_degree": 2.0, "generic_tag": "pheno", "born_time": "b0", "id": "lexicalized_tree-adjoining"}, {"ppr_percentile": 0.0, "weighted_degree": 0.0, "generic_tag": "pheno", "born_time": "b4", "id": "urdu"}, {"ppr_percentile": 37.7431906614786, "weighted_degree": 2.0, "generic_tag": "method", "born_time": "b0", "id": "class_based"}, {"ppr_percentile": 0.0, "weighted_degree": 0.0, "generic_tag": "method", "born_time": "b1",
{"directed": false, "multigraph": false, "graph": {"name": "Zachary's Karate Club"}, "nodes": [{"club": "Mr. Hi", "id": 0}, {"club": "Mr. Hi", "id": 1}, {"club": "Mr. Hi", "id": 2}, {"club": "Mr. Hi", "id": 3}, {"club": "Mr. Hi", "id": 4}, {"club": "Mr. Hi", "id": 5}, {"club": "Mr. Hi", "id": 6}, {"club": "Mr. Hi", "id": 7}, {"club": "Mr. Hi", "id": 8}, {"club": "Officer", "id": 9}, {"club": "Mr. Hi", "id": 10}, {"club": "Mr. Hi", "id": 11}, {"club": "Mr. Hi", "id": 12}, {"club": "Mr. Hi", "id": 13}, {"club": "Officer", "id": 14}, {"club": "Officer", "id": 15}, {"club": "Mr. Hi", "id": 16}, {"club": "Mr. Hi", "id": 17}, {"club": "Officer", "id": 18}, {"club": "Mr. Hi", "id": 19}, {"club": "Officer", "id": 20}, {"club": "Mr. Hi", "id": 21}, {"club": "Officer", "id": 22}, {"club": "Officer", "id": 23}, {"club": "Officer", "id": 24}, {"club": "Officer", "id": 25}, {"club": "Officer", "id": 26}, {"club": "Officer", "id": 27}, {"club": "Officer", "id": 28}, {"club": "Officer", "id": 29}, {"club": "Officer", "id":
@viveksck
viveksck / gist:64bfb3fbd7937bd11778705f94140e34
Created March 17, 2019 01:22 — forked from seanjtaylor/gist:568141f04a16d518be24
Reshaping a Pandas dataframe into a sparse matrix
import pandas as pd
import scipy.sparse as sps
df = pd.DataFrame({'tag1': ['sean', 'udi', 'bogdan'], 'tag2': ['sean', 'udi', 'udi'], 'freq': [1,2,3]})
# tag1 -> rows, tag2 -> columns
df.set_index(['tag1', 'tag2'], inplace=True)
mat = sps.coo_matrix((df.freq, (df.index.labels[0], df.index.labels[1])))
print(mat.todense())
from itertools import izip
import numpy as np
import scipy as sp
import math
def get_base(unit ='bit'):
if unit == 'bit':
log = sp.log2
elif unit == 'nat':
log = sp.log
@viveksck
viveksck / scratch.ipynb
Last active February 14, 2018 01:09
Scratch
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@viveksck
viveksck / pd_latex_table.py
Created February 9, 2018 22:14 — forked from tbrittoborges/pd_latex_table.py
Pandas recipe for better latex tables
def better_table(table, caption, name):
start = r"""
\begin{{table}}[!htb]
\sisetup{{round-mode=places, round-precision=2}}
\caption{{{}}}\label{{table:{}}}
\centering
""".format(caption, name)
end = r"\end{table}"
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.