Skip to content

Instantly share code, notes, and snippets.

View karlnapf's full-sized avatar

Heiko Strathmann karlnapf

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@karlnapf
karlnapf / gamma_median_heuristic.py
Created January 22, 2016 11:00
Heuristc for choosing the bandwidth of a Gaussian kernel
def gamma_median_heuristic(Z, num_subsample=1000):
"""
Computes the median pairwise distance in a random sub-sample of Z.
Returns a \gamma for k(x,y)=\exp(-\gamma ||x-y||^2), according to the median heuristc,
i.e. it corresponds to \sigma in k(x,y)=\exp(-0.5*||x-y||^2 / \sigma^2) where
\sigma is the median distance. \gamma = 0.5/(\sigma^2)
"""
inds = np.random.permutation(len(Z))[:np.max([num_subsample, len(Z)])]
dists = squareform(pdist(Z[inds], 'sqeuclidean'))
median_dist = np.median(dists[dists > 0])
<!DOCTYPE html>
<html>
<head>
<title>Shogun 4.0</title>
</head>
<body>
<p>
The Shogun team just released <a href="http://www.shogun-toolbox.org/new/41" target="_blank">version 4.0</a> of their community driven Machine Learning toolbox.
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.
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.
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.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.