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
@fabianp
fabianp / spsaga.py
Created August 21, 2017 22:02
Sparse Proximal SAGA
import numpy as np
from scipy import sparse
from datetime import datetime
from numba import njit
@njit
def deriv_logistic(p, b):
"""Derivative of the logistic loss"""
p *= b
if p > 0:
@fabianp
fabianp / ellipse.ipynb
Created November 21, 2016 14:25
plotly ellipse
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fabianp
fabianp / tv1d.py
Created June 10, 2016 06:43
1D total variation (also known as fussed lasso) proximal operator
from numba import njit
@njit
def prox_tv1d(w, stepsize):
"""
Parameters
----------
w: array
vector of coefficieents
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
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):
"""