Contents:
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 glob | |
from optparse import OptionParser | |
import os | |
import sys | |
from modshogun import SerializableAsciiFile, WrappedObjectArray | |
if __name__ == "__main__": | |
op = OptionParser() |
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
/* | |
* -*- coding: utf-8 -*- | |
* vim: set fileencoding=utf-8 | |
* | |
* Copyright (c) 2016, Shogun-Toolbox e.V. <shogun-team@shogun-toolbox.org> | |
* All rights reserved. | |
* | |
* Redistribution and use in source and binary forms, with or without | |
* modification, are permitted provided that the following conditions are met: | |
* |
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
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]) |
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
<!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. |
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
# A single Shogun program | |
This documents classififier_libsvm_probabilities.cpp. | |
Cool thing is we can use standard markdown to write the documentation while the source code can be executed. Another advantage is that not all source code is pasted at once. Rather, we can write little paragraphs in between, even including math. | |
## Include and initialisation | |
First, let's include the needed header files and initialise Shogun. | |
However, if this is not documented in this doxypage (one might not want to do that as it is standard), the code still is in the source file and thus can be executed and tested. | |
### Header includes |
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
{ | |
"metadata": { | |
"name": "", | |
"signature": "sha256:5480489225e5331c5fb14f21f5cb3e8312909e64210905685b98b1b36a07e6f3" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ |
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
{ | |
"metadata": { | |
"name": "Gastby ML assignment 6" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ |