Skip to content

Instantly share code, notes, and snippets.

View vgoklani's full-sized avatar

Vishal Goklani vgoklani

View GitHub Profile
@anotherjavadude
anotherjavadude / index.html
Created October 25, 2011 11:37
Most simple d3.js tree
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?1.27.2"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.layout.js?1.27.2"></script>
<style>
.link {
fill: none;
@wrunk
wrunk / jinja2_file_less.py
Last active April 14, 2025 10:17
python jinja2 examples
#!/usr/bin/env/python
#
# More of a reference of using jinaj2 without actual template files.
# This is great for a simple output transformation to standard out.
#
# Of course you will need to "sudo pip install jinja2" first!
#
# I like to refer to the following to remember how to use jinja2 :)
# http://jinja.pocoo.org/docs/templates/
#
@marcelcaraciolo
marcelcaraciolo / linregr.py
Created October 28, 2011 03:43
linear regression
from numpy import loadtxt, zeros, ones, array, linspace, logspace
from pylab import scatter, show, title, xlabel, ylabel, plot, contour
#Evaluate the linear regression
def compute_cost(X, y, theta):
'''
Comput cost for linear regression
'''
#Number of training samples
@marcelcaraciolo
marcelcaraciolo / multlin.py
Created October 28, 2011 03:57
multivariate linear regression
from numpy import loadtxt, zeros, ones, array, linspace, logspace, mean, std, arange
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
from pylab import plot, show, xlabel, ylabel
#Evaluate the linear regression
def feature_normalize(X):
'''
Returns a normalized version of X where
@marcelcaraciolo
marcelcaraciolo / log_regression.py
Created November 6, 2011 14:24
log_regression
from numpy import loadtxt, where
from pylab import scatter, show, legend, xlabel, ylabel
#load the dataset
data = loadtxt('ex2data1.txt', delimiter=',')
X = data[:, 0:2]
y = data[:, 2]
pos = where(y == 1)
@marcelcaraciolo
marcelcaraciolo / prediction.py
Created November 13, 2011 12:54
Logistic prediction
def predict(theta, X):
'''Predict whether the label
is 0 or 1 using learned logistic
regression parameters '''
m, n = X.shape
p = zeros(shape=(m, 1))
h = sigmoid(X.dot(theta.T))
for it in range(0, h.shape[0]):
@mikedewar
mikedewar / df2json.py
Created December 16, 2011 13:17
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],
@marcelcaraciolo
marcelcaraciolo / pyfoursquare.py
Created December 22, 2011 04:05
pyfoursquare Oauth
import foursquare
# == OAuth2 Authentication ==
#
# This mode of authentication is the required one for Foursquare
# The client id and client secret can be found on your application's Details
# page located at https://foursquare.com/oauth/
client_id = ""
client_secret = ""
@marcelcaraciolo
marcelcaraciolo / pyfoursquare.py
Created December 22, 2011 04:07
pyfoursquare API
#Now let's create an API
api = foursquare.API(auth)
#Now you can access the Foursquare API!
result = api.venues_search(query='Burburinho', ll='-8.063542,-34.872891')
#You can acess as a Model
print dir(result[0])
#Access all its attributes
@ogrisel
ogrisel / learning_curves.png
Created December 30, 2011 16:04
Learning Curves for under/overfitting evaluation
learning_curves.png