Skip to content

Instantly share code, notes, and snippets.

@lesteve
lesteve / test_sklearn_issue_5136.py
Last active October 13, 2015 16:38
Reproducing scikit-learn issue #5136
import pandas as pd
import numpy as np
from sklearn.naive_bayes import MultinomialNB
import unicodedata
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.cross_validation import train_test_split
path='./BUG-SKLEARN-MNB/'
#%% load et normalisation des donnees
# def norm(x):
@lesteve
lesteve / joblib_bench.py
Created March 11, 2015 09:22
joblib simple benchmark
import time
import sys
import numpy as np
np.random.seed(0)
N = int(1e7)
big_array = np.random.random(N)
@lesteve
lesteve / line_with_scientific_notation_coordinates.svg
Created September 8, 2014 21:16
SVG using scientific notation for one of its path coordinates
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.
@lesteve
lesteve / embed_kernel_and_connected_notebook.py
Created March 22, 2013 00:17
Embedding a kernel and starting a ipython notebook that knows how to connect to it. Kind of a work-around similar to ipython notebook --existing if it existed.
from IPython import embed_kernel
import start_notebook
def main():
p = start_notebook.main()
localDict = { 'a':1, 'b':2 }
embed_kernel()
p.kill()
@lesteve
lesteve / ipkernelapp_outside_main_thread.py
Last active February 22, 2018 02:31
Starting an ipython kernel outside the main thread
import threading
import sys
import signal
# this is the heavy monkey-patching that actually works
# i.e. you can start the kernel fine and connect to it e.g. via
# ipython console --existing
# signal.signal = lambda *args, **kw: None
from IPython.zmq.ipkernel import IPKernelApp
app = IPKernelApp.instance()