Skip to content

Instantly share code, notes, and snippets.

View enricorotundo's full-sized avatar
🤔
Thinking

Enrico Rotundo enricorotundo

🤔
Thinking
View GitHub Profile
@eavidan
eavidan / tensorflow_grpc_vs_rest_requests_prep.py
Created August 5, 2018 11:41
benchmark for the preparation rate of MNIST requests for tensorflow serving REST vs gRPC
import tensorflow as tf
from tensorflow_serving.apis import predict_pb2
import time
import base64
import requests
import pickle
import numpy as np
import random
@kell18
kell18 / ndcg_recsys.py
Last active January 10, 2023 04:31
NDCG for recommender systems
from math import log
import unittest
def dcg_at_k(scores):
assert scores
return scores[0] + sum(sc / log(ind, 2) for sc, ind in zip(scores[1:], range(2, len(scores)+1)))
def ndcg_at_k(predicted_scores, user_scores):
assert len(predicted_scores) == len(user_scores)
@mathewdgardner
mathewdgardner / docker-save-load-images.sh
Created March 1, 2016 02:55
Save / load compressed docker images
#!/bin/bash
# Save docker images
ds() {
docker images | \
cut -d ' ' -f 1 | \
tail -n +2 | \
xargs -t -n 1 -I {} -P 4 \
sh -c 'docker save {} | bzip2 > $(echo "{}" | sed "s/^.*\///").tar.bz2'
}
@nkigen
nkigen / numbered_images.sh
Created October 31, 2014 13:35
Shell script to automate the generation of numbered images from dummyimage.com . To use just change the START and END variables and possibly the colors and size. Instead of numbers you can generate text also with a bit of modification
#!/bin/bash
#<nellyk89@gmail.com>
# http://dummyimage.com/600x400/000/fff&text=100000
BASE_URL="http://dummyimage.com/"
DEFAULT_SIZE="600X400"
DEFAULT_BG_COLOR="000"
DEFAULT_COLOR="fff"
START=1001
END=4000
@elsonidoq
elsonidoq / gist:4230222
Created December 7, 2012 02:21
Python implementation of mutual information for continuous variables
from math import log
log2= lambda x:log(x,2)
from scipy import histogram, digitize, stats, mean, std
from collections import defaultdict
def mutual_information(x,y):
return entropy(y) - conditional_entropy(x,y)
def conditional_entropy(x, y):
"""
@fabianp
fabianp / ranking.py
Last active February 1, 2024 10:02
Pairwise ranking using scikit-learn LinearSVC
"""
Implementation of pairwise ranking using scikit-learn LinearSVC
Reference:
"Large Margin Rank Boundaries for Ordinal Regression", R. Herbrich,
T. Graepel, K. Obermayer 1999
"Learning to rank from medical imaging data." Pedregosa, Fabian, et al.,
Machine Learning in Medical Imaging 2012.