Skip to content

Instantly share code, notes, and snippets.

View cmantas's full-sized avatar

Christos Mantas cmantas

View GitHub Profile
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
@cmantas
cmantas / cdf.py
Created March 22, 2019 15:16
A simple method plotting a Cumulative Distribution Function for a given array
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)
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()
@cmantas
cmantas / kendall.rb
Last active August 9, 2017 10:13
Kendall's tau measure in Ruby (Kendall rank correlation coefficient)
# 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`)