Skip to content

Commit

Permalink
added bibtex references draft
Browse files Browse the repository at this point in the history
  • Loading branch information
karlnapf authored and vigsterkr committed Mar 10, 2016
1 parent 213c35b commit 2234442
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
3 changes: 2 additions & 1 deletion doc/sphinx/source/conf.py
Expand Up @@ -28,7 +28,8 @@
# ones.
extensions = [
'sphinx.ext.pngmath',
'sgexample'
'sgexample',
'sphinxcontrib.bibtex',
]

# Add any paths that contain templates here, relative to this directory.
Expand Down
23 changes: 18 additions & 5 deletions doc/sphinx/source/examples/classifier/knn.rst
Expand Up @@ -4,24 +4,37 @@ K Nearest neighbours

KNN classifies data according to the majority of labels in the nearest neighbourhood, according to some underlying distance function :math:`d(x,x')`.

For :math:`k=1`, the label for point :math:`x_i` is :math:`y_{k^*}`, where :math:`k^*=\argmin_n d(x_i, x_n)`.
For :math:`k=1`, the label for point :math:`x_i` is :math:`y_{k^*}`, where

.. math::
k^*=\argmin_n d(x_i, x_n).
See Chapter 14 in :cite:`barber2012bayesian` for a detailed introduction.

-------
Example
-------

Imagine you have some training and test data.
Load some training and test data.

.. sgexample:: knn.sg:load_data

In order to run KNN, we need to choose a distance, for example CEuclideanDistance, or other sub-classes of CDistance. The distance needs the data we want to classify.
In order to run KNN, we need to choose a distance, for example CEuclideanDistance, or other sub-classes of CDistance. The distance is initialized with the data we want to classify.

.. sgexample:: knn.sg:choose_distance

Once you have chosen a distance, create an instance of the CKNN classifier, passing it training data and labels
Once we have chosen a distance, we create an instance of the CKNN classifier, passing it training data and labels.

.. sgexample:: knn.sg:create_instance

Now we run the KNN algorithm and apply it to test data
Then we run the KNN algorithm and apply it to test data.

.. sgexample:: knn.sg:train_and_apply

----------
References
----------
`KNN on Wikipedia <https://en.wikipedia.org/wiki/K-nearest_neighbors_algorithm>`_

.. bibliography:: ../../references.bib
6 changes: 6 additions & 0 deletions doc/sphinx/source/references.bib
@@ -0,0 +1,6 @@
@book{barber2012bayesian,
title={Bayesian reasoning and machine learning},
author={Barber, David},
year={2012},
publisher={Cambridge University Press}
}

0 comments on commit 2234442

Please sign in to comment.