Skip to content

Instantly share code, notes, and snippets.

Avatar

Mathieu Blondel mblondel

View GitHub Profile
@mblondel
mblondel / nmf_cd.py
Last active Jun 12, 2019
NMF by coordinate descent
View nmf_cd.py
"""
NMF by coordinate descent, designed for sparse data (without missing values)
"""
# Author: Mathieu Blondel <mathieu@mblondel.org>
# License: BSD 3 clause
import numpy as np
import scipy.sparse as sp
import numba
@mblondel
mblondel / local_regression.py
Last active Aug 29, 2015
Local regression
View local_regression.py
"""Local regression"""
# Author: Mathieu Blondel <mathieu@mblondel.org>
# License: BSD 3 clause
import numpy as np
from sklearn.base import BaseEstimator, RegressorMixin
from sklearn.metrics.pairwise import pairwise_kernels
from sklearn.linear_model import Ridge
@mblondel
mblondel / letor_metrics.py
Last active Oct 21, 2020
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 Jan 27, 2020
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.
You can’t perform that action at this time.