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 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') |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
"""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 |
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
# Now lets measure the similarity | |
print(stats.spearmanr(upper(m1), upper(m2))) |
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
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 |
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 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 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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]: |
NewerOlder