{{ message }}

Instantly share code, notes, and snippets.

# Diogo Costa diogojc

Created Apr 2, 2012
Generates every possible combination from a set of discrete variables
View combinations.py
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
 #!/usr/bin/python def combinations(S): """ Generates every possible combination from a set of discrete variables Arguments --------- S: Cardinality of variable space. When S = [2, 3, 4] variables 1, 2 and
Created Jan 1, 2012
Density estimation using multivariate gaussians
View multivariateGaussian.py
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 numpy as np import matplotlib.pyplot as plt def params(X): """ Calculates the mean vector and covariance matrix for the given data. Arguments ---------
Created Dec 28, 2011
Regression based collaborative filtering
View cf.py
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 numpy as np from scipy.optimize import fmin_cg def cost(p, Y, R, alpha): """ Calculates collaborative filtering cost function. Arguments
Created Dec 25, 2011
Ridge Regression
View ridge.py
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
 #!/usr/bin/python # -*- coding: utf-8 -*- import numpy as np import matplotlib.pyplot as plt class RidgeRegressor(object): """ Linear Least Squares Regression with Tikhonov regularization.
Created Nov 25, 2011
parameterizing and plotting Power Laws in python (Zipf example)
View powerlaw.py
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 numpy as np def powerLaw(y, x): """ 'When the frequency of an event varies as power of some attribute of that event the frequency is said to follow a power law.' (wikipedia) This is represented by the following equation, where c and alpha are constants: y = c . x ^ alpha
Created Nov 3, 2011
python implementation of pagerank
View pagerank.py
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 numpy as np from scipy.sparse import csc_matrix def pageRank(G, s = .85, maxerr = .001): """ Computes the pagerank for each of the n states. Used in webpage ranking and text summarization using unweighted or weighted transitions respectively.