Skip to content

Instantly share code, notes, and snippets.

@tsterker
tsterker / gist:1503993
Created December 21, 2011 00:46 — forked from chrisgilmerproj/gist:1503913
[py] Password Generator
p = ''.join(random.sample('ABCDEFGHJKLMNPQRSTUVWXYZ23456789', 6))
@tsterker
tsterker / Evolution of a Python programmer.py
Created December 21, 2011 00:58
[py] programmer levels
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
@tsterker
tsterker / linregr.py
Created December 21, 2011 01:12 — forked from marcelcaraciolo/linregr.py
[py] 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()
@tsterker
tsterker / multlin.py
Created December 21, 2011 01:14 — forked from marcelcaraciolo/multlin.py
[py] 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 = []
@tsterker
tsterker / ex1.py
Created December 21, 2011 01:15 — forked from gorlum0/ex1.py
[py] ml-class - ex1
#!/usr/bin/env python
import numpy as np
import matplotlib.pyplot as plt
from numpy import newaxis, r_, c_, mat
from numpy.linalg import *
def plotData(X, y):
plt.plot(X, y, 'rx', markersize=7)
plt.ylabel('Profit in $10,000s')
plt.xlabel('Population of City in 10,000s')