From 3d695b1f475a8ac47c4343d0a13049052b0b0c08 Mon Sep 17 00:00:00 2001 From: terrytangyuan Date: Mon, 21 Sep 2015 22:32:55 -0400 Subject: [PATCH 01/10] Added intial doc version --- doc/Makefile | 192 ++++++++++++++++++++++ doc/make.bat | 263 +++++++++++++++++++++++++++++++ doc/source/conf.py | 367 +++++++++++++++++++++++++++++++++++++++++++ doc/source/index.rst | 22 +++ 4 files changed, 844 insertions(+) create mode 100644 doc/Makefile create mode 100644 doc/make.bat create mode 100644 doc/source/conf.py create mode 100644 doc/source/index.rst diff --git a/doc/Makefile b/doc/Makefile new file mode 100644 index 00000000..e145cd84 --- /dev/null +++ b/doc/Makefile @@ -0,0 +1,192 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = build + +# User-friendly check for sphinx-build +ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) +$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) +endif + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source + +.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest coverage gettext + +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " singlehtml to make a single large HTML file" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " applehelp to make an Apple Help Book" + @echo " devhelp to make HTML files and a Devhelp project" + @echo " epub to make an epub" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" + @echo " text to make text files" + @echo " man to make manual pages" + @echo " texinfo to make Texinfo files" + @echo " info to make Texinfo files and run them through makeinfo" + @echo " gettext to make PO message catalogs" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " xml to make Docutils-native XML files" + @echo " pseudoxml to make pseudoxml-XML files for display purposes" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + @echo " coverage to run coverage check of the documentation (if enabled)" + +clean: + rm -rf $(BUILDDIR)/* + +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +singlehtml: + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml + @echo + @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." + +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in $(BUILDDIR)/htmlhelp." + +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/metric-learn.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/metric-learn.qhc" + +applehelp: + $(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp + @echo + @echo "Build finished. The help book is in $(BUILDDIR)/applehelp." + @echo "N.B. You won't be able to view it unless you put it in" \ + "~/Library/Documentation/Help or install it in your application" \ + "bundle." + +devhelp: + $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp + @echo + @echo "Build finished." + @echo "To view the help file:" + @echo "# mkdir -p $$HOME/.local/share/devhelp/metric-learn" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/metric-learn" + @echo "# devhelp" + +epub: + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub + @echo + @echo "Build finished. The epub file is in $(BUILDDIR)/epub." + +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make' in that directory to run these through (pdf)latex" \ + "(use \`make latexpdf' here to do that automatically)." + +latexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +latexpdfja: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through platex and dvipdfmx..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +text: + $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text + @echo + @echo "Build finished. The text files are in $(BUILDDIR)/text." + +man: + $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man + @echo + @echo "Build finished. The manual pages are in $(BUILDDIR)/man." + +texinfo: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo + @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." + @echo "Run \`make' in that directory to run these through makeinfo" \ + "(use \`make info' here to do that automatically)." + +info: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo "Running Texinfo files through makeinfo..." + make -C $(BUILDDIR)/texinfo info + @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." + +gettext: + $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale + @echo + @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." + +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +doctest: + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in $(BUILDDIR)/doctest/output.txt." + +coverage: + $(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage + @echo "Testing of coverage in the sources finished, look at the " \ + "results in $(BUILDDIR)/coverage/python.txt." + +xml: + $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml + @echo + @echo "Build finished. The XML files are in $(BUILDDIR)/xml." + +pseudoxml: + $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml + @echo + @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." diff --git a/doc/make.bat b/doc/make.bat new file mode 100644 index 00000000..1c30731c --- /dev/null +++ b/doc/make.bat @@ -0,0 +1,263 @@ +@ECHO OFF + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set BUILDDIR=build +set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% source +set I18NSPHINXOPTS=%SPHINXOPTS% source +if NOT "%PAPER%" == "" ( + set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% + set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% +) + +if "%1" == "" goto help + +if "%1" == "help" ( + :help + echo.Please use `make ^` where ^ is one of + echo. html to make standalone HTML files + echo. dirhtml to make HTML files named index.html in directories + echo. singlehtml to make a single large HTML file + echo. pickle to make pickle files + echo. json to make JSON files + echo. htmlhelp to make HTML files and a HTML help project + echo. qthelp to make HTML files and a qthelp project + echo. devhelp to make HTML files and a Devhelp project + echo. epub to make an epub + echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter + echo. text to make text files + echo. man to make manual pages + echo. texinfo to make Texinfo files + echo. gettext to make PO message catalogs + echo. changes to make an overview over all changed/added/deprecated items + echo. xml to make Docutils-native XML files + echo. pseudoxml to make pseudoxml-XML files for display purposes + echo. linkcheck to check all external links for integrity + echo. doctest to run all doctests embedded in the documentation if enabled + echo. coverage to run coverage check of the documentation if enabled + goto end +) + +if "%1" == "clean" ( + for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i + del /q /s %BUILDDIR%\* + goto end +) + + +REM Check if sphinx-build is available and fallback to Python version if any +%SPHINXBUILD% 2> nul +if errorlevel 9009 goto sphinx_python +goto sphinx_ok + +:sphinx_python + +set SPHINXBUILD=python -m sphinx.__init__ +%SPHINXBUILD% 2> nul +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +:sphinx_ok + + +if "%1" == "html" ( + %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/html. + goto end +) + +if "%1" == "dirhtml" ( + %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. + goto end +) + +if "%1" == "singlehtml" ( + %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. + goto end +) + +if "%1" == "pickle" ( + %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can process the pickle files. + goto end +) + +if "%1" == "json" ( + %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can process the JSON files. + goto end +) + +if "%1" == "htmlhelp" ( + %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can run HTML Help Workshop with the ^ +.hhp project file in %BUILDDIR%/htmlhelp. + goto end +) + +if "%1" == "qthelp" ( + %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; now you can run "qcollectiongenerator" with the ^ +.qhcp project file in %BUILDDIR%/qthelp, like this: + echo.^> qcollectiongenerator %BUILDDIR%\qthelp\metric-learn.qhcp + echo.To view the help file: + echo.^> assistant -collectionFile %BUILDDIR%\qthelp\metric-learn.ghc + goto end +) + +if "%1" == "devhelp" ( + %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. + goto end +) + +if "%1" == "epub" ( + %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The epub file is in %BUILDDIR%/epub. + goto end +) + +if "%1" == "latex" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + if errorlevel 1 exit /b 1 + echo. + echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "latexpdf" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + cd %BUILDDIR%/latex + make all-pdf + cd %~dp0 + echo. + echo.Build finished; the PDF files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "latexpdfja" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + cd %BUILDDIR%/latex + make all-pdf-ja + cd %~dp0 + echo. + echo.Build finished; the PDF files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "text" ( + %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The text files are in %BUILDDIR%/text. + goto end +) + +if "%1" == "man" ( + %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The manual pages are in %BUILDDIR%/man. + goto end +) + +if "%1" == "texinfo" ( + %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. + goto end +) + +if "%1" == "gettext" ( + %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The message catalogs are in %BUILDDIR%/locale. + goto end +) + +if "%1" == "changes" ( + %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes + if errorlevel 1 exit /b 1 + echo. + echo.The overview file is in %BUILDDIR%/changes. + goto end +) + +if "%1" == "linkcheck" ( + %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck + if errorlevel 1 exit /b 1 + echo. + echo.Link check complete; look for any errors in the above output ^ +or in %BUILDDIR%/linkcheck/output.txt. + goto end +) + +if "%1" == "doctest" ( + %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest + if errorlevel 1 exit /b 1 + echo. + echo.Testing of doctests in the sources finished, look at the ^ +results in %BUILDDIR%/doctest/output.txt. + goto end +) + +if "%1" == "coverage" ( + %SPHINXBUILD% -b coverage %ALLSPHINXOPTS% %BUILDDIR%/coverage + if errorlevel 1 exit /b 1 + echo. + echo.Testing of coverage in the sources finished, look at the ^ +results in %BUILDDIR%/coverage/python.txt. + goto end +) + +if "%1" == "xml" ( + %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The XML files are in %BUILDDIR%/xml. + goto end +) + +if "%1" == "pseudoxml" ( + %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml + if errorlevel 1 exit /b 1 + echo. + echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. + goto end +) + +:end diff --git a/doc/source/conf.py b/doc/source/conf.py new file mode 100644 index 00000000..05806271 --- /dev/null +++ b/doc/source/conf.py @@ -0,0 +1,367 @@ +# -*- coding: utf-8 -*- +# +# metric-learn documentation build configuration file, created by +# sphinx-quickstart on Mon Sep 21 22:14:01 2015. +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os +import shlex + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +#sys.path.insert(0, os.path.abspath('.')) + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'sphinx.ext.autodoc', + 'sphinx.ext.doctest', + 'sphinx.ext.intersphinx', + 'sphinx.ext.todo', + 'sphinx.ext.coverage', + 'sphinx.ext.mathjax', + 'sphinx.ext.ifconfig', + 'sphinx.ext.viewcode', +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# source_suffix = ['.rst', '.md'] +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'metric-learn' +copyright = u'2015, CJ Carey and Yuan Tang' +author = u'CJ Carey and Yuan Tang' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = '0.1.0' +# The full version, including alpha/beta/rc tags. +release = '0.1.0' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = [] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +#keep_warnings = False + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = True + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'nature' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +#html_extra_path = [] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Language to be used for generating the HTML full-text search index. +# Sphinx supports the following languages: +# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' +# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' +#html_search_language = 'en' + +# A dictionary with options for the search language support, empty by default. +# Now only 'ja' uses this config value +#html_search_options = {'type': 'default'} + +# The name of a javascript file (relative to the configuration directory) that +# implements a search results scorer. If empty, the default will be used. +#html_search_scorer = 'scorer.js' + +# Output file base name for HTML help builder. +htmlhelp_basename = 'metric-learndoc' + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { +# The paper size ('letterpaper' or 'a4paper'). +#'papersize': 'letterpaper', + +# The font size ('10pt', '11pt' or '12pt'). +#'pointsize': '10pt', + +# Additional stuff for the LaTeX preamble. +#'preamble': '', + +# Latex figure (float) alignment +#'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + (master_doc, 'metric-learn.tex', u'metric-learn Documentation', + u'CJ Carey and Yuan Tang', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + (master_doc, 'metric-learn', u'metric-learn Documentation', + [author], 1) +] + +# If true, show URL addresses after external links. +#man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + (master_doc, 'metric-learn', u'metric-learn Documentation', + author, 'metric-learn', 'One line description of project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +#texinfo_appendices = [] + +# If false, no module index is generated. +#texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +#texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +#texinfo_no_detailmenu = False + + +# -- Options for Epub output ---------------------------------------------- + +# Bibliographic Dublin Core info. +epub_title = project +epub_author = author +epub_publisher = author +epub_copyright = copyright + +# The basename for the epub file. It defaults to the project name. +#epub_basename = project + +# The HTML theme for the epub output. Since the default themes are not optimized +# for small screen space, using the same theme for HTML and epub output is +# usually not wise. This defaults to 'epub', a theme designed to save visual +# space. +#epub_theme = 'epub' + +# The language of the text. It defaults to the language option +# or 'en' if the language is not set. +#epub_language = '' + +# The scheme of the identifier. Typical schemes are ISBN or URL. +#epub_scheme = '' + +# The unique identifier of the text. This can be a ISBN number +# or the project homepage. +#epub_identifier = '' + +# A unique identification for the text. +#epub_uid = '' + +# A tuple containing the cover image and cover page html template filenames. +#epub_cover = () + +# A sequence of (type, uri, title) tuples for the guide element of content.opf. +#epub_guide = () + +# HTML files that should be inserted before the pages created by sphinx. +# The format is a list of tuples containing the path and title. +#epub_pre_files = [] + +# HTML files shat should be inserted after the pages created by sphinx. +# The format is a list of tuples containing the path and title. +#epub_post_files = [] + +# A list of files that should not be packed into the epub file. +epub_exclude_files = ['search.html'] + +# The depth of the table of contents in toc.ncx. +#epub_tocdepth = 3 + +# Allow duplicate toc entries. +#epub_tocdup = True + +# Choose between 'default' and 'includehidden'. +#epub_tocscope = 'default' + +# Fix unsupported image types using the Pillow. +#epub_fix_images = False + +# Scale large images. +#epub_max_image_width = 0 + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +#epub_show_urls = 'inline' + +# If false, no index is generated. +#epub_use_index = True + + +# Example configuration for intersphinx: refer to the Python standard library. +intersphinx_mapping = {'https://docs.python.org/': None} diff --git a/doc/source/index.rst b/doc/source/index.rst new file mode 100644 index 00000000..57f1a01f --- /dev/null +++ b/doc/source/index.rst @@ -0,0 +1,22 @@ +.. metric-learn documentation master file, created by + sphinx-quickstart on Mon Sep 21 22:14:01 2015. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to metric-learn's documentation! +======================================== + +Contents: + +.. toctree:: + :maxdepth: 2 + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + From 036a514e5e309db05114414fcb60d8ec71b7e37f Mon Sep 17 00:00:00 2001 From: terrytangyuan Date: Mon, 21 Sep 2015 22:44:50 -0400 Subject: [PATCH 02/10] Added intro page --- doc/source/conf.py | 4 +-- doc/source/index.rst | 3 ++ doc/source/intro.rst | 69 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 doc/source/intro.rst diff --git a/doc/source/conf.py b/doc/source/conf.py index 05806271..99f99c34 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -276,7 +276,7 @@ # dir menu entry, description, category) texinfo_documents = [ (master_doc, 'metric-learn', u'metric-learn Documentation', - author, 'metric-learn', 'One line description of project.', + author, 'metric-learn', 'Metric Learning in Python.', 'Miscellaneous'), ] @@ -308,7 +308,7 @@ # for small screen space, using the same theme for HTML and epub output is # usually not wise. This defaults to 'epub', a theme designed to save visual # space. -#epub_theme = 'epub' +epub_theme = 'epub' # The language of the text. It defaults to the language option # or 'en' if the language is not set. diff --git a/doc/source/index.rst b/doc/source/index.rst index 57f1a01f..f549c75a 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -11,6 +11,9 @@ Contents: .. toctree:: :maxdepth: 2 + intro + + Indices and tables diff --git a/doc/source/intro.rst b/doc/source/intro.rst new file mode 100644 index 00000000..f3720421 --- /dev/null +++ b/doc/source/intro.rst @@ -0,0 +1,69 @@ +Introduction +===================================== + +|Travis-CI Build Status| |License| + +Metric Learning algorithms in Python. + +**Algorithms** + +- Large Margin Nearest Neighbor (LMNN) +- Information Theoretic Metric Learning (ITML) +- Sparse Determinant Metric Learning (SDML) +- Least Squares Metric Learning (LSML) +- Neighborhood Components Analysis (NCA) +- Local Fisher Discriminant Analysis (LFDA) + +**Dependencies** + +- Python 2.6+ +- numpy, scipy, scikit-learn +- (for running the examples only: matplotlib) + +**Installation/Setup** + +Run ``pip install metric-learn`` to download and install from PyPI. + +Run ``python setup.py install`` for default installation. + +Run ``python setup.py test`` to run all tests. + +**Usage** + +For full usage examples, see the ``test`` and ``examples`` directories. + +Each metric is a subclass of ``BaseMetricLearner``, which provides +default implementations for the methods ``metric``, ``transformer``, and +``transform``. Subclasses must provide an implementation for either +``metric`` or ``transformer``. + +For an instance of a metric learner named ``foo`` learning from a set of +``d``-dimensional points, ``foo.metric()`` returns a ``d`` by ``d`` +matrix ``M`` such that a distance between vectors ``x`` and ``y`` is +expressed ``(x-y).dot(M).dot(x-y)``. + +In the same scenario, ``foo.transformer()`` returns a ``d`` by ``d`` +matrix ``L`` such that a vector ``x`` can be represented in the learned +space as the vector ``L.dot(x)``. + +For convenience, the function ``foo.transform(X)`` is provided for +converting a matrix of points (``X``) into the learned space, in which +standard Euclidean distance can be used. + +**Notes** + +If a recent version of the Shogun Python modular (``modshogun``) library +is available, the LMNN implementation will use the fast C++ version from +there. The two implementations differ slightly, and the C++ version is +more complete. + +**TODO** + +- implement the rest of the methods on `this site`_ + +.. _this site: http://www.cs.cmu.edu/~liuy/distlearn.htm + +.. |Travis-CI Build Status| image:: https://api.travis-ci.org/all-umass/metric-learn.svg?branch=master + :target: https://travis-ci.org/all-umass/metric-learn +.. |License| image:: http://img.shields.io/:license-mit-blue.svg?style=flat + :target: http://badges.mit-license.org \ No newline at end of file From 77798c24e5571993888d64b59da606efe54b71d6 Mon Sep 17 00:00:00 2001 From: terrytangyuan Date: Mon, 21 Sep 2015 23:03:51 -0400 Subject: [PATCH 03/10] Added lmnn doc page --- doc/source/index.rst | 2 +- doc/source/lmnn.rst | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 doc/source/lmnn.rst diff --git a/doc/source/index.rst b/doc/source/index.rst index f549c75a..9d8594e5 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -12,7 +12,7 @@ Contents: :maxdepth: 2 intro - + lmnn diff --git a/doc/source/lmnn.rst b/doc/source/lmnn.rst new file mode 100644 index 00000000..b3c3e394 --- /dev/null +++ b/doc/source/lmnn.rst @@ -0,0 +1,18 @@ +Large Margin Nearest Neighbor (LMNN) +===================================== + +todo: Brief desciption or a link. + +Example Code +===================================== +Using two different implementations: + +:: + + for LMNN_cls in set((LMNN, python_LMNN)): + lmnn = LMNN_cls(k=k, learn_rate=1e-6) + lmnn.fit(self.iris_points, self.iris_labels, verbose=False) + + csep = class_separation(lmnn.transform(), self.iris_labels) + self.assertLess(csep, 0.25) + From a53a6befb5054e29ab8a7313dbf42d5af86269eb Mon Sep 17 00:00:00 2001 From: terrytangyuan Date: Mon, 21 Sep 2015 23:27:52 -0400 Subject: [PATCH 04/10] Changed doc structure --- doc/source/algorithms.rst | 76 +++++++++++++++++++++++++++++++++++++++ doc/source/index.rst | 3 +- doc/source/lmnn.rst | 18 ---------- 3 files changed, 77 insertions(+), 20 deletions(-) create mode 100644 doc/source/algorithms.rst delete mode 100644 doc/source/lmnn.rst diff --git a/doc/source/algorithms.rst b/doc/source/algorithms.rst new file mode 100644 index 00000000..6a0f6981 --- /dev/null +++ b/doc/source/algorithms.rst @@ -0,0 +1,76 @@ +Large Margin Nearest Neighbor (LMNN) +===================================== + +todo: Brief desciption or a link. + +Example Code +------------------ +Using two different implementations: + +:: + + for LMNN_cls in set((LMNN, python_LMNN)): + lmnn = LMNN_cls(k=k, learn_rate=1e-6) + lmnn.fit(self.iris_points, self.iris_labels, verbose=False) + + csep = class_separation(lmnn.transform(), self.iris_labels) + self.assertLess(csep, 0.25) + +References +------------------ + + + +Information Theoretic Metric Learning (ITML) +===================================== + +Example Code +------------------ + +References +------------------ + + + +Sparse Determinant Metric Learning (SDML) +===================================== + +Example Code +------------------ + +References +------------------ + + + +Least Squares Metric Learning (LSML) +===================================== + +Example Code +------------------ + +References +------------------ + + + +Neighborhood Components Analysis (NCA) +===================================== + +Example Code +------------------ + +References +------------------ + + + +Local Fisher Discriminant Analysis (LFDA) +===================================== + +Example Code +------------------ + +References +------------------ + diff --git a/doc/source/index.rst b/doc/source/index.rst index 9d8594e5..7bbb738d 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -12,7 +12,7 @@ Contents: :maxdepth: 2 intro - lmnn + algorithms @@ -20,6 +20,5 @@ Indices and tables ================== * :ref:`genindex` -* :ref:`modindex` * :ref:`search` diff --git a/doc/source/lmnn.rst b/doc/source/lmnn.rst deleted file mode 100644 index b3c3e394..00000000 --- a/doc/source/lmnn.rst +++ /dev/null @@ -1,18 +0,0 @@ -Large Margin Nearest Neighbor (LMNN) -===================================== - -todo: Brief desciption or a link. - -Example Code -===================================== -Using two different implementations: - -:: - - for LMNN_cls in set((LMNN, python_LMNN)): - lmnn = LMNN_cls(k=k, learn_rate=1e-6) - lmnn.fit(self.iris_points, self.iris_labels, verbose=False) - - csep = class_separation(lmnn.transform(), self.iris_labels) - self.assertLess(csep, 0.25) - From f885031ec3b4b693323d13e79447a08258f83e8b Mon Sep 17 00:00:00 2001 From: terrytangyuan Date: Mon, 21 Sep 2015 23:39:04 -0400 Subject: [PATCH 05/10] Added PyPI version badge --- README.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 71517663..5ca653a0 100644 --- a/README.rst +++ b/README.rst @@ -1,4 +1,4 @@ -|Travis-CI Build Status| |License| +|Travis-CI Build Status| |License| |PyPI version| metric-learn ============= @@ -66,3 +66,5 @@ more complete. :target: https://travis-ci.org/all-umass/metric-learn .. |License| image:: http://img.shields.io/:license-mit-blue.svg?style=flat :target: http://badges.mit-license.org +.. |PyPI version| image:: https://badge.fury.io/py/metric-learn.svg + :target: http://badge.fury.io/py/metric-learn \ No newline at end of file From b41b676d0a2c26c69832780a8db45c8b3305bfd0 Mon Sep 17 00:00:00 2001 From: terrytangyuan Date: Tue, 22 Sep 2015 10:30:18 -0400 Subject: [PATCH 06/10] Updated intro and lmnn doc --- doc/source/algorithms.rst | 25 ++++++++++++++++++++++--- doc/source/intro.rst | 12 ++++++------ 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/doc/source/algorithms.rst b/doc/source/algorithms.rst index 6a0f6981..6666492d 100644 --- a/doc/source/algorithms.rst +++ b/doc/source/algorithms.rst @@ -1,14 +1,21 @@ Large Margin Nearest Neighbor (LMNN) ===================================== -todo: Brief desciption or a link. +LMNN learns a Mahanalobis distance metric in the kNN classification setting by semidefinite programming. The learned distance metric enforces the k-nearest neighbors to always belong to the same class while examples from different classes are separated by a large margin. This algorithm makes no assumptions about the distribution of the data. Example Code ------------------ -Using two different implementations: - +We use iris data here for all the examples: :: + from sklearn.datasets import load_iris + + iris_data = load_iris() + self.iris_points = iris_data['data'] + self.iris_labels = iris_data['target'] + np.random.seed(1234) +In this package, we have two different implementations of LMNN. Here we try both implementations in a for loop: +:: for LMNN_cls in set((LMNN, python_LMNN)): lmnn = LMNN_cls(k=k, learn_rate=1e-6) lmnn.fit(self.iris_points, self.iris_labels, verbose=False) @@ -18,6 +25,7 @@ Using two different implementations: References ------------------ +`Link Distance Metric Learning for Large Margin Nearest Neighbor Classification `_ Kilian Q. Weinberger, John Blitzer, Lawrence K. Saul @@ -74,3 +82,14 @@ Example Code References ------------------ + + +Relative Components Analysis (RCA) +===================================== + +Example Code +------------------ + +References +------------------ + diff --git a/doc/source/intro.rst b/doc/source/intro.rst index f3720421..cc4461f2 100644 --- a/doc/source/intro.rst +++ b/doc/source/intro.rst @@ -1,9 +1,8 @@ -Introduction +metric-learn: Metric Learning in Python ===================================== +|License| |PyPI version| -|Travis-CI Build Status| |License| - -Metric Learning algorithms in Python. +Distance metric is widely used in the machine learning literature. We used to choose a distance metric according to a priori (Euclidean Distance , L1 Distance, etc.) or according to the result of cross validation within small class of functions (e.g. choosing order of polynomial for a kernel). Actually, with priori knowledge of the data, we could learn a more suitable distance metric with metric learning techniques. metric-learn contains implementations of the state-of-the-art algorithms for metric learning. These metric learning methods are widely applied in feature extraction, dimensionality reduction, clustering, classification, information retrieval, and computer vision problems. **Algorithms** @@ -13,6 +12,7 @@ Metric Learning algorithms in Python. - Least Squares Metric Learning (LSML) - Neighborhood Components Analysis (NCA) - Local Fisher Discriminant Analysis (LFDA) +- Relative Components Analysis (RCA) **Dependencies** @@ -63,7 +63,7 @@ more complete. .. _this site: http://www.cs.cmu.edu/~liuy/distlearn.htm -.. |Travis-CI Build Status| image:: https://api.travis-ci.org/all-umass/metric-learn.svg?branch=master - :target: https://travis-ci.org/all-umass/metric-learn +.. |PyPI version| image:: https://badge.fury.io/py/metric-learn.svg + :target: http://badge.fury.io/py/metric-learn .. |License| image:: http://img.shields.io/:license-mit-blue.svg?style=flat :target: http://badges.mit-license.org \ No newline at end of file From 93f9aea8d6a00a057a64d80d6bae7c1c984dc356 Mon Sep 17 00:00:00 2001 From: terrytangyuan Date: Tue, 22 Sep 2015 10:41:45 -0400 Subject: [PATCH 07/10] Restructured doc to remove some warnings --- doc/source/algorithms/itml.rst | 8 +++ doc/source/algorithms/lfda.rst | 8 +++ .../{algorithms.rst => algorithms/lmnn.rst} | 67 ------------------- doc/source/algorithms/lsml.rst | 8 +++ doc/source/algorithms/nca.rst | 8 +++ doc/source/algorithms/rca.rst | 8 +++ doc/source/algorithms/sdml.rst | 8 +++ doc/source/index.rst | 8 ++- 8 files changed, 55 insertions(+), 68 deletions(-) create mode 100644 doc/source/algorithms/itml.rst create mode 100644 doc/source/algorithms/lfda.rst rename doc/source/{algorithms.rst => algorithms/lmnn.rst} (60%) create mode 100644 doc/source/algorithms/lsml.rst create mode 100644 doc/source/algorithms/nca.rst create mode 100644 doc/source/algorithms/rca.rst create mode 100644 doc/source/algorithms/sdml.rst diff --git a/doc/source/algorithms/itml.rst b/doc/source/algorithms/itml.rst new file mode 100644 index 00000000..6737e847 --- /dev/null +++ b/doc/source/algorithms/itml.rst @@ -0,0 +1,8 @@ +Information Theoretic Metric Learning (ITML) +===================================== + +Example Code +------------------ + +References +------------------ \ No newline at end of file diff --git a/doc/source/algorithms/lfda.rst b/doc/source/algorithms/lfda.rst new file mode 100644 index 00000000..093bc74d --- /dev/null +++ b/doc/source/algorithms/lfda.rst @@ -0,0 +1,8 @@ +Local Fisher Discriminant Analysis (LFDA) +===================================== + +Example Code +------------------ + +References +------------------ \ No newline at end of file diff --git a/doc/source/algorithms.rst b/doc/source/algorithms/lmnn.rst similarity index 60% rename from doc/source/algorithms.rst rename to doc/source/algorithms/lmnn.rst index 6666492d..780fac65 100644 --- a/doc/source/algorithms.rst +++ b/doc/source/algorithms/lmnn.rst @@ -26,70 +26,3 @@ In this package, we have two different implementations of LMNN. Here we try both References ------------------ `Link Distance Metric Learning for Large Margin Nearest Neighbor Classification `_ Kilian Q. Weinberger, John Blitzer, Lawrence K. Saul - - - -Information Theoretic Metric Learning (ITML) -===================================== - -Example Code ------------------- - -References ------------------- - - - -Sparse Determinant Metric Learning (SDML) -===================================== - -Example Code ------------------- - -References ------------------- - - - -Least Squares Metric Learning (LSML) -===================================== - -Example Code ------------------- - -References ------------------- - - - -Neighborhood Components Analysis (NCA) -===================================== - -Example Code ------------------- - -References ------------------- - - - -Local Fisher Discriminant Analysis (LFDA) -===================================== - -Example Code ------------------- - -References ------------------- - - - -Relative Components Analysis (RCA) -===================================== - -Example Code ------------------- - -References ------------------- - diff --git a/doc/source/algorithms/lsml.rst b/doc/source/algorithms/lsml.rst new file mode 100644 index 00000000..9b6a8fec --- /dev/null +++ b/doc/source/algorithms/lsml.rst @@ -0,0 +1,8 @@ +Least Squares Metric Learning (LSML) +===================================== + +Example Code +------------------ + +References +------------------ \ No newline at end of file diff --git a/doc/source/algorithms/nca.rst b/doc/source/algorithms/nca.rst new file mode 100644 index 00000000..99d0fb1b --- /dev/null +++ b/doc/source/algorithms/nca.rst @@ -0,0 +1,8 @@ +Neighborhood Components Analysis (NCA) +===================================== + +Example Code +------------------ + +References +------------------ diff --git a/doc/source/algorithms/rca.rst b/doc/source/algorithms/rca.rst new file mode 100644 index 00000000..1b2bf43d --- /dev/null +++ b/doc/source/algorithms/rca.rst @@ -0,0 +1,8 @@ +Relative Components Analysis (RCA) +===================================== + +Example Code +------------------ + +References +------------------ \ No newline at end of file diff --git a/doc/source/algorithms/sdml.rst b/doc/source/algorithms/sdml.rst new file mode 100644 index 00000000..85c5b801 --- /dev/null +++ b/doc/source/algorithms/sdml.rst @@ -0,0 +1,8 @@ +Sparse Determinant Metric Learning (SDML) +===================================== + +Example Code +------------------ + +References +------------------ \ No newline at end of file diff --git a/doc/source/index.rst b/doc/source/index.rst index 7bbb738d..a96a3701 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -12,7 +12,13 @@ Contents: :maxdepth: 2 intro - algorithms + algorithms/lmnn + algorithms/itml + algorithms/sdml + algorithms/lsml + algorithms/nca + algorithms/lfda + algorithms/rca From 0c370994c6309219bc4fb4a020d871c711de6d73 Mon Sep 17 00:00:00 2001 From: terrytangyuan Date: Tue, 22 Sep 2015 10:55:26 -0400 Subject: [PATCH 08/10] Added intro to rca --- doc/source/algorithms/lmnn.rst | 2 +- doc/source/algorithms/rca.rst | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/source/algorithms/lmnn.rst b/doc/source/algorithms/lmnn.rst index 780fac65..9734b68d 100644 --- a/doc/source/algorithms/lmnn.rst +++ b/doc/source/algorithms/lmnn.rst @@ -25,4 +25,4 @@ In this package, we have two different implementations of LMNN. Here we try both References ------------------ -`Link Distance Metric Learning for Large Margin Nearest Neighbor Classification `_ Kilian Q. Weinberger, John Blitzer, Lawrence K. Saul +`Distance Metric Learning for Large Margin Nearest Neighbor Classification `_ Kilian Q. Weinberger, John Blitzer, Lawrence K. Saul diff --git a/doc/source/algorithms/rca.rst b/doc/source/algorithms/rca.rst index 1b2bf43d..f6ed8b39 100644 --- a/doc/source/algorithms/rca.rst +++ b/doc/source/algorithms/rca.rst @@ -1,8 +1,10 @@ Relative Components Analysis (RCA) ===================================== +RCA is developed for unsupervised learning using equivalence relations. It uses only closed form expressions of the data, based on an information theoretic basis. RCA is a simple and efficient algorithm for learning a full ranked Mahalanobis distance metric, which is constructed based on a weighted sum of in-class covariance matrices. It applies a global linear transformation to assign large weights to relevant dimensions but low weights to irrelevant dimensions. In RCA, those relevant dimensions are estimated using the term chunklets, which are subsets of points that are known to belong to the same although unknown class. A distance metric that represents the somewhat natural variance of the original unknown class information can then be trained using RCA. Example Code ------------------ References ------------------- \ No newline at end of file +------------------ +`Adjustment learning and relevant component analysis `_ Shental, Noam, et al. \ No newline at end of file From 3710b64337503eb4e76a84c5f8b95e0cf5fa538e Mon Sep 17 00:00:00 2001 From: terrytangyuan Date: Tue, 22 Sep 2015 11:11:10 -0400 Subject: [PATCH 09/10] Added doc for itml --- doc/source/algorithms/itml.rst | 13 ++++++++++++- doc/source/algorithms/lmnn.rst | 8 +++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/doc/source/algorithms/itml.rst b/doc/source/algorithms/itml.rst index 6737e847..8c4abd6f 100644 --- a/doc/source/algorithms/itml.rst +++ b/doc/source/algorithms/itml.rst @@ -1,8 +1,19 @@ Information Theoretic Metric Learning (ITML) ===================================== +ITML minimizes the differential relative entropy between two multivariate Gaussians under constraints on the distance function, which can be formulated into a particular Bregman optimization problem by minimizing the LogDet divergence subject to the linear constraints. This algorithm can handle wide variety of constraints and can optionally incorporate a prior on the distance function. Unlike some existing method, ITML is fast and scalable since no eigenvalue computation or semi-definite programming are required. Example Code ------------------ +After loading the iris data, we apply ITML: +:: + from metric_learn import ITML + + num_constraints = 200 + n = self.iris_points.shape[0] + C = ITML.prepare_constraints(self.iris_labels, n, num_constraints) + itml = ITML().fit(self.iris_points, C, verbose=False) + itml.transform() References ------------------- \ No newline at end of file +------------------ +`Information-theoretic Metric Learning `_ Davis, Jason V., et al. \ No newline at end of file diff --git a/doc/source/algorithms/lmnn.rst b/doc/source/algorithms/lmnn.rst index 9734b68d..15c7dc5a 100644 --- a/doc/source/algorithms/lmnn.rst +++ b/doc/source/algorithms/lmnn.rst @@ -8,6 +8,7 @@ Example Code We use iris data here for all the examples: :: from sklearn.datasets import load_iris + import numpy as np iris_data = load_iris() self.iris_points = iris_data['data'] @@ -16,12 +17,13 @@ We use iris data here for all the examples: In this package, we have two different implementations of LMNN. Here we try both implementations in a for loop: :: + from metric_learn import LMNN + from metric_learn.lmnn import python_LMNN + for LMNN_cls in set((LMNN, python_LMNN)): lmnn = LMNN_cls(k=k, learn_rate=1e-6) lmnn.fit(self.iris_points, self.iris_labels, verbose=False) - - csep = class_separation(lmnn.transform(), self.iris_labels) - self.assertLess(csep, 0.25) + lmnn.transform() References ------------------ From 630b1ba53b02ad980adee9bd778fbb437aeefd67 Mon Sep 17 00:00:00 2001 From: terrytangyuan Date: Tue, 22 Sep 2015 11:33:06 -0400 Subject: [PATCH 10/10] Updated references for doc --- doc/source/algorithms/itml.rst | 2 +- doc/source/algorithms/lfda.rst | 6 +++++- doc/source/algorithms/rca.rst | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/doc/source/algorithms/itml.rst b/doc/source/algorithms/itml.rst index 8c4abd6f..7114e755 100644 --- a/doc/source/algorithms/itml.rst +++ b/doc/source/algorithms/itml.rst @@ -16,4 +16,4 @@ After loading the iris data, we apply ITML: References ------------------ -`Information-theoretic Metric Learning `_ Davis, Jason V., et al. \ No newline at end of file +`Information-theoretic Metric Learning `_ Jason V. Davis, et al. \ No newline at end of file diff --git a/doc/source/algorithms/lfda.rst b/doc/source/algorithms/lfda.rst index 093bc74d..47797922 100644 --- a/doc/source/algorithms/lfda.rst +++ b/doc/source/algorithms/lfda.rst @@ -1,8 +1,12 @@ Local Fisher Discriminant Analysis (LFDA) ===================================== +LFDA is a linear supervised dimensionality reduction method and is particularly useful when dealing with multimodality where some class consists of separate clusters. LFDA has an analytic form of the embedding matrix and the solution can be easily computed just by solving a generalized eigenvalue problem. It is thus scalable to large datasets and computationally reliable. Example Code ------------------ References ------------------- \ No newline at end of file +------------------ +`Dimensionality Reduction of Multimodal Labeled Data by Local Fisher Discriminant Analysis `_ Masashi Sugiyama. + +`Local Fisher Discriminant Analysis on Beer Style Clustering `_ Yuan Tang. \ No newline at end of file diff --git a/doc/source/algorithms/rca.rst b/doc/source/algorithms/rca.rst index f6ed8b39..ec547a20 100644 --- a/doc/source/algorithms/rca.rst +++ b/doc/source/algorithms/rca.rst @@ -7,4 +7,4 @@ Example Code References ------------------ -`Adjustment learning and relevant component analysis `_ Shental, Noam, et al. \ No newline at end of file +`Adjustment learning and relevant component analysis `_ Noam Shental, et al. \ No newline at end of file