Skip to content

Instantly share code, notes, and snippets.

View mynameisvinn's full-sized avatar

v mynameisvinn

View GitHub Profile
from glob import glob
import json
from tqdm import tqdm
# raw treatment -> gs://etsy-recsys-ml-dev-data-nxsn/user/vtang/updates-ranker-v1/metrics/prod_updates_2
prod_fp = glob("./prod_updates_2/*")
prod_updates = {} # key = notification_feed_id, value = notification_type of candidate position 0
for fp in tqdm(prod_fp):
import requests
import json
import numpy as np
url = 'http://mmx-recsys-ingress.flop.search-infra.etsy-searchinfra-gke-prod-2.etsycloud.com/apiv2/general/rec_set/dynamic/recs'
headers = {
'accept': 'application/json',
'Content-Type': 'application/json',
}

Updates Ranker

Overview

The Updates Ranker ranks notification types (eg thank you coupons).

Surface

The Updates Ranker will be used in the Deal tab.

Runbook

Generate User and Global Notification Features

Notification features (eg user click rate for various notification types, triggers, and sources) are generated via a Sparkly job. These features are moved to FBv2 via the recs_ranking_updates_features_fbv2 DAG

Generating image embeddings for Hub
# we know the following graph is nilpontent
m = np.array([[0, 1, 0, 0, 0, 0],
[0, 0, 1, 1, 0, 0],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 1],
[0, 0, 0, 0, 0, 1],
[0, 0, 1, 0, 0, 0]])
for k in range(len(m)):
print(m)
@mynameisvinn
mynameisvinn / test_acyclicity.py
Last active May 30, 2020 21:06
test acyclicity by evaluating whether adjacency matrix is nilpontent
"""
graph examples collected from https://www.cs.hmc.edu/~keller/courses/cs60/s98/examples/acyclic/
in the first example, we have an acylic graph. there exists k such its adjacency
matrix m^k == 0. because we cant produce a path of arbitrarily high length (eg
greater than k), the graph does not have a cycle.
in the second example, we have a cyclic graph. there is no k where its adjacency
matrix m^k == 0.
@mynameisvinn
mynameisvinn / lisp_parser.py
Last active April 28, 2020 16:06
recurse center, pair programming
def create_tokens(source):
"""convert source to tokens.
convert a string "(first (list 1 (+ 2 3) 9))" into a python list
['(', 'first', '(', 'list', '1', '(', '+', '2', '3', ')', '9', ')', ')'].
this conversion allows us to recursively inspect each element in the list.
"""
return source.replace('(',' ( ').replace(')',' ) ').split()
class Vertex(object):
"""represent vertices in a tree/graph."""
def __init__(self, name):
self.name = name
self.children = {}
self.status = None
def add_child(self, child):
key = child.name
self.children[key] = child
@mynameisvinn
mynameisvinn / gist:ac8e37881d9eb5c198f953b8132c0b5b
Created November 27, 2016 15:51 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
# Image processing function
# Usage: In the Terminal, run: bash images.sh
# Get user input and resize images
function process () {
# rename
a=1
for i in *.${ext}
do