This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% 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: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |