This is the outline of a framework that will allow general distance metrics to be incorporated into scikit-learn BallTree. The idea is that we need a fast way to compute the distance between two points under a given metric. In the basic framework here, this involves creating an object which exposes C-pointers to a function and a parameter structure so that the distance function can be called from either python or directly from cython with no python overhead.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mymodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from astroML import stats | |
def estimate_bayes_factor(traces, logp, r=0.05, return_list=False, | |
old_version=False, normalize_space=True): | |
"""Estimate the bayes factor using the local density of points""" | |
D, N = traces.shape | |
if normalize_space: | |
traces = traces.copy() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from scipy.sparse.linalg import eigs | |
N = 6 | |
k = 2 | |
# with this random seed, I get a memory error on the third iteration below | |
np.random.seed(2301) | |
A = np.random.random((N,N)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
code demonstrating the problem seen in issue #365 | |
to run the example: | |
tar -zxvf data.tgz | |
python test.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import warnings | |
from sklearn import datasets | |
from sklearn.neighbors import NearestNeighbors | |
import numpy as np | |
n_points = 1000 | |
n_neighbors = 10 | |
out_dim = 2 | |
n_trials = 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from matplotlib import pyplot as plt | |
from matplotlib import animation | |
# First set up the figure, the axis, and the plot element we want to animate | |
fig = plt.figure() | |
ax = fig.add_subplot(111, xlim=(0, 2), ylim=(-2, 2)) | |
line, = ax.plot([], [], lw=2) | |
# initialization function: plot the background of each frame |
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import warnings | |
import re | |
import itertools | |
from pelican.readers import MarkdownReader, EXTENSIONS | |
from pelican.utils import pelican_open | |
from pelican import signals | |
def split_args(argstring): |