Skip to content

Instantly share code, notes, and snippets.

View jcheong0428's full-sized avatar
🥕

Jin Hyun Cheong jcheong0428

🥕
View GitHub Profile
@jcheong0428
jcheong0428 / webcam.py
Created May 23, 2022 06:34
OpenCV webcam example
# import packages.
import numpy as np
import cv2
import time
# Initialize the fist webcam as webCam
webCam = cv2.VideoCapture(0)
# Define the codec, fps, and resolution, to create the VideoWriter object
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
@jcheong0428
jcheong0428 / 22w_psyc53.ipynb
Last active March 1, 2022 01:37
22W_PSYC53.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jcheong0428
jcheong0428 / vest_output_loader.ipynb
Created January 17, 2022 18:15
VEST_output_loader.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jcheong0428
jcheong0428 / tds-matrices.ipynb
Created December 20, 2021 03:51
TDS-matrices
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jcheong0428
jcheong0428 / sim_mat4.py
Last active December 20, 2021 03:31
sim_mat4.py
"""Nonparametric permutation testing Monte Carlo"""
np.random.seed(0)
rhos = []
n_iter = 5000
true_rho, _ = stats.spearmanr(upper(m1), upper(m2))
# matrix permutation, shuffle the groups
m_ids = list(m1.columns)
m2_v = upper(m2)
for iter in range(n_iter):
np.random.shuffle(m_ids) # shuffle list
@jcheong0428
jcheong0428 / sim_mat3.py
Created December 20, 2021 03:11
sim_mat3.py
# Now lets measure the similarity
print(stats.spearmanr(upper(m1), upper(m2)))
@jcheong0428
jcheong0428 / sim_mat2.py
Created December 20, 2021 03:03
sim_mat2.py
def upper(df):
'''Returns the upper triangle of a correlation matrix.
You can use scipy.spatial.distance.squareform to recreate matrix from upper triangle.
Args:
df: pandas or numpy correlation matrix
Returns:
list of values from upper triangle
@jcheong0428
jcheong0428 / sim_mat1.py
Last active December 30, 2021 03:49
sim_mat1.py
import seaborn as sns
import numpy as np
import pandas as pd
import scipy.stats as stats
from scipy.spatial.distance import squareform
import matplotlib.pyplot as plt
# n is the number of subjects or items that will determine the size of the correlation matrix.
n = 20
data_length = 50
@jcheong0428
jcheong0428 / back_pain.ipynb
Created November 15, 2021 05:02
back_pain.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jcheong0428
jcheong0428 / backpain_2.py
Created November 15, 2021 04:52
backpain_2.py
from scipy import stats
def create_future():
"""Code to create datetime index for the covid WFH period."""
future = list()
for y in [2020]:
for m in range(4, 13):
date = f'{y}-{m:02d}'
future.append([date])
for y in [2021]: