├── Discrete_Fourier_Transform ├── DFT.py ├── README.md ├── output.wav └── x.wav ├── GMM ├── GMM.py ├── README.md ├── december.mat ├── december.png ├── june.mat └── june.png ├── ICA ├── ICA.py ├── ICA_plot.png ├── README.md ├── output1.wav ├── output2.wav ├── output3.wav ├── output4.wav ├── x_ica_1.wav ├── x_ica_10.wav ├── x_ica_11.wav ├── x_ica_12.wav ├── x_ica_13.wav ├── x_ica_14.wav ├── x_ica_15.wav ├── x_ica_16.wav ├── x_ica_17.wav ├── x_ica_18.wav ├── x_ica_19.wav ├── x_ica_2.wav ├── x_ica_20.wav ├── x_ica_3.wav ├── x_ica_4.wav ├── x_ica_5.wav ├── x_ica_6.wav ├── x_ica_7.wav ├── x_ica_8.wav └── x_ica_9.wav ├── KMeans └── KMeans.py ├── KNN_Source_Separation ├── KNN_Source_Separation.py ├── README.md ├── output.wav ├── trn.wav ├── trs.wav └── x_nmf.wav ├── Locality_Sensitive_Hashing_KNN ├── Locality_Sensitive_Hashing_KNN.py ├── README.md ├── eeg.mat └── output.pdf ├── NMF ├── NMF.py ├── README.md ├── recovered_file.wav ├── trn.wav ├── trs.wav └── x_nmf.wav ├── PCA ├── PCA.py ├── README.md └── s.wav ├── README.md └── img ├── NMF_Error_function.PNG ├── NMF_Masking_Matrix.PNG ├── NMF_Update_Rules.PNG ├── NMF_eqn1.png ├── NMF_eqn10.png ├── NMF_eqn11.png ├── NMF_eqn2.png ├── NMF_eqn3.png ├── NMF_eqn4.png ├── NMF_eqn5.png ├── NMF_eqn6.png ├── NMF_eqn7.png ├── NMF_eqn8.png ├── NMF_eqn9.png ├── eqn1.png ├── eqn2.png ├── eqn3.png ├── eqn4.png ├── eqn5.png ├── eqn6.png ├── eqn7.png ├── eqn8.png ├── knn_ss_eqn1.png ├── knn_ss_eqn2.png ├── knn_ss_eqn3.png └── knn_ss_eqn4.png /Discrete_Fourier_Transform/DFT.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | @author: arpit 4 | """ 5 | 6 | import os 7 | 8 | os.chdir('D:\IUB\Machine Learning for Signal Processing\Assignment\Assignment-2\data\data') 9 | 10 | import numpy as np 11 | import matplotlib.pyplot as plt 12 | import librosa 13 | from scipy import signal 14 | 15 | #Loading X.wav 16 | x, sr = librosa.load('x.wav', sr=None) 17 | N=1024 18 | 19 | #Declaring F matrix of NxN 20 | matrix_F = np.zeros(shape=(N,N)) 21 | #creating f matrix of size N from 0-N 22 | f=[] 23 | for i in range(0,N): 24 | f.append(i) 25 | f=np.array(f) 26 | f=f.reshape(f.shape[0],1) 27 | 28 | #creating n matrix of size N from 0-N 29 | n=f.T 30 | 31 | #Computing F matrix 32 | matrix_F = np.exp(-2 * 1j * np.pi * f * (n/N)) 33 | 34 | plt.imshow(matrix_F.real) 35 | plt.title('Real part of F matrix') 36 | plt.show() 37 | 38 | plt.imshow(matrix_F.imag) 39 | plt.title('Imaginary part of F matrix') 40 | plt.show() 41 | #Creating Hann's window of size N 42 | hann_window = signal.hann(N) 43 | hann_window = hann_window.reshape(np.shape(hann_window)[0],1) 44 | 45 | #Initialising X matrix 46 | matrix_X = np.zeros((N,1)) 47 | 48 | #Taking sample of N size after every N/2 intervals and then multiplying it with the Hann's window 49 | #After the multiplication, stacking it into the X matrix 50 | for i in range(0,len(x),512): 51 | if np.shape(x[i:N+i])[0] == 1024: 52 | sample_window = x[i:N+i] 53 | sample_window = sample_window.reshape(np.shape(sample_window)[0],1) 54 | intermediate_matrix = np.multiply(sample_window,hann_window) 55 | intermediate_matrix = intermediate_matrix.reshape(np.shape(intermediate_matrix)[0],1) 56 | matrix_X = np.hstack((matrix_X,intermediate_matrix)) 57 | 58 | #Since matrix X has extra column zeros at the start, we remove that extra column 59 | final_matrix_X = matrix_X[:,1:(np.shape(matrix_X)[1]+1)] 60 | #Caluclating the Y matrix 61 | matrix_Y = np.dot(matrix_F,final_matrix_X) 62 | 63 | plt.imshow(np.abs(matrix_Y)) 64 | plt.title('Spectogram') 65 | plt.show() 66 | 67 | #Taking a part of the Y matrix 68 | subset = matrix_Y[:,0:15] 69 | 70 | #Calculating M from samples of Y 71 | M= np.mean(np.absolute(subset),axis=1) 72 | M= M.reshape(np.shape(M)[0],1) 73 | 74 | #Calulating residual magnitudes 75 | subtract = np.absolute(matrix_Y) - M 76 | subtract = subtract.clip(0) 77 | 78 | #Calculating the phase of Y 79 | phase = matrix_Y/np.absolute(matrix_Y) 80 | 81 | mul = np.multiply(phase,subtract) 82 | 83 | #Calculting the inverse DFT 84 | recover_dft = (1/N)* (np.exp(2j * np.pi * f * (n/N))) 85 | 86 | #Checking if F* x F is almost equal to identity matrix or not 87 | I = np.dot(recover_dft,matrix_F) 88 | 89 | #Calculting X dash by multiplying F* with spectogram 90 | X_dash = np.dot(recover_dft, mul) 91 | 92 | X_dash_T = X_dash.T 93 | 94 | #Reversing the procedure applied above. Again taking the samples of size N with an interval of N/2 95 | #Then applying overlap and add to it 96 | #Merging it into a single array and creating the final output without noise 97 | i=1 98 | output = X_dash_T[0,0:1024] 99 | output = output.reshape(np.shape(output)[0],1).T 100 | for i in range(np.shape(X_dash_T)[0]): 101 | first_half = X_dash_T[i-1,512:1024] 102 | first_half = first_half.reshape(np.shape(first_half)[0],1) 103 | second_half = X_dash_T[i,0:512] 104 | second_half = second_half.reshape(np.shape(second_half)[0],1) 105 | addition = first_half.T + second_half.T 106 | output = np.hstack((output,addition)) 107 | 108 | #Taking only the real part of the output file 109 | #Writing the output wav file. 110 | librosa.output.write_wav('output.wav', (output.real).T, sr) -------------------------------------------------------------------------------- /Discrete_Fourier_Transform/README.md: -------------------------------------------------------------------------------- 1 | # Removing white noise 2 | 3 | In this problem, I was given a file 'x.wav' which was contaminated by white noise. Once the file was loaded, I applied Hann's window on the input file. 4 | For Hann's window, I create a window of size N and carry out element wise multiplication with N samples of the input file. This helps in creating the X matrix for calculation of Discrete Fourier Transform (DFT) matrix. After multiplication, we move by N/2 samples again with the size of N samples. 5 | 6 | Once all the samples were covered, I applied DFT on the data matrix, ie Y = FX. From this step I got a spectogram with complex values which in turn have noise at the start and end of the file. -------------------------------------------------------------------------------- /Discrete_Fourier_Transform/output.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/Discrete_Fourier_Transform/output.wav -------------------------------------------------------------------------------- /Discrete_Fourier_Transform/x.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/Discrete_Fourier_Transform/x.wav -------------------------------------------------------------------------------- /GMM/GMM.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | @author: arpit 4 | """ 5 | 6 | import os 7 | 8 | os.chdir('D:\IUB\Machine Learning for Signal Processing\Assignment\Assignment-2\data\data') 9 | 10 | import numpy as np 11 | import scipy.io as sio 12 | 13 | #Reading june.mat and decemeber.mat 14 | june = sio.loadmat('june.mat') 15 | december = sio.loadmat('december.mat') 16 | 17 | june_mat = june['june'] 18 | december_mat = december['december'] 19 | 20 | #Calculating the disparity matrix 21 | disparity_x = december_mat[:,0] - june_mat[:,0] 22 | disparity_x = disparity_x.reshape(disparity_x.shape[0],1) 23 | 24 | #Initialising the mean with values that we got from K-means 25 | mean_mat = np.array([24,41]) 26 | mean_mat = mean_mat.reshape(mean_mat.shape[0],1) 27 | 28 | #Initialising standard deviations randomly 29 | standard_deviation = np.array([0.4,0.5]) 30 | standard_deviation = standard_deviation.reshape(standard_deviation.shape[0],1) 31 | 32 | #Initialising the priors with 0.5 value for both of them 33 | P = np.array([0.5,0.5],dtype=float) 34 | P = P.reshape(np.shape(P)[0],1) 35 | 36 | #Initialising U matrix 37 | matrix_U = np.zeros(shape = (disparity_x.shape[0],2)) 38 | 39 | #Initialising N matrix which will consist of norm values 40 | matrix_N = np.zeros(shape = (disparity_x.shape[0],2)) 41 | 42 | #Initialisng this matrix which will compute the values of U*prior values 43 | U_prior = np.zeros(shape = (disparity_x.shape[0],2)) 44 | 45 | #Initialising old likelihood value with a large negative value 46 | old_loglikelihood = -99999 47 | 48 | #count = 0 49 | while True: 50 | #E-Step 51 | for i in range(0,matrix_N.shape[0]): 52 | for j in range(0,matrix_N.shape[1]): 53 | matrix_N[i][j] = (1 / (np.sqrt(2 * np.pi * standard_deviation[j,0])) * np.exp(-np.square(disparity_x[i,0] - mean_mat[j,0]) / (2 * standard_deviation[j,0]))) 54 | if matrix_N[i][j] == 0: 55 | matrix_N[i][j] = 0.0001 56 | 57 | #Multiplying the priors with U matrix 58 | for i in range(0,2): 59 | U_prior[:,i] = P[i][0] * matrix_N[:,i] 60 | 61 | #Calculating the sum of of the above matrix 62 | deno = np.sum(U_prior,axis = 1) 63 | 64 | #Computing the final U matrix which will be divided by the denominator 65 | for i in range(0,2): 66 | matrix_U[:,i] = U_prior[:,i] * (1/deno) 67 | 68 | #M-Step 69 | matrix_U_trans = matrix_U.T 70 | 71 | sum_mean = np.array([1 / np.sum(matrix_U[:,i]) for i in range(matrix_U.shape[1])]) 72 | sum_mean = sum_mean.reshape(sum_mean.shape[0],1) 73 | #Calculating the means 74 | mean_mat = np.multiply(np.dot(matrix_U.T,disparity_x),sum_mean) 75 | #Calculating the standard deviations 76 | standard_deviation = np.array([np.dot(matrix_U_trans[i,:],np.square((disparity_x - mean_mat[i,0]))) * sum_mean[i][0] for i in range(matrix_U.shape[1])]) 77 | 78 | # count +=1 79 | # print(count) 80 | #Calculating the probabilities 81 | P = np.array([sum(matrix_U[:,i])/np.shape(matrix_U)[0] for i in range(matrix_U.shape[1])]) 82 | P = P.reshape(np.shape(P)[0],1) 83 | 84 | #If thee are any value in the U matrix that is equal to 0 then we change it 85 | #to a small value because log of 0 is inf 86 | for i in range(0,U_prior.shape[0]): 87 | for j in range(0,U_prior.shape[1]): 88 | if U_prior[i][j] == 0: 89 | U_prior[i][j] = 0.01 90 | 91 | #Calculating the likelihood 92 | new_loglikelihood = np.sum(np.log(U_prior)) 93 | #Calculating the difference of new likelihood with the previous one 94 | if np.abs(new_loglikelihood - old_loglikelihood) < 0.01: 95 | break 96 | else: 97 | old_loglikelihood = new_loglikelihood 98 | 99 | print(mean_mat) 100 | #[[20.8432586 ] 101 | # [40.15283258]] -------------------------------------------------------------------------------- /GMM/README.md: -------------------------------------------------------------------------------- 1 | # GMM for Parallax 2 | 3 | Parallax is an effect in which the position or direction of an object appears to differ when viewed from different positions. 4 | For this problem, I was given data about x and y coordinates of stars in the month of June and December. The problem statement came with an assumption that the displacements of stars only occurred on the x-axis. Considering this assumption, I was able to calculate the disparity (amount of oscillation) of all the 2700 stars. 5 | 6 | After plotting a histogram, there were only 2 clusters that were visible, so I first calculated the 2 cluster means values using K-means and from the output of the K-means algorithm, I implemented Expectation-Maximization(EM) algorithm from scratch to identify which stars belonged to our galaxy and also compare why EM for Gaussian Mixture Models(GMM) works better as compared to K-means. -------------------------------------------------------------------------------- /GMM/december.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/GMM/december.mat -------------------------------------------------------------------------------- /GMM/december.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/GMM/december.png -------------------------------------------------------------------------------- /GMM/june.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/GMM/june.mat -------------------------------------------------------------------------------- /GMM/june.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/GMM/june.png -------------------------------------------------------------------------------- /ICA/ICA.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Fri Oct 12 18:46:34 2018 4 | 5 | @author: arpit 6 | """ 7 | 8 | import os 9 | 10 | os.chdir('D:\IUB\Machine Learning for Signal Processing\Assignment\Assignment-3\data') 11 | 12 | 13 | import librosa 14 | import numpy as np 15 | import matplotlib.pyplot as plt 16 | 17 | input = np.zeros((76800,20)) 18 | for i in range(0,20): 19 | s,sr = librosa.load('x_ica_' + str(i+1) +'.wav', sr=None) 20 | input[:,i] = s 21 | 22 | x_matrix = input.T 23 | 24 | 25 | #THis function is used to calculate the singular values 26 | def singular_value_func(eigen_vector,residual_mat): 27 | sd = np.sqrt(np.sum((np.dot(eigen_vector.T,residual_mat)) ** 2)) 28 | 29 | return sd 30 | 31 | #This method is used to calculate the eigenvectors 32 | def power_iteration(matrix,eigenvector,iterations): 33 | 34 | for i in range(iterations): 35 | temp_eigenvector = np.dot(matrix,eigenvector) 36 | 37 | norm_constant = np.sqrt(np.sum(temp_eigenvector ** 2)) #Calculating the normalising constant 38 | computed_eigenvector = temp_eigenvector/norm_constant #Computing the eigen vector 39 | eigenvector = computed_eigenvector 40 | return computed_eigenvector 41 | 42 | #Used to calculate the right basis vectors 43 | def u_matrix_func(residual_mat,eigen_vector,singular_value): 44 | ud = np.dot(residual_mat.T,eigen_vector)/singular_value 45 | shaped_ud = ud.reshape(ud.shape[0],1) 46 | 47 | return shaped_ud 48 | 49 | #Used to calculate V*S*U matrix ie. left singular matrix * singular values * right singular matrix 50 | def intermediate_mat_func(eigenvector,singular_value,u_mat): 51 | itermediate_mat = np.dot(eigenvector,singular_value) 52 | computed_mat = np.dot(itermediate_mat,u_mat.T) 53 | 54 | return computed_mat 55 | 56 | #USed to calculate the residual matrix 57 | def residual_mat_func(matrix,computed_mat): 58 | residual_matrix = matrix - computed_mat 59 | 60 | return residual_matrix 61 | 62 | def covariance(B): 63 | #print(B.shape[1]) 64 | #print(np.shape(B.mean(axis=0))) 65 | A_mean = B - B.mean(axis=1).reshape(B.shape[0],1) 66 | N=float(B.shape[1] -1) 67 | return np.dot(A_mean,A_mean.T) / N 68 | 69 | #This method returns all the 8 eigenvectors 70 | def eigenvectors_func(matrix): 71 | #Calculating all the nececssary values for first eigenvector 72 | S=[] 73 | #Calculating the symmetric covariance matrix 74 | # b_mat = matrix - matrix.mean(axis = 1).reshape(matrix.shape[0],1) 75 | # transpose_mat = b_mat.T 76 | # covariance_mat = np.dot(b_mat,transpose_mat)/(b_mat.shape[1]-1) 77 | covariance_mat = covariance(x_matrix) 78 | #Taking matrix of ones 79 | nrows = np.size(matrix,0) 80 | ones_mat = np.ones((nrows,1)) 81 | 82 | #Calculating the first eigen vector 83 | first_eigenvector = power_iteration(covariance_mat,ones_mat,100) 84 | shaped_first_eigenvector = first_eigenvector.reshape(first_eigenvector.shape[0],1) 85 | 86 | #Calculating singular value 87 | singular_value = singular_value_func(shaped_first_eigenvector,covariance_mat) ## 88 | S.append(singular_value) 89 | #Calculating the right basis vectors 90 | u_matrix = u_matrix_func(covariance_mat,first_eigenvector,singular_value) 91 | 92 | #Calculating V*S*U 93 | computed_mat = intermediate_mat_func(shaped_first_eigenvector,singular_value,u_matrix) 94 | 95 | #Calculating residual matrix 96 | residual_matrix = residual_mat_func(covariance_mat,computed_mat) 97 | 98 | #Stacking the first eigenvector 99 | stack = np.hstack((shaped_first_eigenvector)) 100 | stack = stack.reshape(stack.shape[0],1) 101 | 102 | ##Calculating all the nececssary values for remaining eigenvectors 103 | for i in range(1,20): 104 | if i == 1: 105 | eigen_vector = power_iteration(residual_matrix,shaped_first_eigenvector,100) 106 | else: 107 | eigen_vector = power_iteration(residual_matrix,eigen_vector,100) 108 | stack = np.hstack((stack,eigen_vector)) 109 | singular_value = singular_value_func(eigen_vector,residual_matrix) 110 | u_matrix = u_matrix_func(residual_matrix,eigen_vector,singular_value) 111 | intermediate_mat = intermediate_mat_func(eigen_vector,singular_value,u_matrix) 112 | residual_matrix = residual_mat_func(residual_matrix,intermediate_mat) 113 | S.append(singular_value) 114 | #Returning all the eigenvectors clubbed together 115 | return stack,S 116 | 117 | eigenvectors,S_array = eigenvectors_func(x_matrix) 118 | 119 | #op = np.dot(eigenvectors.T,x_matrix) 120 | 121 | plt.matshow(eigenvectors.T,aspect='auto') 122 | plt.title('Eigenvectors for input matrix' ) 123 | plt.show() 124 | S_array = np.asarray(S_array) 125 | sq_S = np.sqrt(S_array) 126 | Lambda = np.diag(1/np.sqrt(S_array)) 127 | 128 | 129 | Intermediate_W = np.dot(Lambda,eigenvectors.T) 130 | 131 | Whiten_Data = np.dot(Intermediate_W,x_matrix) 132 | 133 | original = covariance(Whiten_Data) 134 | 135 | one_inter = np.dot(Intermediate_W,covariance(x_matrix)) 136 | two_inter = np.dot(np.dot(one_inter,eigenvectors),Lambda) 137 | 138 | i_matrix = np.identity(4) 139 | i_matrix = (x_matrix.shape[1]) * i_matrix 140 | err = [] 141 | W_matrix = np.identity(4) 142 | backup=np.zeros(shape=(4,4)) 143 | count = 0 144 | Y_matrix = np.dot(W_matrix,Whiten_Data[0:4:,]) 145 | while True: 146 | delta_W_matrix = np.dot(i_matrix - np.dot(np.tanh(Y_matrix),(Y_matrix ** 3).T),W_matrix) 147 | W_matrix = W_matrix + (0.000001 * delta_W_matrix) 148 | Y_matrix = np.dot(W_matrix,Whiten_Data[0:4:,]) 149 | count+=1 150 | err.append(np.max(np.abs(backup - delta_W_matrix))) 151 | # if np.all(W_matrix==backup): 152 | # break 153 | # backup = deepcopy(W_matrix) 154 | if(count == 10000): 155 | break 156 | backup = delta_W_matrix 157 | 158 | final_vav = Y_matrix[0] 159 | for i in range(1,4): 160 | final_vav = np.hstack((final_vav,Y_matrix[i])) 161 | 162 | plt.plot(err) 163 | plt.show() 164 | #librosa.output.write_wav('final.wav', final_vav, sr) 165 | librosa.output.write_wav('output1.wav', Y_matrix[0], sr) 166 | librosa.output.write_wav('output2.wav', Y_matrix[1], sr) 167 | librosa.output.write_wav('output3.wav', Y_matrix[2], sr) 168 | librosa.output.write_wav('output4.wav', Y_matrix[3], sr) 169 | 170 | -------------------------------------------------------------------------------- /ICA/ICA_plot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/ICA/ICA_plot.png -------------------------------------------------------------------------------- /ICA/README.md: -------------------------------------------------------------------------------- 1 | # Instantaneous Source Separation 2 | 3 | In this problem, I was given a total of 20 recordings of Jazz music. Each recording has N time domain samples. In this music there are 4 | K unknown number of musical sources played at the same time. The goal of the problem was to find the K different mixing sources and thus separate them from the input files to get a clear audio of the Jazz music. 5 | 6 | After hearing all the recording, I had a feeling that the number of sources were much less than 20, so I first performed PCA with whitening to reduce the number of dimensions. PCA was performed on a matrix of 20 X N dimension. After PCA, I take a look at the eigenvalues to decide on the number of K sources. 7 | 8 | On my whitened/dimension reduced data matrix Z(K X N), I applied Independent Compnent Analysis(ICA). Update rules for ICA used were : 9 | 10 | ![Eqn1](https://github.com/shaharpit809/Machine-Learning-for-Signal-Processing/blob/master/img/eqn1.png) 11 | 12 | where 13 | 14 | ![Eqn2](https://github.com/shaharpit809/Machine-Learning-for-Signal-Processing/blob/master/img/eqn2.png): The ICA unmixing matrix you're estimating \ 15 | ![Eqn3](https://github.com/shaharpit809/Machine-Learning-for-Signal-Processing/blob/master/img/eqn3.png): The K X N source matrix you're estimating \ 16 | ![Eqn4](https://github.com/shaharpit809/Machine-Learning-for-Signal-Processing/blob/master/img/eqn4.png): Whitened/dim reduced version of your input (using PCA) \ 17 | ![Eqn5](https://github.com/shaharpit809/Machine-Learning-for-Signal-Processing/blob/master/img/eqn5.png) \ 18 | ![Eqn6](https://github.com/shaharpit809/Machine-Learning-for-Signal-Processing/blob/master/img/eqn6.png) \ 19 | ![Eqn7](https://github.com/shaharpit809/Machine-Learning-for-Signal-Processing/blob/master/img/eqn7.png): learning rate \ 20 | ![Eqn8](https://github.com/shaharpit809/Machine-Learning-for-Signal-Processing/blob/master/img/eqn8.png): number of samples 21 | 22 | 23 | Once ICA converges, the audio files are separated and clean Jazz music is retained. 24 | -------------------------------------------------------------------------------- /ICA/output1.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/ICA/output1.wav -------------------------------------------------------------------------------- /ICA/output2.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/ICA/output2.wav -------------------------------------------------------------------------------- /ICA/output3.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/ICA/output3.wav -------------------------------------------------------------------------------- /ICA/output4.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/ICA/output4.wav -------------------------------------------------------------------------------- /ICA/x_ica_1.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/ICA/x_ica_1.wav -------------------------------------------------------------------------------- /ICA/x_ica_10.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/ICA/x_ica_10.wav -------------------------------------------------------------------------------- /ICA/x_ica_11.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/ICA/x_ica_11.wav -------------------------------------------------------------------------------- /ICA/x_ica_12.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/ICA/x_ica_12.wav -------------------------------------------------------------------------------- /ICA/x_ica_13.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/ICA/x_ica_13.wav -------------------------------------------------------------------------------- /ICA/x_ica_14.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/ICA/x_ica_14.wav -------------------------------------------------------------------------------- /ICA/x_ica_15.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/ICA/x_ica_15.wav -------------------------------------------------------------------------------- /ICA/x_ica_16.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/ICA/x_ica_16.wav -------------------------------------------------------------------------------- /ICA/x_ica_17.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/ICA/x_ica_17.wav -------------------------------------------------------------------------------- /ICA/x_ica_18.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/ICA/x_ica_18.wav -------------------------------------------------------------------------------- /ICA/x_ica_19.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/ICA/x_ica_19.wav -------------------------------------------------------------------------------- /ICA/x_ica_2.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/ICA/x_ica_2.wav -------------------------------------------------------------------------------- /ICA/x_ica_20.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/ICA/x_ica_20.wav -------------------------------------------------------------------------------- /ICA/x_ica_3.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/ICA/x_ica_3.wav -------------------------------------------------------------------------------- /ICA/x_ica_4.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/ICA/x_ica_4.wav -------------------------------------------------------------------------------- /ICA/x_ica_5.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/ICA/x_ica_5.wav -------------------------------------------------------------------------------- /ICA/x_ica_6.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/ICA/x_ica_6.wav -------------------------------------------------------------------------------- /ICA/x_ica_7.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/ICA/x_ica_7.wav -------------------------------------------------------------------------------- /ICA/x_ica_8.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/ICA/x_ica_8.wav -------------------------------------------------------------------------------- /ICA/x_ica_9.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/ICA/x_ica_9.wav -------------------------------------------------------------------------------- /KMeans/KMeans.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | @author: arpit 4 | """ 5 | 6 | import os 7 | 8 | os.chdir('D:\IUB\Machine Learning for Signal Processing\Assignment\Assignment-2\data\data') 9 | 10 | import numpy as np 11 | import matplotlib.pyplot as plt 12 | import scipy.io as sio 13 | 14 | #Readind .mat files 15 | june = sio.loadmat('june.mat') 16 | december = sio.loadmat('december.mat') 17 | #Taking out hte matrix from the mat file 18 | june_mat = june['june'] 19 | december_mat = december['december'] 20 | #Caluclating the disparity matrix 21 | disparity_x = december_mat[:,0] - june_mat[:,0] 22 | disparity_x = disparity_x.reshape(disparity_x.shape[0],1) 23 | #Plotting the disparity matrix 24 | plt.hist(disparity_x, bins =20) 25 | plt.title('Disparity Histogram') 26 | plt.show() 27 | 28 | #After plotting the historgram, we can se that the 2 means are near 20 and 40 29 | #Therefore initialising the centroids with 20 and 40 30 | old_centroid = np.array([20,40]) 31 | old_centroid = old_centroid.reshape(old_centroid.shape[0],1) 32 | 33 | while True: 34 | #Initialising these varialbles to 0 35 | #Sum_x will store the values from disparty matrix which are near to first mean and same for Sum_y 36 | sum_x = 0 37 | sum_y = 0 38 | #Rhis will keep the count of samples that belong to cluster 1 and 2 respectively 39 | counter_x = 0 40 | counter_y = 0 41 | 42 | #Initialising matrix that will hold the values of distance of each 'X' value from both the centroids 43 | argmin_mat = np.zeros(shape=(disparity_x.shape[0],old_centroid.shape[0])) 44 | 45 | #Initialising membership matrix which will hold the values of membership values of all the X values 46 | #Membership value will determine to which cluster does that point X belong to 47 | #If the value is set to 1 then it will belong to that cluster 48 | membership_matrix = np.zeros(shape=(disparity_x.shape[0],old_centroid.shape[0])) 49 | 50 | for i in range(0,disparity_x.shape[0]): 51 | #Calculating the distane of each X from both the centroids 52 | for j in range(0,old_centroid.shape[0]): 53 | argmin_mat[i][j] = np.square(disparity_x[i][0] - old_centroid[j][0]) 54 | #Distance for which centorid is minimum, membership value will be updated to 1 55 | for k in range(0,old_centroid.shape[0]): 56 | if argmin_mat[i][0] == min(argmin_mat[i][0],argmin_mat[i][1]): 57 | membership_matrix[i][0] = 1 58 | else: 59 | membership_matrix[i][1] = 1 60 | #Grouping all the values of all the 'X' for which the membership is 1 61 | if membership_matrix[i][0] == 1: 62 | sum_x+= disparity_x[i][0] 63 | counter_x+=1 64 | else: 65 | sum_y+= disparity_x[i][0] 66 | counter_y+=1 67 | 68 | #Calculating new mean 69 | new_centroid = np.array([sum_x/counter_x,sum_y/counter_y]) 70 | new_centroid = new_centroid.reshape(new_centroid.shape[0],1) 71 | 72 | #if old and new mean match then the k-means algorithm stops 73 | if np.allclose(new_centroid,old_centroid): 74 | break 75 | else: 76 | old_centroid = new_centroid 77 | 78 | print(new_centroid) 79 | #24.358736 80 | #41.226642 -------------------------------------------------------------------------------- /KNN_Source_Separation/KNN_Source_Separation.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Wed Oct 17 17:07:58 2018 4 | 5 | @author: arpit 6 | """ 7 | 8 | import os 9 | 10 | os.chdir('D:\IUB\Machine Learning for Signal Processing\Assignment\Assignment-3\data') 11 | 12 | import numpy as np 13 | import matplotlib.pyplot as plt 14 | import librosa 15 | from scipy import signal 16 | 17 | trs, sr = librosa.load('trs.wav', sr=None) 18 | trn, sr = librosa.load('trn.wav', sr=None) 19 | x_nmf, sr = librosa.load('x_nmf.wav', sr=None) 20 | 21 | N=1024 22 | 23 | def STFT(x,N): 24 | 25 | #Declaring F matrix of NxN 26 | matrix_F = np.zeros(shape=(N,N)) 27 | #creating f matrix of size N from 0-N 28 | f=[] 29 | for i in range(0,N): 30 | f.append(i) 31 | f=np.array(f) 32 | f=f.reshape(f.shape[0],1) 33 | 34 | #creating n matrix of size N from 0-N 35 | n=f.T 36 | 37 | #Computing F matrix 38 | matrix_F = np.exp(-2 * 1j * np.pi * f * (n/N)) 39 | 40 | plt.imshow(matrix_F.real) 41 | plt.title('Real part of F matrix') 42 | plt.show() 43 | 44 | plt.imshow(matrix_F.imag) 45 | plt.title('Imaginary part of F matrix') 46 | plt.show() 47 | #Creating Hann's window of size N 48 | hann_window = signal.hann(N) 49 | hann_window = hann_window.reshape(np.shape(hann_window)[0],1) 50 | 51 | #Initialising X matrix 52 | matrix_X = np.zeros((N,1)) 53 | 54 | #Taking sample of N size after every N/2 intervals and then multiplying it with the Hann's window 55 | #After the multiplication, stacking it into the X matrix 56 | for i in range(0,len(x),512): 57 | if np.shape(x[i:N+i])[0] == 1024: 58 | sample_window = x[i:N+i] 59 | sample_window = sample_window.reshape(np.shape(sample_window)[0],1) 60 | intermediate_matrix = np.multiply(sample_window,hann_window) 61 | intermediate_matrix = intermediate_matrix.reshape(np.shape(intermediate_matrix)[0],1) 62 | matrix_X = np.hstack((matrix_X,intermediate_matrix)) 63 | 64 | #Since matrix X has extra column zeros at the start, we remove that extra column 65 | final_matrix_X = matrix_X[:,1:(np.shape(matrix_X)[1]+1)] 66 | #Caluclating the Y matrix 67 | matrix_Y = np.dot(matrix_F,final_matrix_X) 68 | 69 | #Only taking 513 rows from 1024 70 | X = matrix_Y[0:513,:] 71 | S = np.abs(X) 72 | return X,S 73 | 74 | conj_trs,magnitude_matrix_trs = STFT(trs,N) 75 | 76 | conj_trn,magnitude_matrix_trn = STFT(trn,N) 77 | 78 | conj_x_nmf,magnitude_matrix_x_nmf = STFT(x_nmf,N) 79 | 80 | G = conj_trs + conj_trn 81 | 82 | G_abs = np.abs(G) 83 | 84 | B = np.zeros(shape = (G.shape[0],G.shape[1])) 85 | 86 | for i in range(0,G.shape[0]): 87 | for j in range(0,G.shape[1]): 88 | if(magnitude_matrix_trs[i][j] > magnitude_matrix_trn[i][j]): 89 | B[i][j] = 1 90 | 91 | def KNN(G,Y,B,k): 92 | Dist = np.zeros(shape = (Y.shape[1] , G.shape[1])) 93 | for i in range(Y.shape[1]):#131 94 | for j in range(G.shape[1]):#987 95 | diff = np.sum(np.power(Y[:,i] - G[:,j] , 2)) 96 | distance = np.sqrt(diff) 97 | Dist[i][j] = distance 98 | 99 | sorted_distance = Dist.argsort() 100 | 101 | k_index = sorted_distance[:,0:k] 102 | 103 | reconstruct_matrix = np.zeros((Y.shape[1],Y.shape[0])) 104 | for i in range(0,k_index.shape[0]): 105 | B_all = np.zeros((513,1)) 106 | for j in range(0,k_index.shape[1]): 107 | col_index = int(k_index[i][j]) 108 | median_value = B[:,col_index] 109 | median_value = median_value.reshape((median_value.shape[0],1)) 110 | B_all = np.hstack((B_all,median_value)) 111 | B_all = B_all[:,1:] 112 | median_k = np.median(B_all, axis = 1) 113 | reconstruct_matrix[i,:] = median_k 114 | 115 | r_T = reconstruct_matrix.T 116 | 117 | S_test = np.multiply(r_T,conj_x_nmf) 118 | 119 | conj_Stest = np.conjugate(S_test) 120 | 121 | for i in range(511,0,-1): 122 | S_test = np.vstack((S_test,conj_Stest[i])) 123 | 124 | return S_test 125 | 126 | def IDFT(x,N): 127 | 128 | f=[] 129 | for i in range(0,N): 130 | f.append(i) 131 | f=np.array(f) 132 | f=f.reshape(f.shape[0],1) 133 | n=f.T 134 | 135 | recover_dft = (1/N)* (np.exp(2j * np.pi * f * (n/N))) 136 | 137 | s_dash1test = np.dot(recover_dft,x) 138 | 139 | s_dash_T = s_dash1test.T 140 | i=1 141 | output = s_dash_T[0,0:1024] 142 | output = output.reshape(np.shape(output)[0],1).T 143 | for i in range(np.shape(s_dash_T)[0]): 144 | first_half = s_dash_T[i-1,512:1024] 145 | first_half = first_half.reshape(np.shape(first_half)[0],1) 146 | second_half = s_dash_T[i,0:512] 147 | second_half = second_half.reshape(np.shape(second_half)[0],1) 148 | addition = first_half.T + second_half.T 149 | output = np.hstack((output,addition)) 150 | 151 | return output 152 | 153 | S_test = KNN(G_abs,magnitude_matrix_x_nmf,B,15) 154 | output = IDFT(S_test,N) 155 | librosa.output.write_wav('output.wav', (output.real).T, sr) -------------------------------------------------------------------------------- /KNN_Source_Separation/README.md: -------------------------------------------------------------------------------- 1 | # KNN Source Separation 2 | 3 | In this problem, I was given 3 audio files such as: \ 4 | * trs.wav - Clean signal of the speaker 5 | * trn.wav - Noise signal 6 | * x_nmf.wav - Test signal consisting of speaker signal with noise 7 | 8 | After converting all the files in time-frequency, I created a masking matrix called Ideal Binary Masks (IBM) such that : 9 | ![](https://github.com/shaharpit809/Machine-Learning-for-Signal-Processing/blob/master/img/knn_ss_eqn1.png) 10 | 11 | By using the nearest neighbor indices, I collected the IBM vectors from 12 | ![](https://github.com/shaharpit809/Machine-Learning-for-Signal-Processing/blob/master/img/knn_ss_eqn2.png) 13 | 14 | If the t-th frame belonged to sound signal then there should have been more number of sound neighbours as compared to noise. So I created anothe matrix 15 | ![](https://github.com/shaharpit809/Machine-Learning-for-Signal-Processing/blob/master/img/knn_ss_eqn3.png) 16 | which 1 if 1 was the majority and vice-versa. 17 | 18 | ![](https://github.com/shaharpit809/Machine-Learning-for-Signal-Processing/blob/master/img/knn_ss_eqn4.png) 19 | 20 | I then use the above matrix 21 | ![](https://github.com/shaharpit809/Machine-Learning-for-Signal-Processing/blob/master/img/knn_ss_eqn3.png) 22 | to suppress the noise and recover a clear audio file consisting of only speaker's signal. 23 | -------------------------------------------------------------------------------- /KNN_Source_Separation/output.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/KNN_Source_Separation/output.wav -------------------------------------------------------------------------------- /KNN_Source_Separation/trn.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/KNN_Source_Separation/trn.wav -------------------------------------------------------------------------------- /KNN_Source_Separation/trs.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/KNN_Source_Separation/trs.wav -------------------------------------------------------------------------------- /KNN_Source_Separation/x_nmf.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/KNN_Source_Separation/x_nmf.wav -------------------------------------------------------------------------------- /Locality_Sensitive_Hashing_KNN/Locality_Sensitive_Hashing_KNN.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Fri Oct 19 18:55:55 2018 4 | 5 | @author: arpit 6 | """ 7 | 8 | import os 9 | 10 | os.chdir('D:\IUB\Machine Learning for Signal Processing\Assignment\Assignment-3\data') 11 | 12 | import numpy as np 13 | import scipy.io as sio 14 | 15 | eeg = sio.loadmat('eeg.mat') 16 | 17 | x_train = eeg['x_train'] 18 | x_test = eeg['x_te'] 19 | 20 | y_train = eeg['y_train'] 21 | y_test = eeg['y_te'] 22 | 23 | N = 64 24 | l = 110 25 | k = 21 26 | def STFT(N,x): 27 | 28 | blackman_window = np.blackman(N) 29 | blackman_window = blackman_window.reshape(np.shape(blackman_window)[0],1) 30 | 31 | #Taking sample of N size after every N/2 intervals and then multiplying it with the Hann's window 32 | #After the multiplication, stacking it into the X matrix 33 | for i in range(0,x.shape[2]): 34 | h = np.array([1000000]) 35 | h = h.reshape((h.shape[0],1)) 36 | for j in range(0,x.shape[1]): 37 | matrix_X = np.zeros((N,1)) 38 | something1 = x[:,j] 39 | something2 = something1[:,i] 40 | for k in range(0,x.shape[0],48): 41 | if np.shape(something2[k:N+k])[0] == 64: 42 | sample_window = something2[k:N+k] 43 | sample_window = sample_window.reshape(np.shape(sample_window)[0],1) 44 | intermediate_matrix = np.multiply(sample_window,blackman_window) 45 | intermediate_matrix = intermediate_matrix.reshape(np.shape(intermediate_matrix)[0],1) 46 | matrix_X = np.hstack((matrix_X,intermediate_matrix)) 47 | final_matrix_X = matrix_X[:,1:] 48 | part_of_matrix_X = final_matrix_X[3:8,:] 49 | 50 | for l in range(0,5): 51 | inter = part_of_matrix_X[l] 52 | inter = inter.reshape((inter.shape[0],1)) 53 | h = np.vstack((h,inter)) 54 | 55 | if(h[0] == 1000000): 56 | h = h[1:] 57 | 58 | if i == 0: 59 | final = np.zeros((len(h),1)) 60 | final = np.hstack((final,h)) 61 | else: 62 | final = np.hstack((final,h)) 63 | 64 | final = final[:,1:] 65 | return final 66 | 67 | def calculating_A(l,M): 68 | 69 | np.random.seed(2) 70 | A = np.random.uniform(-1,1,l) 71 | for i in range(len(M) - 1): 72 | A = np.vstack((A,np.random.uniform(-1,1,l))) 73 | 74 | sum_A = [sum(A[i]) for i in range(len(M))] 75 | sum_A = np.array(sum_A) 76 | inv_sum_A = 1/sum_A 77 | 78 | B = A * inv_sum_A[:, np.newaxis] 79 | B_T = B.T 80 | 81 | return B_T 82 | 83 | def calculating_Y(A,Z): 84 | Y = np.dot(A,Z) 85 | 86 | Y_sign = np.sign(Y) 87 | 88 | return Y,Y_sign 89 | 90 | def hamming(s1,s2): 91 | dist = np.count_nonzero(s1 != s2) 92 | return dist 93 | 94 | def distance(Y,Y_test): 95 | 96 | distance = np.zeros((28,112)) 97 | for i in range(distance.shape[0]): 98 | for j in range(distance.shape[1]): 99 | distance[i][j] = hamming(Y_test[:,i],Y[:,j]) 100 | 101 | sorted_distance = distance.argsort() 102 | final_index = np.zeros((Y_test.shape[1],Y.shape[1])) 103 | for i in range(Y_test.shape[1]): 104 | for j in range(Y.shape[1]): 105 | index = sorted_distance[i][j] 106 | final_index[i][j] = y_train[index,0] 107 | 108 | return final_index 109 | 110 | Z = STFT(N,x_train) 111 | 112 | Z_test = STFT(N,x_test) 113 | list_i = [] 114 | list_j = [] 115 | list_acc = [] 116 | for i in range(10,110,5): 117 | for j in range(3,21,2): 118 | l = i 119 | k = j 120 | 121 | A = calculating_A(l,Z) 122 | 123 | Y,Y_sign = calculating_Y(A,Z) 124 | 125 | Y_test,Y_test_sign = calculating_Y(A,Z_test) 126 | 127 | index_mat = distance(Y_sign,Y_test_sign) 128 | k_index_mat = index_mat[:,0:k] 129 | 130 | final_y_test = np.zeros((y_test.shape[0],1)) 131 | for p in range(0,28): 132 | final_y_test[p] = np.median(k_index_mat[p,:]) 133 | 134 | count = 0 135 | for p in range(0,28): 136 | if final_y_test[p] == y_test[p]: 137 | count+=1 138 | 139 | accuracy = count/28 140 | 141 | list_i.append(i) 142 | 143 | list_j.append(j) 144 | 145 | list_acc.append(accuracy) 146 | # print('Accuracy for K=' + str(k) +' and L=' + str(l) + ' is ' +str(count/28)) 147 | 148 | list_i = np.array(list_i) 149 | list_i = list_i.reshape((list_i.shape[0],1)) 150 | 151 | list_j = np.array(list_j) 152 | list_j = list_j.reshape((list_j.shape[0],1)) 153 | 154 | list_acc = np.array(list_acc) 155 | list_acc = list_acc.reshape((list_acc.shape[0],1)) 156 | 157 | intermediate_stack = np.hstack((list_i,list_j)) 158 | final_stack = np.hstack((intermediate_stack,list_acc)) 159 | 160 | sorted_stack = final_stack[final_stack[:,2].argsort()] 161 | 162 | reverse_stack = sorted_stack[::-1] 163 | 164 | partial_reverse_stack = reverse_stack[0:20] 165 | 166 | for i in range(len(partial_reverse_stack)): 167 | print('Accuracy for L=' + str(reverse_stack[i,0]) + ' and K=' + str(reverse_stack[i,1]) + ' is ' + str(reverse_stack[i,2])) -------------------------------------------------------------------------------- /Locality_Sensitive_Hashing_KNN/README.md: -------------------------------------------------------------------------------- 1 | # Motor Imagery using Locality Sensitive Hasing and KNN 2 | 3 | In this problem, I was given Electroencephalography (eeg) readings in 'eeg.mat'. 4 | 5 | First I performed locality sensitive hasing to convert the data into 1 and -1. 6 | 7 | After which I performed KNN to properly classify the test samples. -------------------------------------------------------------------------------- /Locality_Sensitive_Hashing_KNN/eeg.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/Locality_Sensitive_Hashing_KNN/eeg.mat -------------------------------------------------------------------------------- /Locality_Sensitive_Hashing_KNN/output.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/Locality_Sensitive_Hashing_KNN/output.pdf -------------------------------------------------------------------------------- /NMF/NMF.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Mon Oct 15 17:00:58 2018 4 | 5 | @author: arpit 6 | """ 7 | 8 | import os 9 | 10 | os.chdir('D:\IUB\Machine Learning for Signal Processing\Assignment\Assignment-3\data') 11 | 12 | import numpy as np 13 | import matplotlib.pyplot as plt 14 | import librosa 15 | from scipy import signal 16 | 17 | trs, sr = librosa.load('trs.wav', sr=None) 18 | trn, sr = librosa.load('trn.wav', sr=None) 19 | x_nmf, sr = librosa.load('x_nmf.wav', sr=None) 20 | 21 | N=1024 22 | 23 | def STFT(x,N): 24 | #Declaring F matrix of NxN 25 | matrix_F = np.zeros(shape=(N,N)) 26 | #creating f matrix of size N from 0-N 27 | f=[] 28 | for i in range(0,N): 29 | f.append(i) 30 | f=np.array(f) 31 | f=f.reshape(f.shape[0],1) 32 | 33 | #creating n matrix of size N from 0-N 34 | n=f.T 35 | 36 | #Computing F matrix 37 | matrix_F = np.exp(-2 * 1j * np.pi * f * (n/N)) 38 | 39 | plt.imshow(matrix_F.real) 40 | plt.title('Real part of F matrix') 41 | plt.show() 42 | 43 | plt.imshow(matrix_F.imag) 44 | plt.title('Imaginary part of F matrix') 45 | plt.show() 46 | #Creating Hann's window of size N 47 | hann_window = signal.hann(N) 48 | hann_window = hann_window.reshape(np.shape(hann_window)[0],1) 49 | 50 | #Initialising X matrix 51 | matrix_X = np.zeros((N,1)) 52 | 53 | #Taking sample of N size after every N/2 intervals and then multiplying it with the Hann's window 54 | #After the multiplication, stacking it into the X matrix 55 | for i in range(0,len(x),512): 56 | if np.shape(x[i:N+i])[0] == 1024: 57 | sample_window = x[i:N+i] 58 | sample_window = sample_window.reshape(np.shape(sample_window)[0],1) 59 | intermediate_matrix = np.multiply(sample_window,hann_window) 60 | intermediate_matrix = intermediate_matrix.reshape(np.shape(intermediate_matrix)[0],1) 61 | matrix_X = np.hstack((matrix_X,intermediate_matrix)) 62 | 63 | #Since matrix X has extra column zeros at the start, we remove that extra column 64 | final_matrix_X = matrix_X[:,1:(np.shape(matrix_X)[1]+1)] 65 | #Caluclating the Y matrix 66 | matrix_Y = np.dot(matrix_F,final_matrix_X) 67 | 68 | #Only taking 513 rows from 1024 69 | X = matrix_Y[0:513,:] 70 | S = np.abs(X) 71 | return X,S 72 | 73 | 74 | def update_W(S,W,H,ones_matrix): 75 | num_W = np.dot(np.divide(S , np.dot(W , H)) , H.T) 76 | den_W = np.dot(ones_matrix , H.T) 77 | W = np.multiply(W , np.divide(num_W , den_W)) 78 | return W 79 | 80 | def NMF(S,W,flag): 81 | H = np.random.uniform(0,1,S.shape[1]) 82 | for i in range(W.shape[1] - 1): 83 | H = np.vstack((H,np.random.uniform(0,1,S.shape[1]))) 84 | 85 | ones_matrix = np.ones(shape = (S.shape[0],S.shape[1])) 86 | 87 | count = 0 88 | backup_error = 0 89 | app = 0 90 | while True: 91 | W[W == 0] = 0 + 1e-20 92 | H[H == 0] = 0 + 1e-20 93 | 94 | if flag: 95 | W = update_W(S,W,H,ones_matrix) 96 | 97 | num_H = np.dot(W.T , np.divide(S , np.dot(W , H))) 98 | den_H = np.dot(W.T , ones_matrix) 99 | H = np.multiply(H , np.divide(num_H , den_H)) 100 | 101 | count+=1 102 | 103 | prod = np.dot(W,H) 104 | 105 | error = np.sum((S * np.log(S / prod)) - S + prod) 106 | app = np.append(app , error) 107 | if backup_error != 0: 108 | if (backup_error - error) < 0.01: 109 | print(error - backup_error) 110 | break 111 | backup_error = error 112 | plt.plot(app[1:]) 113 | print(count) 114 | 115 | return W,H 116 | 117 | W = np.random.uniform(0,1,30) 118 | for i in range(512): 119 | W = np.vstack((W,np.random.uniform(0,1,30))) 120 | 121 | conj_trs,magnitude_matrix_trs = STFT(trs,N) 122 | W_S,H_S = NMF(magnitude_matrix_trs,W,True) 123 | 124 | conj_trn,magnitude_matrix_trn = STFT(trn,N) 125 | W_N,H_N = NMF(magnitude_matrix_trn,W,True) 126 | 127 | WS_WN = np.hstack((W_S,W_N)) 128 | 129 | conj_x_nmf,magnitude_matrix_x_nmf = STFT(x_nmf,N) 130 | W_SN, H_SN = NMF(magnitude_matrix_x_nmf,WS_WN,False) 131 | 132 | mask = np.divide(np.dot(W_S ,H_SN[0:30]) ,np.dot(W_SN ,H_SN)) 133 | 134 | s_dash = np.multiply(mask , conj_x_nmf) 135 | 136 | conj = np.conjugate(s_dash) 137 | 138 | #s_dash = np.vstack((s_dash,conj)) 139 | for i in range(511,0,-1): 140 | s_dash = np.vstack((s_dash,conj[i])) 141 | 142 | def IDFT(x,N): 143 | 144 | f=[] 145 | for i in range(0,N): 146 | f.append(i) 147 | f=np.array(f) 148 | f=f.reshape(f.shape[0],1) 149 | 150 | #creating n matrix of size N from 0-N 151 | n=f.T 152 | 153 | recover_dft = (1/N)* (np.exp(2j * np.pi * f * (n/N))) 154 | 155 | s_dash = np.dot(recover_dft,x) 156 | s_dash_T = s_dash.T 157 | i=1 158 | output = s_dash_T[0,0:1024] 159 | output = output.reshape(np.shape(output)[0],1).T 160 | for i in range(np.shape(s_dash_T)[0]): 161 | first_half = s_dash_T[i-1,512:1024] 162 | first_half = first_half.reshape(np.shape(first_half)[0],1) 163 | second_half = s_dash_T[i,0:512] 164 | second_half = second_half.reshape(np.shape(second_half)[0],1) 165 | addition = first_half.T + second_half.T 166 | output = np.hstack((output,addition)) 167 | 168 | return output 169 | 170 | output = IDFT(s_dash,N) 171 | librosa.output.write_wav('recovered_file.wav', (output.real).T, sr) 172 | -------------------------------------------------------------------------------- /NMF/README.md: -------------------------------------------------------------------------------- 1 | # Single-channel Source Separation using NMF 2 | 3 | In this problem, I was given an audio file named 'trs.wav' which is a speech signal of a speaker. First I perform STFT to convert it into time-frequency domain. \ 4 | 5 | For STFT, I take a frame of 1024 samples with 50% overlap and then apply Hann's window which leaves me with a complexed-value matrix. This matrix has complex conjugacy which means that bottom half of the spectrogram is a mirrored version of the upper half. This is because of the fact that 6 | ![](https://github.com/shaharpit809/Machine-Learning-for-Signal-Processing/blob/master/img/NMF_eqn1.png) (the real part) and 7 | ![](https://github.com/shaharpit809/Machine-Learning-for-Signal-Processing/blob/master/img/NMF_eqn2.png) (the imaginary part). 8 | So I only took 513 samples because the other half could be easy recovered during inverse-DFT. 9 | 10 | After taking magnitude of the input file, I apply Non-negative matrix factorization (NMF) on S (magnitude of input file) such that \ 11 | ![](https://github.com/shaharpit809/Machine-Learning-for-Signal-Processing/blob/master/img/NMF_eqn3.png) \ 12 | where 13 | ![](https://github.com/shaharpit809/Machine-Learning-for-Signal-Processing/blob/master/img/NMF_eqn4.png) 14 | is a set of basis vectors and 15 | ![](https://github.com/shaharpit809/Machine-Learning-for-Signal-Processing/blob/master/img/NMF_eqn5.png) 16 | where 17 | ![](https://github.com/shaharpit809/Machine-Learning-for-Signal-Processing/blob/master/img/NMF_eqn6.png) 18 | is a set of nonnegative real numbers. 19 | 20 | For updating 21 | ![](https://github.com/shaharpit809/Machine-Learning-for-Signal-Processing/blob/master/img/NMF_eqn4.png) 22 | and 23 | ![](https://github.com/shaharpit809/Machine-Learning-for-Signal-Processing/blob/master/img/NMF_eqn7.png), 24 | I use the below given update rules. 25 | 26 | ![NMF Update Rules](https://github.com/shaharpit809/Machine-Learning-for-Signal-Processing/blob/master/img/NMF_Update_Rules.PNG) 27 | 28 | The error function for NMF is given by : 29 | 30 | ![NMF Error Function](https://github.com/shaharpit809/Machine-Learning-for-Signal-Processing/blob/master/img/NMF_Error_function.PNG) 31 | 32 | Similarly, I take another audio file 'trn.wav' which only consists of noise and perform the above steps to get 33 | ![](https://github.com/shaharpit809/Machine-Learning-for-Signal-Processing/blob/master/img/NMF_eqn8.png) 34 | 35 | Once training on both clean and noisy signal was completed, I took a test audio file 'x_nmf.wav' to check how the model performed in separating the source. Since basis vectors were already learnt in the training step, let 36 | ![](https://github.com/shaharpit809/Machine-Learning-for-Signal-Processing/blob/master/img/NMF_eqn9.png). 37 | Now since the activation matrix is ready, only activation of these basis vectors needs to be learnt. 38 | 39 | Once both 40 | ![](https://github.com/shaharpit809/Machine-Learning-for-Signal-Processing/blob/master/img/eqn2.png) 41 | and 42 | ![](https://github.com/shaharpit809/Machine-Learning-for-Signal-Processing/blob/master/img/NMF_eqn10.png) 43 | were ready, a masking matrix could be created from them using the below given formula : 44 | 45 | ![NMF Masking Matrix](https://github.com/shaharpit809/Machine-Learning-for-Signal-Processing/blob/master/img/NMF_Masking_Matrix.PNG) 46 | 47 | The above matrix 48 | ![](https://github.com/shaharpit809/Machine-Learning-for-Signal-Processing/blob/master/img/NMF_eqn11.png) 49 | can then be used to recover the speech source. 50 | -------------------------------------------------------------------------------- /NMF/recovered_file.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/NMF/recovered_file.wav -------------------------------------------------------------------------------- /NMF/trn.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/NMF/trn.wav -------------------------------------------------------------------------------- /NMF/trs.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/NMF/trs.wav -------------------------------------------------------------------------------- /NMF/x_nmf.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/NMF/x_nmf.wav -------------------------------------------------------------------------------- /PCA/PCA.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | @author: arpit 4 | """ 5 | 6 | import os 7 | 8 | os.chdir('D:\IUB\Machine Learning for Signal Processing\Assignment\Assignment-2\data\data') 9 | 10 | 11 | import librosa 12 | import numpy as np 13 | import random 14 | import matplotlib.pyplot as plt 15 | 16 | #Loading the s.wav file 17 | s,sr = librosa.load('s.wav', sr=None) 18 | 19 | #This function takes the number of sample as input and creates a Nx8 matrix 20 | #After randomly selecting 8 consecutive samples, N times, we return transpose(8*N) of the matrix created 21 | def mainfunc(N): 22 | print(N) 23 | matrix = np.zeros(shape=(N,8)) 24 | 25 | for i in range(0,N): 26 | random_num = random.choice(s) 27 | for j in range(0, len(s)): 28 | if s[j] == random_num: 29 | index = j 30 | break 31 | for k in range(0,8): 32 | matrix[i][k] = s[index + k] 33 | 34 | return matrix.T 35 | 36 | #THis function is used to calculate the singular values 37 | def singular_value_func(eigen_vector,residual_mat): 38 | sd = np.sqrt(np.sum((np.dot(eigen_vector.T,residual_mat)) ** 2)) 39 | shaped_sd = sd.reshape(1,1) 40 | 41 | return shaped_sd 42 | 43 | #This method is used to calculate the eigenvectors 44 | def power_iteration(matrix,eigenvector,iterations): 45 | 46 | for i in range(iterations): 47 | temp_eigenvector = np.dot(matrix,eigenvector) 48 | 49 | norm_constant = np.sqrt(np.sum(temp_eigenvector ** 2)) #Calculating the normalising constant 50 | computed_eigenvector = temp_eigenvector/norm_constant #Computing the eigen vector 51 | 52 | return computed_eigenvector 53 | 54 | #Used to calculate the right basis vectors 55 | def u_matrix_func(residual_mat,eigen_vector,singular_value): 56 | ud = np.dot(residual_mat.T,eigen_vector)/singular_value 57 | shaped_ud = ud.reshape(ud.shape[0],1) 58 | 59 | return shaped_ud 60 | 61 | #Used to calculate V*S*U matrix ie. left singular matrix * singular values * right singular matrix 62 | def intermediate_mat_func(eigenvector,singular_value,u_mat): 63 | itermediate_mat = np.dot(eigenvector,singular_value) 64 | computed_mat = np.dot(itermediate_mat,u_mat.T) 65 | 66 | return computed_mat 67 | 68 | #USed to calculate the residual matrix 69 | def residual_mat_func(matrix,computed_mat): 70 | residual_matrix = matrix - computed_mat 71 | 72 | return residual_matrix 73 | 74 | #This method returns all the 8 eigenvectors 75 | def eigenvectors_func(matrix): 76 | #Calculating all the nececssary values for first eigenvector 77 | 78 | #Calculating the symmetric covariance matrix 79 | b_mat = matrix - matrix.mean(axis = 1).reshape(matrix.shape[0],1) 80 | transpose_mat = b_mat.T 81 | covariance_mat = np.dot(b_mat,transpose_mat)/(b_mat.shape[1]-1) 82 | 83 | #Taking matrix of ones 84 | nrows = np.size(matrix,0) 85 | ones_mat = np.ones((nrows,1)) 86 | 87 | #Calculating the first eigen vector 88 | first_eigenvector = power_iteration(covariance_mat,ones_mat,100) 89 | shaped_first_eigenvector = first_eigenvector.reshape(first_eigenvector.shape[0],1) 90 | 91 | #Calculating singular value 92 | singular_value = singular_value_func(shaped_first_eigenvector,covariance_mat) ## 93 | 94 | #Calculating the right basis vectors 95 | u_matrix = u_matrix_func(covariance_mat,first_eigenvector,singular_value) 96 | 97 | #Calculating V*S*U 98 | computed_mat = intermediate_mat_func(shaped_first_eigenvector,singular_value,u_matrix) 99 | 100 | #Calculating residual matrix 101 | residual_matrix = residual_mat_func(covariance_mat,computed_mat) 102 | 103 | #Stacking the first eigenvector 104 | stack = np.hstack((shaped_first_eigenvector)) 105 | stack = stack.reshape(stack.shape[0],1) 106 | 107 | ##Calculating all the nececssary values for remaining eigenvectors 108 | for i in range(1,8): 109 | if i == 1: 110 | eigen_vector = power_iteration(residual_matrix,shaped_first_eigenvector,100) 111 | else: 112 | eigen_vector = power_iteration(residual_matrix,eigen_vector,100) 113 | stack = np.hstack((stack,eigen_vector)) 114 | singular_value = singular_value_func(eigen_vector,residual_matrix) 115 | u_matrix = u_matrix_func(residual_matrix,eigen_vector,singular_value) 116 | intermediate_mat = intermediate_mat_func(eigen_vector,singular_value,u_matrix) 117 | residual_matrix = residual_mat_func(residual_matrix,intermediate_mat) 118 | 119 | #Returning all the eigenvectors clubbed together 120 | return stack 121 | 122 | #Selecting 10 samples and then plotting 123 | data_matrix = mainfunc(10) 124 | eigenvectors = eigenvectors_func(data_matrix) 125 | 126 | plt.matshow(eigenvectors.T,aspect='auto') 127 | plt.title('Eigenvectors for 10 samples' ) 128 | plt.show() 129 | 130 | #Selecting 100 samples and then plotting 131 | data_matrix = mainfunc(100) 132 | eigenvectors = eigenvectors_func(data_matrix) 133 | 134 | plt.matshow(eigenvectors.T,aspect='auto') 135 | plt.title('Eigenvectors for 100 samples' ) 136 | plt.show() 137 | 138 | #Selecting 1000 samples and then plotting 139 | data_matrix = mainfunc(1000) 140 | eigenvectors = eigenvectors_func(data_matrix) 141 | 142 | plt.matshow(eigenvectors.T,aspect='auto') 143 | plt.title('Eigenvectors for 1000 samples' ) 144 | plt.show() -------------------------------------------------------------------------------- /PCA/README.md: -------------------------------------------------------------------------------- 1 | # PCA 2 | 3 | Implemetend Principal Component Analysis (PCA) from scratch on 's.wav' as input. Experimented with different samples sizes to check the performance of PCA with small and large amount of samples. Identified factors such as variance and sample size to prove why PCA performs better than Discrete Cosine Transform (DCT) -------------------------------------------------------------------------------- /PCA/s.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/PCA/s.wav -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Machine-Learning-for-Signal-Processing 2 | This repository consists of work done in Machine Learning and Signal Processing. 3 | 4 | ## Machine Learning Stage consists of: 5 | * K-means 6 | * Expectation Maximization 7 | * Principal Component Analysis (PCA) 8 | * Mixture Models 9 | * Hidden Markov Models (HMM) 10 | * Graphical Models * Gibbs Sampling 11 | * Manifold Learning 12 | * Hashing 13 | 14 | ## Signal Processing Stage consists of: 15 | * Source Separation 16 | * Stereo Matching 17 | * Audio Processing 18 | * Fourier Transform 19 | * Brain Waves 20 | * Keyword Detection 21 | * Sentiment Analysis 22 | * Music Signal Processing 23 | * Image Segmentation 24 | -------------------------------------------------------------------------------- /img/NMF_Error_function.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/img/NMF_Error_function.PNG -------------------------------------------------------------------------------- /img/NMF_Masking_Matrix.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/img/NMF_Masking_Matrix.PNG -------------------------------------------------------------------------------- /img/NMF_Update_Rules.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/img/NMF_Update_Rules.PNG -------------------------------------------------------------------------------- /img/NMF_eqn1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/img/NMF_eqn1.png -------------------------------------------------------------------------------- /img/NMF_eqn10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/img/NMF_eqn10.png -------------------------------------------------------------------------------- /img/NMF_eqn11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/img/NMF_eqn11.png -------------------------------------------------------------------------------- /img/NMF_eqn2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/img/NMF_eqn2.png -------------------------------------------------------------------------------- /img/NMF_eqn3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/img/NMF_eqn3.png -------------------------------------------------------------------------------- /img/NMF_eqn4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/img/NMF_eqn4.png -------------------------------------------------------------------------------- /img/NMF_eqn5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/img/NMF_eqn5.png -------------------------------------------------------------------------------- /img/NMF_eqn6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/img/NMF_eqn6.png -------------------------------------------------------------------------------- /img/NMF_eqn7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/img/NMF_eqn7.png -------------------------------------------------------------------------------- /img/NMF_eqn8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/img/NMF_eqn8.png -------------------------------------------------------------------------------- /img/NMF_eqn9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/img/NMF_eqn9.png -------------------------------------------------------------------------------- /img/eqn1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/img/eqn1.png -------------------------------------------------------------------------------- /img/eqn2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/img/eqn2.png -------------------------------------------------------------------------------- /img/eqn3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/img/eqn3.png -------------------------------------------------------------------------------- /img/eqn4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/img/eqn4.png -------------------------------------------------------------------------------- /img/eqn5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/img/eqn5.png -------------------------------------------------------------------------------- /img/eqn6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/img/eqn6.png -------------------------------------------------------------------------------- /img/eqn7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/img/eqn7.png -------------------------------------------------------------------------------- /img/eqn8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/img/eqn8.png -------------------------------------------------------------------------------- /img/knn_ss_eqn1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/img/knn_ss_eqn1.png -------------------------------------------------------------------------------- /img/knn_ss_eqn2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/img/knn_ss_eqn2.png -------------------------------------------------------------------------------- /img/knn_ss_eqn3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/img/knn_ss_eqn3.png -------------------------------------------------------------------------------- /img/knn_ss_eqn4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaharpit809/Machine-Learning-for-Signal-Processing/cd0257c4b2d2e5ab59c64ca47040b6a02be08aa8/img/knn_ss_eqn4.png --------------------------------------------------------------------------------