Skip to content

Instantly share code, notes, and snippets.

Mathieu Blondel mblondel

Block or report user

Report or block mblondel

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mblondel
mblondel / letor_metrics.py
Last active Sep 18, 2019
Learning to rank metrics.
View letor_metrics.py
# (C) Mathieu Blondel, November 2013
# License: BSD 3 clause
import numpy as np
def ranking_precision_score(y_true, y_score, k=10):
"""Precision at rank k
Parameters
@mblondel
mblondel / matrix_sketch.py
Last active Feb 13, 2019
Frequent directions algorithm for matrix sketching.
View matrix_sketch.py
# (C) Mathieu Blondel, November 2013
# License: BSD 3 clause
import numpy as np
from scipy.linalg import svd
def frequent_directions(A, ell, verbose=False):
"""
Return the sketch of matrix A.
@mblondel
mblondel / curve_averaging.py
Last active May 13, 2017
Variable-length curve averaging
View curve_averaging.py
"""Variable-length curve averaging"""
# Author: Mathieu Blondel <mathieu@mblondel.org>
# License: BSD 3 clause
import numpy as np
from scipy.interpolate import interp1d
def curves_mean_std(X, Y, kind="linear"):
View kernel_kmeans.py
"""Kernel K-means"""
# Author: Mathieu Blondel <mathieu@mblondel.org>
# License: BSD 3 clause
import numpy as np
from sklearn.base import BaseEstimator, ClusterMixin
from sklearn.metrics.pairwise import pairwise_kernels
from sklearn.utils import check_random_state
@mblondel
mblondel / gaussian_process.py
Created Aug 14, 2013
Gaussian Process Regression
View gaussian_process.py
"""Gaussian processes"""
# Author: Mathieu Blondel <mathieu@mblondel.org>
# License: BSD 3 clause
import numpy as np
from scipy.linalg import cholesky, solve_triangular
from sklearn.base import BaseEstimator, RegressorMixin
from sklearn.metrics.pairwise import pairwise_kernels
@mblondel
mblondel / sparse_multiclass_numba.py
Last active Sep 19, 2018
Sparse Multiclass Classification in Numba!
View sparse_multiclass_numba.py
"""
(C) August 2013, Mathieu Blondel
# License: BSD 3 clause
This is a Numba-based reimplementation of the block coordinate descent solver
(without line search) described in the paper:
Block Coordinate Descent Algorithms for Large-scale Sparse Multiclass
Classification. Mathieu Blondel, Kazuhiro Seki, and Kuniaki Uehara.
Machine Learning, May 2013.
@mblondel
mblondel / imputer.py
Last active May 13, 2017
Missing-value imputation
View imputer.py
# (C) Mathieu Blondel
# License: BSD 3 clause
import numpy as np
from numpy import ma
import scipy.sparse as sp
def _get_mask(X, missing_values, sparse=False):
if sparse:
@mblondel
mblondel / xref.txt
Created May 10, 2013
Cross-referencing in LaTeX.
View xref.txt
paper.tex: main manuscript
supp.tex: supplementary material
Cross-referencing
-----------------
We want to cross-reference equations in paper.tex from supp.tex.
@mblondel
mblondel / lbfgs_nnls.py
Last active Dec 10, 2015
NNLS via LBFGS
View lbfgs_nnls.py
# (C) Mathieu Blondel 2012
# License: BSD 3 clause
import numpy as np
from scipy.optimize import fmin_l_bfgs_b
from sklearn.base import BaseEstimator, RegressorMixin
from sklearn.utils.extmath import safe_sparse_dot
View kernel_sgd.py
# Mathieu Blondel, May 2012
# License: BSD 3 clause
import numpy as np
def euclidean_distances(X, Y=None, Y_norm_squared=None, squared=False):
XX = np.sum(X * X, axis=1)[:, np.newaxis]
YY = np.sum(Y ** 2, axis=1)[np.newaxis, :]
distances = np.dot(X, Y.T)
distances *= -2
You can’t perform that action at this time.