Skip to content

Instantly share code, notes, and snippets.

View vgoklani's full-sized avatar

Vishal Goklani vgoklani

View GitHub Profile
from pymongo import Connection
import datetime
import time
#connect to mongodb
connection = Connection(‘newitfarmer.com’, 27017)
from pymongo import Connection
import datetime
import time
#connect to mongodb
connection = Connection(‘newitfarmer.com’, 27017)
@vgoklani
vgoklani / gist:1817700
Created February 13, 2012 15:44 — forked from neilkod/gist:1319966
my stopwords code, optimized for social media
given a text file containing stopwords, return a python list of its contents.
this list is optimized for twitter/social media and filters out stuff
like RT, nowplaying, lastfm, 4sq etc.
def get_stopwords(file='stopwords.txt'):
words = open(file,'r')
stopwords = [word.strip() for word in words]
return set(stopwords)
@vgoklani
vgoklani / df2json.py
Created March 1, 2012 15:23 — forked from mikedewar/df2json.py
A little script to convert a pandas data frame to a JSON object. Is there a better way?
"""
tiny script to convert a pandas data frame into a JSON object
"""
import ujson as json
import pandas
import numpy as np
df = pandas.DataFrame({
"time" : [1,2,3,4,5],
@vgoklani
vgoklani / friends.py
Created April 1, 2012 22:25 — forked from ewilderj/friends.py
Make a graph of your social network from those you follow
# a messy hack written by Edd Dumbill. http://twitter.com/edd
# You may need to rerun this script if you hit a Twitter Error because you
# use up API rate limiting. That's why we pickle the results, so we can resume
# where we left off.
# get the twitter module using 'easy_install twitter'
from twitter.api import Twitter, TwitterError
from twitter.oauth import OAuth
@vgoklani
vgoklani / GPTutorial.ipynb
Created April 10, 2012 20:00 — forked from fonnesbeck/GPTutorial.ipynb
An iPython notebook containing a short PyMC tutorial on Gaussian Processes. Requires PyMC and iPython (>=0.12) to be installed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vgoklani
vgoklani / GPTutorial.ipynb
Created April 11, 2012 11:11 — forked from fonnesbeck/GPTutorial.ipynb
An iPython notebook containing a short PyMC tutorial on Gaussian Processes. Requires PyMC and iPython (>=0.12) to be installed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vgoklani
vgoklani / learning_curves.png
Created April 24, 2012 17:25 — forked from ogrisel/learning_curves.png
Learning Curves for under/overfitting evaluation
learning_curves.png
@vgoklani
vgoklani / fast_svd.py
Created April 26, 2012 03:08 — forked from alextp/fast_svd.py
Gunnar Martinsson's fast svd
import numpy as np, numpy.linalg as linalg
def fast_svd(M, k):
p = k+5
Y = np.dot(M, np.random.normal(size=(M.shape[1],p)))
Q,r = linalg.qr(Y)
B = np.dot(Q.T,M)
Uhat, s, v = linalg.svd(B, full_matrices=False)
U = np.dot(Q, Uhat)
return U.T[:k].T, s[:k], v[:k]
@vgoklani
vgoklani / lda_gibbs.py
Created August 6, 2012 13:06 — forked from mblondel/lda_gibbs.py
Latent Dirichlet Allocation with Gibbs sampler
"""
(C) Mathieu Blondel - 2010
Implementation of the collapsed Gibbs sampler for
Latent Dirichlet Allocation, as described in
Finding scientifc topics (Griffiths and Steyvers)
"""
import numpy as np