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
| import numpy as np | |
| EPSILON = 1e-10 | |
| def _error(actual: np.ndarray, predicted: np.ndarray): | |
| """ Simple error """ | |
| return actual - predicted | |
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
| max(-x,-y) = -min(x,y) | |
| min(-x,-y) = -max(x,y) | |
| abs(x) = abs(-x) | |
| abs(x) = max(x,-x) = -min(x,-x) | |
| abs(x*a) = if (a >= 0) abs(x)*a | |
| (a < 0) -abs(x)*a | |
| // basically any commutative operation | |
| min(x,y) + max(x,y) = x + y |
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
| """ | |
| 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 | |
| """ |
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
| # 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
| import numpy as np | |
| import pandas as pd | |
| from collections import defaultdict | |
| from scipy.stats import hmean | |
| from scipy.spatial.distance import cdist | |
| from scipy import stats | |
| import numbers | |
| def weighted_hamming(data): |