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 / 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
@fabianp
fabianp / svd_memory.py
Created December 10, 2012 14:10
Timings and memory consumption for the singular value decomposition implemented in scipy. The script svd_memory.py generates a plot about the memory consumption (requires the package `memory_profiler`) and the second one will plot the timings. The scripts will perform several iterations for matrices of different sizes and will take about 30 minu…
# .. Memory benchmarks for SciPy's Singular Value Decomposition ..
# .. Author: Fabian Pedregosa <[email protected]>
import numpy as np
from scipy.sparse import linalg as splinalg
from scipy import sparse, linalg
import pylab as pl
from memory_profiler import memory_usage
dims = np.arange(500, 1500, 20)
@fabianp
fabianp / lars_ill.ipynb
Created October 28, 2012 18:16
lars ill conditioned
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fabianp
fabianp / gist:3568540
Created September 1, 2012 09:51
isotonic regression benchmarks
import numpy as np
# Author : Fabian Pedregosa <[email protected]>
#
# License : BSD
def isotonic_regression_new(w, y, x_min=None, x_max=None):
"""
Solve the isotonic regression with complete ordering model:
@fabianp
fabianp / gist:3097107
Created July 12, 2012 09:58
strong rules lasso
# -*- coding: utf-8 -*-
"""
Strong rules for coordinate descent
Author: Fabian Pedregosa <[email protected]>
"""
import numpy as np
from scipy import linalg
@fabianp
fabianp / coordinate_descent.py
Created July 12, 2012 07:47
minimalistic l1 coordinate descent
# -*- coding: utf-8 -*-
"""
Minimalistic implementation of l1 minimization via coordinate descent.
Reference: www.jstatsoft.org/v33/i01/paper
Author: Fabian Pedregosa <[email protected]>
"""
import numpy as np
@fabianp
fabianp / gist:3081831
Created July 10, 2012 07:33
Pool Adjacent Violators
import numpy as np
# Author : Alexandre Gramfort
# license : BSD
def pav(y):
"""
PAV uses the pair adjacent violators method to produce a monotonic
smoothing of y
@fabianp
fabianp / isotonic_regression.py
Created April 23, 2012 09:04
isotonic regression
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