This file contains hidden or 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
#!/bin/bash | |
mkdir sssp | |
cd sssp | |
curl "https://dl.dropboxusercontent.com/u/7571776/facebook100_txt_only.zip" -o "facebook100_txt_only.zip" | |
unzip facebook100_txt_only.zip | |
curl https://gist.githubusercontent.com/sangheestyle/6335b209b4779dddc5ac/raw/47a803d6ccfa727efb80d5c32f5e7361d32c861a/ps16c.py > ps16c.py | |
mkdir out | |
python ps16c.py facebook100txt $1 $2 | |
cd .. |
This file contains hidden or 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 sys | |
import json | |
from os import listdir | |
from os.path import isfile, join, basename | |
def get_file_paths(root): | |
file_paths = [] | |
for f in listdir(root): | |
if isfile((join(root, f))): |
This file contains hidden or 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 os | |
import json | |
summary_folder = "summary" | |
summary = {} | |
for path in os.listdir(summary_folder): | |
path_summary = json.load(open(os.path.join(summary_folder, path), "r")) | |
if not len(summary): | |
summary = path_summary | |
else: |
This file contains hidden or 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
nothing |
This file contains hidden or 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
# Reference: | |
# http://networkx.github.io/documentation/networkx-1.9.1/ | |
# reference/algorithms.centrality.html | |
import operator | |
import networkx as nx | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import itertools |
This file contains hidden or 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
OK, here is what you should do to use python pandas on Debian Wheezy, | |
Step 1: Make a bootable image with usb key | |
a. Get a usb key | |
b. Download debian live ISO image (recommend xfce integrated image) | |
c. Make a usb key as a ISO boot image (recommend using dd) | |
Step 2: Install & Boot | |
d. Boot up your machine with Debian usb key (recommend UEFI) | |
e. Do configuration |
This file contains hidden or 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
# origin: http://stackoverflow.com/questions/24662006/python-networkx-graph-different-colored-nodes-using-two-lists | |
## assign a node attribute, which I am going to color according to | |
for node in G.nodes(): | |
G.node[node]['category'] = my_category_dict[node] | |
## put together a color map, one color for a category | |
color_map = {'type_A':'b', 'type_B':'#FF0099', 'type_C':'#660066'} | |
## construct a list of colors then pass to node_color | |
nx.draw(G, node_color=[color_map[G.node[node]['category']] for node in G]) | |
plt.show() |
This file contains hidden or 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 csv | |
with open('ps03-4.csv','rb') as file: | |
contents = csv.reader(file) | |
matrix = list() | |
for row in contents: | |
matrix.append(row) |
This file contains hidden or 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
from collections import defaultdict | |
from nltk.corpus import brown | |
print ">>> Procssing" | |
word_tag = defaultdict(set) | |
for word, tag in brown.tagged_words(): | |
word_tag[word].add(tag) | |
num_words_by_num_tags = defaultdict(int) | |
words_with_max_tags = [None, 0] |
This file contains hidden or 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
words1 = "pa’Daq ghah taH tera’ngan ’e".replace("’","'").split() | |
tags1 = "N PRO V N PRO".split() | |
words2 = "ja’chuqmeH rojHom neH tera’ngan".replace("’","'").split() | |
tags2 = "V N V N".split() | |
words3 = "tera’ngan qIp puq ’eg puq qIp tera’ngan".replace("’","'").split() | |
tags3 = "N V N CONJ N V N".split() | |
train = [] |