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
select | |
year(dt) as departure_year, | |
weekofyear(dt) as departure_week | |
from ( | |
select date_add(current_date(), x) as dt | |
from `table_that_contains_integers_0_to_n_as_x` | |
where x % 7 = 0 | |
) | |
order by dt |
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 matplotlib import pyplot as plt | |
import numpy as np | |
a = np.random.randn(10,10) | |
plt.imshow(a, cmap='gray') |
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
%matplotlib inline | |
import networkx as nx | |
from networkx.algorithms import bipartite | |
from networkx.algorithms import community | |
from matplotlib import pyplot as plt | |
G = bipartite.gnmk_random_graph(3,5,10) | |
top = nx.bipartite.sets(G)[0] | |
pos = nx.bipartite_layout(G, top) | |
nx.draw_networkx(G,pos) |
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
# pip install icrawler | |
from icrawler.builtin import GoogleImageCrawler | |
import argparse | |
if __name__=='__main__': | |
parser = argparse.ArgumentParser(description='Scrape some images.') | |
parser.add_argument('keywords', metavar = 'KEYWORDS', nargs = '+', | |
help='keywords to download images for') | |
parser.add_argument('-n', '--max-num', type = int, default = 10, |
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
# Infer on live video | |
from math import ceil | |
import subprocess | |
import cv2 | |
TEST_FRAMES = 500 | |
# Initialize camera | |
cap = cv2.VideoCapture(0) | |
# Check if camera opened successfully |
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 keras.models import Sequential, load_model | |
from keras.layers import Dense, Activation, Dropout | |
from sklearn.model_selection import train_test_split | |
from sklearn.metrics import f1_score | |
MODEL_PATH='model.h5' | |
EPOCHS = 10 | |
HIDDEN_SIZE = 16 | |
model = Sequential() |
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
# Create X, y series | |
import cv2 | |
import numpy as np | |
from keras.preprocessing import image | |
from keras.applications.vgg16 import VGG16 | |
from keras.applications.vgg16 import preprocess_input | |
class VGGFramePreprocessor(): | |
def __init__(self, vgg_model): |
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 cv2 | |
from time import sleep | |
CLASSES = ['SAFE', 'DANGER'] | |
NEG_IDX = 0 | |
POS_IDX = 1 | |
FRAMES_PER_VIDEO = 100 | |
VIDEOS_PER_CLASS = 2 | |
def capture(num_frames, path='out.avi'): |
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
// Load two data paths | |
val df1 = spark.read.load("/path/to/data1") // e.g. parquet files | |
val df2 = spark.read.load("/path/to/data2") // e.g. parquet files | |
// Union into single dataframe | |
df1.createOrReplaceTempView("data1") | |
df2.createOrReplaceTempView("data2") | |
val df = spark.sql(""" |
NewerOlder