Skip to content

Instantly share code, notes, and snippets.

@rishabhjain
rishabhjain / twittertrends.py
Created November 20, 2012 05:14
Twitter Trends
from __future__ import division
# s -> observation
def probclass(dists,gamma):
from math import exp
p = 0
for i in range(len(dists)):
p = p + exp(-gamma*(dists[i]))
return p
@rishabhjain
rishabhjain / ensembleutility.py
Created November 20, 2012 05:16
Ensembleutility
from __future__ import division
import numpy as np
from functools import partial
from itertools import product
from collections import Counter,defaultdict
from sklearn import svm
from sklearn import linear_model
from sklearn.ensemble import RandomForestClassifier
from sklearn.decomposition import PCA
from sklearn import neighbors
@rishabhjain
rishabhjain / somename.py
Created November 24, 2012 18:28
tfifdvectorconvertrer
from __future__ import division
import tarfile, os
import nltk
from collections import Counter,defaultdict
from math import log
from ipdb import set_trace as l
from nltk.corpus import wordnet
from itertools import count
class hashabledict(Counter):
@rishabhjain
rishabhjain / tfidf.py
Created November 24, 2012 19:20
tfidfvector
import codecs,tarfile,os
from sklearn.feature_extraction.text import CountVectorizer,TfidfTransformer
from ipdb import set_trace as l
# Put this script in folder having 20news-bydate.tar.gz and run main()
def extract():
f = tarfile.open('20news-bydate.tar.gz', 'r:gz') #extracts tarballs
f.extractall()
trainpath = os.path.join(os.path.realpath('.'), '20news-bydate-train/')
#!/usr/bin/python
# Adapted from http://kutuma.blogspot.com/2007/08/sending-emails-via-gmail-with-python.html
import getpass
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email import Encoders
import os
@rishabhjain
rishabhjain / logreg.rb
Created May 11, 2013 13:28
Logistic Regression
require 'matrix'
require 'debugger'
def online_gradient_descent(sample,label,weight,learning_rate=0.1)
# debugger
# Expecting Sample and Weight to be a Vector
# Expecting label to be from {1,-1} and learning_rate to be float
# Single epoch, updates weight vector using a single sample
weight -= (-1)*(learning_rate)*label*sample/(1+Math.exp(label*(sample.inner_product(weight))))
end
sudo apt-get update
sudo apt-get -y install ruby1.9.1 ruby1.9.1-dev rubygems1.9.1 irb1.9.1 ri1.9.1 rdoc1.9.1 build-essential libopenssl-ruby1.9.1 libssl-dev zlib1g-dev libxslt-dev libxml2-dev libmysqlclient-dev curl git
sudo update-alternatives --install /usr/bin/ruby ruby /usr/bin/ruby1.9.1 400 --slave /usr/share/man/man1/ruby.1.gz ruby.1.gz /usr/share/man/man1/ruby1.9.1.1.gz --slave /usr/bin/ri ri /usr/bin/ri1.9.1 --slave /usr/bin/irb irb /usr/bin/irb1.9.1 --slave /usr/bin/rdoc rdoc /usr/bin/rdoc1.9.1
git clone git://github.com/cantino/huginn.git
cd huginn
sudo gem install rake bundle
#bundle
echo mysql-server mysql-server/root_password password password | sudo debconf-set-selections
echo mysql-server mysql-server/root_password_again password password | sudo debconf-set-selections
sudo apt-get -y install mysql-server
@rishabhjain
rishabhjain / Vagrantfile
Created May 16, 2013 22:46
vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "precise32"

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@rishabhjain
rishabhjain / cv.md
Created August 26, 2016 17:12
The gist of my professional history.

Ken Hu

Keep searching; in data, tech, arts, startups, world, love, and life.

I am a Python developer, specializing in data and natural language analysis. My professional experiences ranges across API development, natural language processing, business intelligence dashboard, and machine learning. I also have strong interests in search engines and data visualization.

##Table of Content

  1. Contact
  2. Achievement