Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Fabian Pedregosa fabianp

🏠
Working from home
Last active March 21, 2024 09:00
Partial Correlation in Python (clone of Matlab's partialcorr)
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
 """ Partial Correlation in Python (clone of Matlab's partialcorr) This uses the linear regression approach to compute the partial correlation (might be slow for a huge number of variables). The algorithm is detailed here: http://en.wikipedia.org/wiki/Partial_correlation#Using_linear_regression Taking X and Y two variables of interest and Z the matrix with all the variable minus {X, Y},
Created March 19, 2018 18:40
Python implementation of the Frank-Wolfe algorithm
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 from scipy import sparse # .. for plotting .. import pylab as plt # .. to generate a synthetic dataset .. from sklearn import datasets n_samples, n_features = 1000, 10000 A, b = datasets.make_regression(n_samples, n_features)
Created December 2, 2011 14:17
group lasso
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 from scipy import linalg, optimize MAX_ITER = 100 def group_lasso(X, y, alpha, groups, max_iter=MAX_ITER, rtol=1e-6, verbose=False): """ Linear least-squares with l2/l1 regularization solver.
Last active February 1, 2024 10:02
Pairwise ranking using scikit-learn LinearSVC
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
 """ Implementation of pairwise ranking using scikit-learn LinearSVC Reference: "Large Margin Rank Boundaries for Ordinal Regression", R. Herbrich, T. Graepel, K. Obermayer 1999 "Learning to rank from medical imaging data." Pedregosa, Fabian, et al., Machine Learning in Medical Imaging 2012.
Created July 12, 2012 09:58
strong rules lasso
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 -*- """ Strong rules for coordinate descent Author: Fabian Pedregosa """ import numpy as np from scipy import linalg
Created April 23, 2012 09:04
isotonic regression
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 def isotonic_regression(w, y, x_min=None, x_max=None): """ Solve the isotonic regression model: min Sum w_i (y_i - x_i) ** 2 subject to x_min = x_1 <= x_2 ... <= x_n = x_max
Created April 21, 2011 12:16
locally linear embedding - swiss roll example
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 -*- """ =================================== Swiss Roll reduction with LLE =================================== An illustration of Swiss Roll reduction with locally linear embedding """
Last active May 31, 2022 20:37
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Created February 14, 2022 16:23
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
 # Copyright 2021 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS,
Last active February 1, 2022 20:33
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
 # Copyright 2021 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS,