Skip to content

Instantly share code, notes, and snippets.

View Erotemic's full-sized avatar
An eroteme is a question mark

Jon Crall Erotemic

An eroteme is a question mark
View GitHub Profile
@Erotemic
Erotemic / toy_nan_rf.py
Created October 14, 2016 17:12
Test random forest classifier with informative nan values
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
import numpy as np
from six.moves import zip
def toydata1(rng):
from sklearn.datasets import samples_generator
n_samples = 500
n_features = 2
n_classes = 2
@Erotemic
Erotemic / bench__labels_inertia_precompute_dense.py
Created October 24, 2016 17:23
Benchmark of _labels_inertia_precompute_dense
# -*- coding: utf-8 -*-
from __future__ import print_function, division, absolute_import, unicode_literals
import time
import itertools as it
from sklearn.utils.extmath import row_norms
from sklearn.metrics.pairwise import euclidean_distances
from sklearn.metrics.pairwise import pairwise_distances_argmin_min
import numpy as np
# -*- coding: utf-8 -*-
from __future__ import print_function, division, absolute_import, unicode_literals
import time
import itertools as it
from sklearn.utils.extmath import row_norms
from sklearn.metrics.pairwise import euclidean_distances
from sklearn.metrics.pairwise import pairwise_distances_argmin_min
import numpy as np
@Erotemic
Erotemic / bench_km_mbkm.py
Created October 25, 2016 21:33
benchmarks
# -*- coding: utf-8 -*-
from __future__ import print_function, division, absolute_import, unicode_literals
import time
import itertools as it
from sklearn.utils.extmath import row_norms
from sklearn.metrics.pairwise import euclidean_distances
from sklearn.metrics.pairwise import pairwise_distances_argmin_min
import numpy as np
from scipy.stats import hypergeom
deck_size = 30
hand_size = 4
def mul_for_card(copies_in_deck=2, hand_size=3):
deck_size = 30
prb = hypergeom(deck_size, copies_in_deck, hand_size)
# P(initial_miss)
p_none_in_first3 = prb.cdf(0)
import numpy as np
import utool as ut
def get_toydata(rng):
if ut.get_argflag('--toy2'):
X_true, X, y = toydata2(rng)
else:
X_true, X, y = toydata1(rng)
return X_true, X, y
@Erotemic
Erotemic / kedgeconn.py
Created July 25, 2017 00:51
Algorithms for finding k-edge-connected compoments
# -*- coding: utf-8 -*-
"""
Algorithms for finding k-edge-connected compoments.
"""
import networkx as nx
from networkx.utils import arbitrary_element
class EdgeComponentAuxGraph(object):
"""
@Erotemic
Erotemic / gist:72bcbd647a9b6b0c2d69dac4523703c4
Created September 14, 2017 15:55
Description of versioning PRS
Initial work for updating fletch to target python3.
I still haven't gotten this to build all the way through yet, so for now its just a work in progress.
This combines PRs #172 #173 #174 #175 #177 and #186 which each pertain to their own library --- opencv, caffe (which is in there twice), vtk, ffmpeg, and openblas --- and then adds initial support for python3, which is used by multiple libraries.
### Current Status:
This branch merges the branches from the other PRs I've recently submitted and then adds initial support for python3 on top. By default only one package (OpenBLAS) has changed versions because it seems that this update never caused **any** issues in my tests. The other packages still hicup every so often when switching to their new version (some more than others).
@Erotemic
Erotemic / old_versioning_description.md
Created September 14, 2017 15:57
Old Versioning Description

Initial work for updating fletch to target python3.

I still haven't gotten this to build all the way through yet, so for now its just a work in progress.

This combines PRs #172 #173 #174 #175 #177 and #186 which each pertain to their own library --- opencv, caffe (which is in there twice), vtk, ffmpeg, and openblas --- and then adds initial support for python3, which is used by multiple libraries.

Current Status:

This branch merges the branches from the other PRs I've recently submitted and then adds initial support for python3 on top. By default only one package (OpenBLAS) has changed versions because it seems that this update never caused any issues in my tests. The other packages still hicup every so often when switching to their new version (some more than others).

@Erotemic
Erotemic / bench_confusion_matrix.py
Created September 28, 2017 03:17
Scikit-Learn Confusion Matrix Benchmark
import numpy as np
from sklearn.metrics.classification import (unique_labels, _check_targets,
check_consistent_length,
coo_matrix)
def confusion_matrix_orig(y_true, y_pred, labels=None, sample_weight=None):
y_type, y_true, y_pred = _check_targets(y_true, y_pred)
if y_type not in ("binary", "multiclass"):
raise ValueError("%s is not supported" % y_type)