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
################################################################################# | |
# | |
# This is FFT library implemented in python. | |
# The Algorithm used is FFT, decimation in time, radix -2 algorithm | |
# can compute FFT of 1-d and 2-d lists, 1-d for 1-d signals , and 2-d for images | |
# | |
# by : Umanga Bista @ [email protected] | |
# | |
################################################################################# |
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
'''Implementation and of K Means Clustering | |
Requires : python 2.7.x, Numpy 1.7.1+''' | |
import numpy as np | |
def kMeans(X, K, maxIters = 10, plot_progress = None): | |
centroids = X[np.random.choice(np.arange(len(X)), K), :] | |
for i in range(maxIters): | |
# Cluster Assignment step | |
C = np.array([np.argmin([np.dot(x_i-y_k, x_i-y_k) for y_k in centroids]) for x_i in 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
'''Implementation and Demostration of Dynamic Time Warping | |
Requires : python 2.7.x, Numpy 1.7.1, Matplotlib, 1.2.1''' | |
from math import * | |
import numpy as np | |
import sys | |
def DTW(A, B, window = sys.maxint, d = lambda x,y: abs(x-y)): | |
# create the cost matrix | |
A, B = np.array(A), np.array(B) |
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
# -*- coding: utf-8 -*- | |
""" | |
Created on Sat May 3 10:21:21 2014 | |
@author: umb | |
""" | |
import numpy as np | |
class GMM: |
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 numpy as np | |
from scipy.io import wavfile | |
from numpy.fft import fft, ifft, fftshift | |
def hamming(M): | |
n = np.arange(M) | |
return 0.54 - 0.46 * np.cos( 2 * np.pi * n / (M - 1)) | |
def hann(M): | |
n = np.arange(M) |
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 numpy as np | |
import pylab as plt | |
''' | |
Performs the Principal Coponent analysis of the Matrix X | |
Matrix must be n * m dimensions | |
where n is # features | |
m is # examples | |
''' | |
def PCA(X, varRetained = 0.95, show = False): |
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 numpy as np | |
def imhist(im): | |
# calculates normalized histogram of an image | |
m, n = im.shape | |
h = [0.0] * 256 | |
for i in range(m): | |
for j in range(n): | |
h[im[i, j]]+=1 | |
return np.array(h)/(m*n) |
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
# -*- coding: utf-8 -*- | |
############################################################################# | |
####### usage : > python PR.py -t 0.01 ################################### | |
####### OR, > python PR.py --thresh=0.01 #################################### | |
import numpy as np | |
from optparse import OptionParser | |
parser = OptionParser() | |
parser.add_option("-t", "--thresh", dest="threshold", help="Threshold for PR") | |
options, args = parser.parse_args() |
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
# -*- coding: utf-8 -*- | |
""" | |
Created on Tue Feb 25 22:19:09 2014 | |
@author: bistaumanga | |
Local Outlier factor implementation in python | |
Implementations are in two version for calculating knn: | |
1. Naive method |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
OlderNewer