{{ message }}

Instantly share code, notes, and snippets.

# Mathieu Blondel mblondel

Last active Jun 18, 2022
View smoothed_conjugate.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 # Mathieu Blondel, 2022 # BSD license import numpy as np from scipy.ndimage import convolve1d from sklearn.metrics.pairwise import euclidean_distances def smoothed_conjugate_conv(f, x, eps=1.0): """
Last active Mar 21, 2022
A small script to get numerical evidence that a function is convex
View check_convex.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 # Authors: Mathieu Blondel, Vlad Niculae # License: BSD 3 clause import numpy as np def _gen_pairs(gen, max_iter, max_inner, random_state, verbose): rng = np.random.RandomState(random_state) # if tuple, interpret as randn
Created Nov 2, 2019
Projection onto the probability simplex using isotonic regression.
View projection_simplex_isotonic.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 # Author: Mathieu Blondel # License: BSD 3 clause import numpy as np from sklearn.isotonic import isotonic_regression def projection_simplex(x, z=1): """ Compute argmin_{p : p >= 0 and \sum_i p_i = z} ||p - x||
Last active Apr 14, 2022
Vectorized projection onto the simplex
View projection_simplex_vectorized.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 # Author: Mathieu Blondel # License: BSD 3 clause import numpy as np def projection_simplex(V, z=1, axis=None): """ Projection of x onto the simplex, scaled by z: P(x; z) = argmin_{y >= 0, sum(y) = z} ||y - x||^2
Created Sep 3, 2017
Optimal transport dual LP
View ot_dual_lp.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 # Author: Mathieu Blondel # License: BSD 3 clause import numpy as np from scipy.optimize import linprog def dual_lp(a, b, C, verbose=0): """Solves the dual optimal transport problem:
Created Nov 6, 2016
Efficient implementation of FISTA
View fista.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 """ Efficient implementation of FISTA. """ # Author: Mathieu Blondel # License: BSD 3 clause import numpy as np
Created Oct 28, 2015
Semi-supervised Naive Bayes
View seminb.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 # -*- coding: utf-8 -*- # Copyright (C) 2010 Mathieu Blondel # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful,
Created May 22, 2015
Einstein sum notation
View einsum.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 import numpy as np rng = np.random.RandomState(0) print "Trace" A = rng.rand(3, 3) print np.trace(A) print np.einsum("ii", A) print
Last active Dec 23, 2021
Multiclass SVMs
View multiclass_svm.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 """ Multiclass SVMs (Crammer-Singer formulation). A pure Python re-implementation of: Large-scale Multiclass Support Vector Machine Training via Euclidean Projection onto the Simplex. Mathieu Blondel, Akinori Fujino, and Naonori Ueda. ICPR 2014. http://www.mblondel.org/publications/mblondel-icpr2014.pdf """
Last active Apr 24, 2022
Projection onto the simplex
View projection_simplex.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 """ License: BSD Author: Mathieu Blondel Implements three algorithms for projecting a vector onto the simplex: sort, pivot and bisection. For details and references, see the following paper: Large-scale Multiclass Support Vector Machine Training via Euclidean Projection onto the Simplex Mathieu Blondel, Akinori Fujino, and Naonori Ueda.