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] = zscore_normalize_data(X, mu, sigma) | |
X_norm=bsxfun(@minus,X,mu); | |
X_norm=bsxfun(@rdivide,X_norm,sigma); |
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 urllib2 | |
from BeautifulSoup import BeautifulSoup | |
import pdb | |
import os | |
import htmlentitydefs | |
from BeautifulSoup import BeautifulStoneSoup | |
import HTMLParser | |
import cgi | |
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 mix = gmm(dim, ncentres, covar_type, ppca_dim) | |
%GMM Creates a Gaussian mixture model with specified architecture. | |
% | |
% Description | |
% MIX = GMM(DIM, NCENTRES, COVARTYPE) takes the dimension of the space | |
% DIM, the number of centres in the mixture model and the type of the | |
% mixture model, and returns a data structure MIX. The mixture model | |
% type defines the covariance structure of each component Gaussian: | |
% 'spherical' = single variance parameter for each component: stored as a vector | |
% 'diag' = diagonal matrix for each component: stored as rows of a matrix |
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 [varargout] = rdir(rootdir,varargin) | |
% Lists the files in a directory and its sub directories. | |
% | |
% function [D] = rdir(ROOT,TEST) | |
% | |
% Recursive directory listing. | |
% | |
% ROOT is the directory starting point and includes the | |
% wildcard specification. | |
% The function returns a structure D similar to the one |
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
#!/usr/bin/env python | |
''' | |
Query on GoogleImageSearch and install resulted images by scraping. | |
To use this script install mechanize and BeautifulSoup packages as | |
easy_install mechanize | |
easy_install Beautiful |
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 [] = sample_neg_examples(ROOT_PATH, num_sample, OUTPUT_PATH) | |
SEARCH_PATH = fullfile(ROOT_PATH,'**','*'); | |
SAVE_PATH = 'neg_examples' | |
paths = rdir(SEARCH_PATH); | |
if exist('OUTPUT_PATH','var') | |
SAVE_PATH = OUTPUT_PATH; | |
end |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
if ~exist('vlfeat', 'dir') | |
from = 'http://www.vlfeat.org/download/vlfeat-0.9.13-bin.tar.gz' ; | |
fprintf('Downloading vlfeat from %s\n', from) ; | |
untar(from, 'data') ; | |
movefile('data/vlfeat-0.9.13', 'vlfeat') ; | |
end |
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 [ res ] = ie505_hw1( n,a,b ) | |
%İE505_HW1 Summary of this function goes here | |
% Detailed explanation goes here | |
[~,bins]= hist([a,b],1000); | |
r =unique( round( n*bins)); | |
res = arrayfun(@(x)nchoosek(n,x)*double(1/(2^n)),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
''' | |
split a file into two randomly, line by line. | |
Usage: split.py <input file> <output file 1> <output file 2> [<probability of writing to the first file>] [<random seed>]' | |
''' | |
import csv | |
import sys | |
import random | |
input_file = sys.argv[1] |