Skip to content

Instantly share code, notes, and snippets.

View fabianp's full-sized avatar
🏠
Working from home

Fabian Pedregosa fabianp

🏠
Working from home
View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fabianp
fabianp / partial_corr.py
Last active March 21, 2024 09:00
Partial Correlation in Python (clone of Matlab's partialcorr)
"""
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},
@fabianp
fabianp / gist:804e8a2891633d4618dd
Created September 9, 2014 13:41
profile strong rules
=====================
Lasso and Elastic Net
=====================
Lasso and elastic net (L1 and L2 penalisation) implemented using a
coordinate descent.
The coefficients can be forced to be positive.
@fabianp
fabianp / lowess.py
Last active August 29, 2015 13:58
SParse Additive Models (SPAM) in Python
"""
This module implements the Lowess function for nonparametric regression.
Functions:
lowess Fit a smooth nonparametric regression curve to a scatterplot.
For more information, see
William S. Cleveland: "Robust locally weighted regression and smoothing
scatterplots", Journal of the American Statistical Association, December 1979,
@fabianp
fabianp / check_ordinal.py
Created November 15, 2013 11:02
Check that the gradient of the ordinal logistic regression is correct
"""
Check that the gradient of the logistic regression is correct
"""
import numpy as np
BIG = 1e12
def phi(t):
"""
@fabianp
fabianp / nisl_doc.sh
Last active December 17, 2015 22:39
NISL documentation buildbot
#/bin/bash
source $HOME/envs/cron/bin/activate
cd $HOME/cron/nisl
# clean all previous code
rm -rf *
# clean import
git fetch origin
git reset --hard origin/master
@fabianp
fabianp / bench.py
Last active December 17, 2015 02:08
Benchmark different solvers in scikit-learn's Ridge
from __future__ import print_function
import numpy as np
from sklearn import linear_model
from datetime import datetime
import pylab as pl
import pylab
def errorfill(x, y, yerr, color=None, alpha_fill=0.3, ax=None, label=None):
# helper function, stolen from http://tonysyu.github.com/plotting-error-bars.html
@fabianp
fabianp / trace.py
Created January 10, 2013 17:03
Trace norm
import numpy as np
from scipy import linalg
from scipy.sparse import linalg as splinalg
def prox_l1(a, b):
return np.sign(a) * np.fmax(np.abs(a) - b, 0)
def prox(X, t, v0, n_nonzero=1000, n=0, algo='dense', n_svals=10):
"""prox operator for trace norm