Skip to content

Instantly share code, notes, and snippets.

View TomDLT's full-sized avatar

Tom Dupré la Tour TomDLT

View GitHub Profile
@TomDLT
TomDLT / sag_threading.py
Last active August 29, 2015 14:25
Benchmark SAG multi-threading
import time
from sklearn.linear_model import LogisticRegression, LogisticRegressionCV
from sklearn.datasets import fetch_mldata
if __name__ == "__main__":
mnist = fetch_mldata('MNIST original')
X = mnist.data[::10]
@TomDLT
TomDLT / README.txt
Last active August 29, 2015 14:26
Greedy coordinate descent for NMF
# Author: Tom Dupre la Tour
# License: BSD 3 clause
Greedy Coordinate Descent for Non-Negative Matrix Factorization
in scikit-learn.
To change the Coordinate Descent into a Greedy Coordinate Descent,
change the call to
_update_cdnmf_fast(W, HHt, XHt, shuffle, seed) (in nmf.py)
into
import gc
import time
import numpy as np
import matplotlib.pyplot as plt
from sklearn.datasets import fetch_rcv1
from sklearn.preprocessing import LabelBinarizer
from sklearn.linear_model import LogisticRegression
from sklearn.linear_model.logistic import _multinomial_loss
from sklearn.externals.joblib import Memory
# Author: Tom Dupre la Tour <tom.dupre-la-tour@m4x.org>
# License: BSD 3 clause
from __future__ import print_function
from time import time
import numpy as np
import scipy.sparse as sp
import matplotlib.pyplot as plt
import pandas
@TomDLT
TomDLT / en_gros.py
Last active November 12, 2015 10:58
import numpy as np
import matplotlib.pyplot as plt
def monte_carlo(n_trajects, n_clients, n_iter, capacity=None, plot=False):
# maximum capacity by car is here unlimited
if capacity is None:
capacity = n_clients
# draw within an uniform distribution
import warnings
import neo.io
def smr2sig(filename, smr_nums=[0]):
"""
read signal from .smr file (Spike2)
parameters
----------
filename : name of file
from sklearn.datasets import fetch_olivetti_faces
from sklearn.decomposition.nmf import NMF
from sklearn.externals.joblib import Parallel, delayed
def fit(X):
nmf.fit(X)
def nmf_test(n_jobs=-1, backend='multiprocessing'):
@TomDLT
TomDLT / smr2mne.py
Created March 25, 2016 12:08
Load Spike2 files (.smr) to MNE-Python objects
from __future__ import print_function
import warnings
import numpy as np
import neo.io
from mne.io.array import RawArray
from mne import create_info
def _smr(filename):
from __future__ import print_function
import sys
import time
# copy from MNE-Python
class ProgressBar():
"""Class for generating a command-line progressbar
Parameters
----------