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 json | |
class MapReduce: | |
def __init__(self): | |
self.data = [] | |
self.intermediate = {} | |
self.result = [] | |
def emit_intermediate(self, key, value): | |
self.intermediate.setdefault(key, []) |
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
# Coursera SNA optional Programming Assignment 3 template | |
# see this blog post for a nice overview of community detection algorithms | |
# http://www.r-bloggers.com/summary-of-community-detection-algorithms-in-igraph-0-6/ | |
# load the igraph library | |
# you may have to install this module if you haven't already | |
import igraph as ig | |
# read in the graph in GML format | |
# it is a sampled collection of pages from a strange set of seed categories: |
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
# Coursera SNA optional Programming Assignment 2 template | |
# load the igraph library | |
# you may have to install this module if you haven't already | |
import igraph as ig | |
import numpy as np | |
# read in the graph in GML format | |
# it is a sampled collection of pages from a strange set of seed categories: | |
# Math, Sociology, and Chemistry |
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
function MonitorAssignment( F, names, valNames, E ) | |
% MonitorAssignment( F, names, valNames, E ) - Pretty prints all the | |
% marginals for an assignment | |
% | |
% F contains the struct array of factors | |
% names contains the variable names | |
% valNames contains the assignment names for each variable, | |
% as seen in SAMIAM | |
% E is an N-by-2 cell array, each row being a variable/value pair. | |
% Variables are in the first column and values are in the second column. |