Skip to content

Instantly share code, notes, and snippets.

View rth's full-sized avatar

Roman Yurchak rth

View GitHub Profile
# -*- coding: utf-8 -*-
# -*- mode: python -*-
# Adapted from mpl_toolkits.axes_grid2
# LICENSE: Python Software Foundation (http://docs.python.org/license.html)
from matplotlib.offsetbox import AnchoredOffsetbox
class AnchoredScaleBar(AnchoredOffsetbox):
def __init__(self, transform, sizex=0, sizey=0, labelx=None, labely=None, loc=4,
pad=0.1, borderpad=0.1, sep=2, prop=None, **kwargs):
"""

Keybase proof

I hereby claim:

  • I am rth on github.
  • I am rth (https://keybase.io/rth) on keybase.
  • I have a public key whose fingerprint is 94DD 00B1 3C91 6861 2089 6CC9 D130 5FCF C0A5 3EB5

To claim this, I am signing this object:

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rth
rth / cosine_distance_metric_benchmark.py
Created November 8, 2016 12:02
A quick benchmark for computing a metric based on the cosine distance
from math import sqrt, acos
import numpy as np
def make_test_arrays(N, norm=True):
X = np.random.rand(N)
Y = np.random.rand(N)
if norm:
X /= np.linalg.norm(X)
Y /= np.linalg.norm(Y)
return X, Y
@rth
rth / mmap_pairwise_distances_benchmark.py
Created January 20, 2017 16:48
A parallel benchmark for parallel pairwise_distances for scikit-learn issue https://github.com/scikit-learn/scikit-learn/issues/8216
from sklearn.metrics import pairwise_distances
from sklearn.externals.joblib import Parallel, delayed, dump, load
import numpy as np
import tempfile
import os
from sklearn.utils import gen_even_slices
import shutil
os.environ['TMPDIR'] = '/dev/shm/'
np.random.seed(99999)
"""
This script aims to benchmark different parallelization options for pairwise metrics in scikit-learn.
The results can be found in https://github.com/scikit-learn/scikit-learn/issues/8216
The environement is setup with,
conda create -n sklearn-env scikit-learn==0.18.1 jupyter python==3.5
and this benchmark should be run with,
@rth
rth / output.txt
Last active February 5, 2018 23:09
/home/rth/src/scikit-learn/sklearn/cross_validation.py:41: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20.
"This module will be removed in 0.20.", DeprecationWarning)
/home/rth/src/scikit-learn/sklearn/grid_search.py:42: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. This module will be removed in 0.20.
DeprecationWarning)
/home/rth/src/scikit-learn/sklearn/learning_curve.py:22: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the functions are moved. This module will be removed in 0.20
DeprecationWarning)
/home/rth/src/scikit-learn/sklearn/utils/validation.py:661: DataConversio