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 / gist:1076844
Last active September 26, 2015 09:37
Ridge coefficients as a function of the regularization parameter
"""
Ridge coefficients as a function of the regularization parameter
----------------------------------------------------------------
And highlight in dashed lines the optimal value by cross-validation.
Author: Fabian Pedregosa -- <fabian@fseoane.net>
"""
print __doc__
@fabianp
fabianp / chkfinite.pyx
Created July 19, 2011 18:55
check an array for finite values
cimport numpy as np
import numpy as np
np.import_array()
def chkfinite_double(np.ndarray X):
cdef int i, length
cdef np.PyArrayObject val
cdef np.flatiter iter
@fabianp
fabianp / plot_memory.py
Created October 14, 2011 13:52
Plot memory usage of qr_multiply using numpy and scipy
"""
Plot memory usage of a numeric computation using numpy and scipy
"""
"""Get process information"""
import time, sys, os
import linecache
if sys.platform.startswith('linux'):
@fabianp
fabianp / gist:1322711
Created October 28, 2011 16:37
Ridge benchmark
def _solve(A, b, solver, tol):
# helper method for ridge_regression, A is symmetric positive
if solver == 'auto':
if hasattr(A, 'todense'):
solver = 'sparse_cg'
else:
solver = 'dense_cholesky'
if solver == 'sparse_cg':
@fabianp
fabianp / nullclient.c
Created February 24, 2012 22:48
nullclient from libpurple
/*
* pidgin
*
* Pidgin is the legal property of its developers, whose names are too numerous
* to list here. Please refer to the COPYRIGHT file distributed with this
* source distribution.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@fabianp
fabianp / pty.py
Created March 31, 2012 20:11
Implementation of pty program from "Advanced Programming in the UNIX Environment"
import sys, os, termios, tty
pid, fd = os.forkpty()
term_info = termios.tcgetattr(sys.stdin.fileno())
if pid < 0:
raise ValueError("Early exit: could not fork process")
elif pid == 0:
# .. child ..
@fabianp
fabianp / gist:3568540
Created September 1, 2012 09:51
isotonic regression benchmarks
import numpy as np
# Author : Fabian Pedregosa <fabian@fseoane.net>
#
# License : BSD
def isotonic_regression_new(w, y, x_min=None, x_max=None):
"""
Solve the isotonic regression with complete ordering model:
@fabianp
fabianp / lars_ill.ipynb
Created October 28, 2012 18:16
lars ill conditioned
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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 <fabian@fseoane.net>
"""
import numpy as np
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.