This file contains hidden or 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
WITH impressions AS( | |
SELECT serve_id, MIN(dt) AS dt | |
FROM little_sister_kraken_events | |
WHERE event_name = 'impression' | |
AND get_json_object(event_details, '$.trackable_type') = 'Post' | |
AND page IN ('Dashboard', 'DashboardTab') | |
AND uuid_type = 'u' | |
AND uuid != '' | |
AND dt BETWEEN '2022-05-16' AND '2022-05-23' | |
GROUP BY serve_id |
This file contains hidden or 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 cdf(data, label, show = True): | |
data_size=len(data) | |
# Set bins edges | |
data_set=sorted(set(data)) | |
bins=np.append(data_set, data_set[-1]+1) | |
# Use the histogram function to bin the data | |
counts, bin_edges = np.histogram(data, bins=bins, density=False) |
This file contains hidden or 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 random import shuffle | |
import requests | |
from urllib.parse import urlparse, parse_qs | |
import tensorflow as tf | |
tf.logging.set_verbosity(tf.logging.ERROR) | |
import matplotlib.pyplot as plt | |
def read_data(fname, token='#'): | |
with open(fname) as f: | |
lines = f.readlines() |
This file contains hidden or 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
# careful!, a and b should have the same elements | |
# Kendall's tau (τ) measure for any two arrays | |
# @param a[Array] an array (sorted by a ranking) | |
# @param b[Array] array having the same elements as a, sorted by another ranking | |
# @return [Float] in range [-1, 1] | |
def kendal(a, b) | |
pairs = a.combination(2) # note that for each of those pairs, the position of | |
# the second element in array `a` is subsequent to the position of the first. | |
# (aka, if a = ['a', 'b', 'c'], value ['c','b'] cannot exist in `pairs`) |