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 redis | |
r = redis.StrictRedis(host='localhost', port=6379, db=0) | |
from redisprob import RedisHashFreqDist | |
rhfd = RedisHashFreqDist(r, 'test') | |
print rhfd.items() | |
# [] -> [('foo', 1)] | |
print rhfd.values() | |
print len(rhfd) |
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
db = dict() | |
trans_history = [] #function structure | |
committed_trans_history = [] #outside block commands | |
trans_block_index = -1 #block index | |
''' SET [name] [value]: Set a variable [name] to the value [value]. Neither variable names nor values will ever contain spaces''' | |
def set_db(name, value): | |
db[name] = value |
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 json, sys, collections | |
import base64 | |
from Datum import Datum | |
class FeatureData : | |
def __init__(self, words, prevLabel, position, | |
wordsDict): | |
self.w = words; | |
self.pL = prevLabel |
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 sys | |
import os | |
import re | |
import pprint | |
my_first_pat = "(?:[a-zA-Z]+[\w+\.\-]+[\-a-zA-Z]+)[ ]*(?:@|\bat\b|\(at\)|\bwhere\b|\b@\b)[ ]*(?:(?:(?:[\-a-zA-Z]+)[ ]*(?:\.|\ |\bdot\b|\bdom\b|\bdt\b)[ ]*(?:[\-a-zA-Z]+)[ ]*(?:\.|\ |\bdot\b|\bdom\b)[ ]*(?:[\-a-zA-Z\ ]+))|(?:(?:(?:[\-a-zA-Z]+)[ ]*(?:\.|\ |\bdot\b|\bdom\b|\bdt\b)[ ]*(?:[\-a-zA-Z\ ]+))))" | |
def striphtml(data): | |
return re.sub(r'<[^>]*?>', ' ', 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
function [J grad] = nnCostFunction(nn_params, ... | |
input_layer_size, ... | |
hidden_layer_size, ... | |
num_labels, ... | |
X, y, lambda) | |
%NNCOSTFUNCTION Implements the neural network cost function for a two layer | |
%neural network which performs classification | |
% [J grad] = NNCOSTFUNCTON(nn_params, hidden_layer_size, num_labels, ... | |
% X, y, lambda) computes the cost and gradient of the neural network. The | |
% parameters for the neural network are "unrolled" into the vector |
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
function J = computeCostMulti(X, y, theta) | |
%COMPUTECOSTMULTI Compute cost for linear regression with multiple variables | |
% J = COMPUTECOSTMULTI(X, y, theta) computes the cost of using theta as the | |
% parameter for linear regression to fit the data points in X and y | |
% Initialize some useful values | |
m = length(y); % number of training examples | |
% You need to return the following variables correctly | |
J = 0; |
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
function [X_norm, mu, sigma] = featureNormalize(X) | |
%FEATURENORMALIZE Normalizes the features in X | |
% FEATURENORMALIZE(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. | |
% You need to set these values correctly | |
X_norm = X; | |
mu = zeros(1, size(X, 2)); |
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
function J = computeCost(X, y, theta) | |
%COMPUTECOST Compute cost for linear regression | |
% J = COMPUTECOST(X, y, theta) computes the cost of using theta as the | |
% parameter for linear regression to fit the data points in X and y | |
% Initialize some useful values | |
m = length(y); % number of training examples | |
% You need to return the following variables correctly | |
J = 0; |
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
function [theta, J_history] = gradientDescent(X, y, theta, alpha, num_iters) | |
%GRADIENTDESCENT Performs gradient descent to learn theta | |
% theta = GRADIENTDESENT(X, y, theta, alpha, num_iters) updates theta by | |
% taking num_iters gradient steps with learning rate alpha | |
% Initialize some useful values | |
m = length(y); % number of training examples | |
J_history = zeros(num_iters, 1); | |
theta_len = length(theta); |
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
''' | |
Created on Jun 6, 2011 | |
@author: denzilc | |
''' | |
import oauth2 as oauth | |
import urlparse | |
import time |
NewerOlder