Skip to content

Instantly share code, notes, and snippets.

View marcelcaraciolo's full-sized avatar
💭
Coding !

Marcel Caraciolo marcelcaraciolo

💭
Coding !
View GitHub Profile
@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 / question_recommendation.py
Created November 1, 2011 11:55
question_recommendation
{% load thumbnails %}
({
name:'{{ recommendation.name }}',
profile_url: '{{ recommendation.get_absolute_url }}',
follow_url: '{% url join_studygroup recommendation.slug %}',
thumbnail: '{% get_thumbnail_url recommendation 'minimum' %}',
type: '{{ type }}',
itens_count: '{{ itens_count }}',
why: {
@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 / multlin.py
Created October 28, 2011 03:53
multivariate linear regression
def feature_normalize(X):
'''
Returns a normalized version of X where
the mean value of each feature is 0 and the standard deviation
is 1. This is often a good preprocessing step to do when
working with learning algorithms.
'''
mean_r = []
std_r = []
@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 / linregr.py
Created October 28, 2011 03:39
linear regression
#Evaluate the linear regression
def compute_cost(X, y, theta):
'''
Comput cost for linear regression
'''
#Number of training samples
m = y.size
predictions = X.dot(theta).flatten()
@marcelcaraciolo
marcelcaraciolo / linregr.py
Created October 28, 2011 03:36
linear regression
X = data[:, 0]
y = data[:, 1]
#number of training samples
m = y.size
#Add a column of ones to X (interception data)
it = ones(shape=(m, 2))
it[:, 1] = X
@marcelcaraciolo
marcelcaraciolo / linregr.py
Created October 28, 2011 03:21
linear regression
from numpy import loadtxt, zeros, ones, array, linspace, logspace
from pylab import scatter, show, title, xlabel, ylabel, plot, contour
#Load the dataset
data = loadtxt('ex1data1.txt', delimiter=',')
#Plot the data
@marcelcaraciolo
marcelcaraciolo / spearman_numpy_cython.pyx
Created September 24, 2011 21:06
spearman_numpy_cython.pyx
import datetime
import sys
import random
cimport numpy as np
def _rank_dists(np.ndarray ranks1, np.ndarray ranks2):
"""Finds the difference between the values in ranks1 and ranks2 for keys
@marcelcaraciolo
marcelcaraciolo / spearman_scipy.py
Created September 24, 2011 20:49
spearman_scipy.py
import datetime
import sys
import random
import numpy as np
from scipy.stats import spearmanr
def _rank_dists(ranks1, ranks2):
"""Finds the values in ranks1 and ranks2 for keys
present in both arrays.