Skip to content

Instantly share code, notes, and snippets.

View aabadie's full-sized avatar

Alexandre Abadie aabadie

View GitHub Profile
@aabadie
aabadie / joblib-s3.py
Created June 17, 2016 13:13
Dump arbitrary object in an Amazon S3 cloud storage using Joblib
"""Example of usage of Joblib with Amazon S3."""
import s3io
import joblib
import numpy as np
big_obj = [np.ones((500, 500)), np.random.random((1000, 1000))]
# Customize the following values with yours
bucket = "my-bucket"
@aabadie
aabadie / strategies_comparison_plot.py
Created May 18, 2016 09:37
Generate nice plot from persistence strategies comparison script
import os
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
# General configuration variables
# Script configuration variables:
CSV_FILE = '/tmp/comparison_results.csv'
PNG_FILE = '/tmp/comparison_results.png'
@aabadie
aabadie / profile_memory.py
Last active May 18, 2016 09:52
Base python script used to profile memory usage of joblib dump/load functions
import numpy as np
import joblib
obj = [np.ones((5000, 5000)), np.random.random((5000, 5000))]
joblib.dump(obj, '/tmp/test.pkl', compress=True)
joblib.load('/tmp/test.pkl')
@aabadie
aabadie / strategies_comparison.py
Last active September 17, 2020 17:36
Persistence strategies comparison
"""Persistence strategies comparison script.
This script compute the speed, memory used and disk space used when dumping and
loading arbitrary data. The data are taken among:
- scikit-learn Labeled Faces in the Wild dataset (LFW)
- a fully random numpy array with 10000x10000 shape
- a dictionary with 1M random keys/values
- a list containing 10M random value
The compared persistence strategies are:
@aabadie
aabadie / bench_joblib_compression.py
Last active January 8, 2016 17:23
Test joblib compression
"""Script comparing different pickling strategies."""
from joblib.numpy_pickle import NumpyPickler, NumpyUnpickler
from joblib.numpy_pickle_utils import JoblibZFile
from joblib.numpy_pickle_utils import BinaryZlibFile, BinaryGzipFile
from pickle import _Pickler, _Unpickler, Pickler, Unpickler
import numpy as np
import bz2
import lzma
import time
@aabadie
aabadie / bench.py
Created November 13, 2015 16:29 — forked from GaelVaroquaux/bench.py
Benching I/O speed with numpy, joblib, NiBabel and pytables
"""
Benching I/O with joblib and other libraries. Comment and
un-comment what you are interested in.
Warning: this is slow, and the benchs are easily offset by other disk
activity.
"""
import os
import time
import shutil