{{ message }}

Instantly share code, notes, and snippets.

# Reza Vaghefi rvaghefi

• Qualcomm
• San Francisco Bay Area
Created Feb 4, 2021
heteroscedasticity_detection.py
View heteroscedasticity_detection.py
 import pandas as pd import matplotlib.pyplot as plt import numpy as np # Load the datasets homoscedastic = pd.read_csv('https://gist.githubusercontent.com/rvaghefi/cb9c3b213e7ec9bc3501eed68aa8dc3f/raw/af218cf7ac0770eefe167a6796c29ab871e83079/homoscedastic.csv') heteroscedastic = pd.read_csv('https://gist.githubusercontent.com/rvaghefi/cb9c3b213e7ec9bc3501eed68aa8dc3f/raw/af218cf7ac0770eefe167a6796c29ab871e83079/heteroscedastic.csv') # Generate bias vector b = np.ones(homoscedastic.shape[0])
Created Feb 4, 2021
outlier_detection.py
View outlier_detection.py
 import matplotlib.pyplot as plt import numpy as np # set the seed np.random.seed(125) # generate a single feature randomly X0 = np.random.rand(500) # actual interception and slope of linear regression
Created Feb 4, 2021
weighted_linear_regression.py
View weighted_linear_regression.py
 import numpy as np import matplotlib.pyplot as plt # set the seed np.random.seed(561) # generate a single feature randomly X0 = np.random.rand(100) # actual interception and slope of linear regression
Last active Jan 22, 2021
linear_regression_data
View heteroscedastic.csv
y X1 X2 X3 5.15 0.7 0.29 0.23 3.65 0.55 0.72 0.42 5.94 0.98 0.68 0.48 3.9 0.39 0.34 0.73 4.51 0.44 0.06 0.4 5.68 0.74 0.18 0.18 4.15 0.53 0.53 0.63 5.48 0.85 0.72 0.61 5.4 0.72 0.32 0.36
Created Jan 14, 2021
distance_benchmark.py
View distance_benchmark.py
 import numpy as np import cupy as cp from numba import jit from timeit import timeit from scipy.spatial.distance import cdist import pandas as pd n = 20 m = 100
Created Jan 14, 2021
numba_for_loop.py
View numba_for_loop.py
 from numba import jit @jit(nopython=True) def numba_for_loop(X,Y): m = X.shape[0] k = Y.shape[0] D = np.zeros((m,k)) for i in range(m): for j in range(k): D[i,j] = np.sum((X[i] - Y[j])**2)**0.5
Created Jan 13, 2021
cupy_vectorized.py
View cupy_vectorized.py
 import cupy as cp def cupy_vectorized(X,Y): X_gpu = cp.asarray(X) Y_gpu = cp.asarray(Y) D = cp.sum((X_gpu[:,None,:] - Y_gpu[None,:,:])**2, axis=2)**0.5 return cp.asnumpy(D)
Created Jan 13, 2021
scipy_cdist.py
View scipy_cdist.py
 from scipy.spatial.distance import cdist def scipy_cdist(X,Y): return cdist(X,Y,metric='euclidean')
Last active Jan 13, 2021
numpy_vectorized.py
View numpy_vectorized.py
 def numpy_vectorized(X,Y): return np.sum((X[:,None,:] - Y[None,:,:])**2, axis=2)**0.5
Created Jan 13, 2021
numpy_for_loop
View numpy_for_loop.py
 def numpy_for_loop(X,Y): m = X.shape[0] k = Y.shape[0] D = np.zeros((m,k)) for i in range(m): for j in range(k): D[i,j] = np.sum((X[i] - Y[j])**2)**0.5 return D