This file contains hidden or 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
| """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 |
This file contains hidden or 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): | |
| """ |
This file contains hidden or 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, September 2010 | |
| # License: BSD 3 clause | |
| import numpy as np | |
| from numpy import linalg | |
| import cvxopt | |
| import cvxopt.solvers | |
| def linear_kernel(x1, x2): | |
| return np.dot(x1, x2) |
This file contains hidden or 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 |
This file contains hidden or 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
| % (C) Mathieu Blondel, July 2010 | |
| \documentclass[a4paper,10pt]{article} | |
| \usepackage[english]{babel} | |
| \usepackage[T1]{fontenc} | |
| \usepackage[ansinew]{inputenc} | |
| \usepackage{lmodern} | |
| \usepackage{amsmath} |
This file contains hidden or 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. |
This file contains hidden or 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 |
This file contains hidden or 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
| #!/usr/bin/env python | |
| """ | |
| Find the solution for the second order differential equation | |
| u'' = -u | |
| with u(0) = 10 and u'(0) = -5 | |
| using the Euler and the Runge-Kutta methods. |
This file contains hidden or 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
| # (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 |
This file contains hidden or 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, February 2012 | |
| # License: BSD 3 clause | |
| # Port to Python of examples in chapter 5 of | |
| # "Introductory Statistics with R" by Peter Dalgaard | |
| import numpy as np | |
| from scipy.stats import ttest_1samp, wilcoxon, ttest_ind, mannwhitneyu | |
| # daily intake of energy in kJ for 11 women |
NewerOlder