Skip to content

Instantly share code, notes, and snippets.

View vene's full-sized avatar
🏴
ahoy

Vlad Niculae vene

🏴
ahoy
View GitHub Profile
@vene
vene / check.py
Last active June 9, 2017 08:32
lightning multiprocessing failure in python 3.6
import sys
import numpy as np
import sklearn
import lightning
print("python", sys.version)
print("numpy", np.__version__)
print("scikit-learn", sklearn.__version__)
print("lightning", lightning.__version__)
@vene
vene / check_if_delegate_has_method.py
Created June 7, 2017 08:33
if_delegate_has_method adds explicit self
from sklearn.utils.metaestimators import if_delegate_has_method
from sklearn.utils.fixes import signature
class Test(object):
def hi(self, what):
return 1 + what
class Kid(object):
@vene
vene / trollplot.ipynb
Created August 4, 2016 15:02
The Trolliest Plot Ever
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vene
vene / AttentiveGRU.ipynb
Last active July 21, 2016 00:42
Attentive GRU for classification of text dyads
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vene
vene / sparsemax_loss_theano.ipynb
Created July 8, 2016 20:53
sparsemax loss for Theano
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vene
vene / coordinate_descent.ipynb
Created June 30, 2016 15:27
simple cd solver for l2-regularized linear models
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vene
vene / lrbilinear.py
Last active May 30, 2016 18:11
low-rank bilinear regression using theano
# low-rank bilinear regression using theano (supports sparse inputs)
# predicts f(x_left, x_right) = x_left' UV' x_right
# Reference:
# Generalised Bilinear Regression
# K. Ruben Gabriel
# Source: Biometrika, Vol. 85, No. 3 (Sep., 1998), pp. 689-700
# Stable URL: http://www.jstor.org/stable/2337396
# Author: Vlad Niculae <[email protected]>
# -*- coding: utf8 -*-
"""Convex factorization machines
Implements the solver by: Mathieu Blondel, Akinori Fujino, Naonori Ueda.
"Convex factorization machines". Proc. of ECML-PKDD 2015
http://www.mblondel.org/publications/mblondel-ecmlpkdd2015.pdf
"""
# Author: Vlad Niculae <[email protected]>
# License: Simplified BSD
""" Poisson-loss Factorization Machines with Numba
Follows the vanilla FM model from:
Steffen Rendle (2012): Factorization Machines with libFM.
In: ACM Trans. Intell. Syst. Technol., 3(3), May.
http://doi.acm.org/10.1145/2168752.2168771
See also: https://github.com/coreylynch/pyFM
"""
from collections import Counter
import numpy as np
from sklearn.metrics import euclidean_distances
from pyemd import emd as pyemd
def word_movers_distance(a, b, embeddings):
"""Word Mover's Distance.
A measure of text similarity: earth mover's distance in embedding metric space.