diff --git a/doc/Figures/tick.png b/doc/Figures/tick.png deleted file mode 100644 index 1175c802..00000000 Binary files a/doc/Figures/tick.png and /dev/null differ diff --git a/doc/Figures/tuto_GP_regression_m1.png b/doc/Figures/tuto_GP_regression_m1.png deleted file mode 100644 index e1a11fb1..00000000 Binary files a/doc/Figures/tuto_GP_regression_m1.png and /dev/null differ diff --git a/doc/Figures/tuto_GP_regression_m2.png b/doc/Figures/tuto_GP_regression_m2.png deleted file mode 100644 index 7e54e919..00000000 Binary files a/doc/Figures/tuto_GP_regression_m2.png and /dev/null differ diff --git a/doc/Figures/tuto_GP_regression_m3.png b/doc/Figures/tuto_GP_regression_m3.png deleted file mode 100644 index 5b2b227c..00000000 Binary files a/doc/Figures/tuto_GP_regression_m3.png and /dev/null differ diff --git a/doc/Figures/tuto_kern_overview_add_orth.png b/doc/Figures/tuto_kern_overview_add_orth.png deleted file mode 100644 index 0d4f1c4e..00000000 Binary files a/doc/Figures/tuto_kern_overview_add_orth.png and /dev/null differ diff --git a/doc/Figures/tuto_kern_overview_allkern.png b/doc/Figures/tuto_kern_overview_allkern.png deleted file mode 100644 index f3406b07..00000000 Binary files a/doc/Figures/tuto_kern_overview_allkern.png and /dev/null differ diff --git a/doc/Figures/tuto_kern_overview_basicplot.png b/doc/Figures/tuto_kern_overview_basicplot.png deleted file mode 100644 index bad43b09..00000000 Binary files a/doc/Figures/tuto_kern_overview_basicplot.png and /dev/null differ diff --git a/doc/Figures/tuto_kern_overview_mANOVA.png b/doc/Figures/tuto_kern_overview_mANOVA.png deleted file mode 100644 index 255a3a80..00000000 Binary files a/doc/Figures/tuto_kern_overview_mANOVA.png and /dev/null differ diff --git a/doc/Figures/tuto_kern_overview_mANOVAdec.png b/doc/Figures/tuto_kern_overview_mANOVAdec.png deleted file mode 100644 index 45b7ae2a..00000000 Binary files a/doc/Figures/tuto_kern_overview_mANOVAdec.png and /dev/null differ diff --git a/doc/Figures/tuto_kern_overview_multadd.png b/doc/Figures/tuto_kern_overview_multadd.png deleted file mode 100644 index 72b6797b..00000000 Binary files a/doc/Figures/tuto_kern_overview_multadd.png and /dev/null differ diff --git a/doc/Figures/tuto_kern_overview_multperdecay.png b/doc/Figures/tuto_kern_overview_multperdecay.png deleted file mode 100644 index 3970d342..00000000 Binary files a/doc/Figures/tuto_kern_overview_multperdecay.png and /dev/null differ diff --git a/doc/GPy.kern._src.psi_comp.rst b/doc/GPy.kern._src.psi_comp.rst deleted file mode 100644 index d84eeaa0..00000000 --- a/doc/GPy.kern._src.psi_comp.rst +++ /dev/null @@ -1,62 +0,0 @@ -GPy.kern._src.psi_comp package -============================== - -Submodules ----------- - -GPy.kern._src.psi_comp.linear_psi_comp module ---------------------------------------------- - -.. automodule:: GPy.kern._src.psi_comp.linear_psi_comp - :members: - :undoc-members: - :show-inheritance: - -GPy.kern._src.psi_comp.rbf_psi_comp module ------------------------------------------- - -.. automodule:: GPy.kern._src.psi_comp.rbf_psi_comp - :members: - :undoc-members: - :show-inheritance: - -GPy.kern._src.psi_comp.rbf_psi_gpucomp module ---------------------------------------------- - -.. automodule:: GPy.kern._src.psi_comp.rbf_psi_gpucomp - :members: - :undoc-members: - :show-inheritance: - -GPy.kern._src.psi_comp.sslinear_psi_comp module ------------------------------------------------ - -.. automodule:: GPy.kern._src.psi_comp.sslinear_psi_comp - :members: - :undoc-members: - :show-inheritance: - -GPy.kern._src.psi_comp.ssrbf_psi_comp module --------------------------------------------- - -.. automodule:: GPy.kern._src.psi_comp.ssrbf_psi_comp - :members: - :undoc-members: - :show-inheritance: - -GPy.kern._src.psi_comp.ssrbf_psi_gpucomp module ------------------------------------------------ - -.. automodule:: GPy.kern._src.psi_comp.ssrbf_psi_gpucomp - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: GPy.kern._src.psi_comp - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/GPy.kern._src.rst b/doc/GPy.kern._src.rst deleted file mode 100644 index 93dc0058..00000000 --- a/doc/GPy.kern._src.rst +++ /dev/null @@ -1,197 +0,0 @@ -GPy.kern._src package -===================== - -Subpackages ------------ - -.. toctree:: - - GPy.kern._src.psi_comp - -Submodules ----------- - -GPy.kern._src.ODE_UY module ---------------------------- - -.. automodule:: GPy.kern._src.ODE_UY - :members: - :undoc-members: - :show-inheritance: - -GPy.kern._src.ODE_UYC module ----------------------------- - -.. automodule:: GPy.kern._src.ODE_UYC - :members: - :undoc-members: - :show-inheritance: - -GPy.kern._src.ODE_st module ---------------------------- - -.. automodule:: GPy.kern._src.ODE_st - :members: - :undoc-members: - :show-inheritance: - -GPy.kern._src.ODE_t module --------------------------- - -.. automodule:: GPy.kern._src.ODE_t - :members: - :undoc-members: - :show-inheritance: - -GPy.kern._src.add module ------------------------- - -.. automodule:: GPy.kern._src.add - :members: - :undoc-members: - :show-inheritance: - -GPy.kern._src.brownian module ------------------------------ - -.. automodule:: GPy.kern._src.brownian - :members: - :undoc-members: - :show-inheritance: - -GPy.kern._src.coregionalize module ----------------------------------- - -.. automodule:: GPy.kern._src.coregionalize - :members: - :undoc-members: - :show-inheritance: - -GPy.kern._src.hierarchical module ---------------------------------- - -.. automodule:: GPy.kern._src.hierarchical - :members: - :undoc-members: - :show-inheritance: - -GPy.kern._src.independent_outputs module ----------------------------------------- - -.. automodule:: GPy.kern._src.independent_outputs - :members: - :undoc-members: - :show-inheritance: - -GPy.kern._src.kern module -------------------------- - -.. automodule:: GPy.kern._src.kern - :members: - :undoc-members: - :show-inheritance: - -GPy.kern._src.kernel_slice_operations module --------------------------------------------- - -.. automodule:: GPy.kern._src.kernel_slice_operations - :members: - :undoc-members: - :show-inheritance: - -GPy.kern._src.linear module ---------------------------- - -.. automodule:: GPy.kern._src.linear - :members: - :undoc-members: - :show-inheritance: - -GPy.kern._src.mlp module ------------------------- - -.. automodule:: GPy.kern._src.mlp - :members: - :undoc-members: - :show-inheritance: - -GPy.kern._src.periodic module ------------------------------ - -.. automodule:: GPy.kern._src.periodic - :members: - :undoc-members: - :show-inheritance: - -GPy.kern._src.poly module -------------------------- - -.. automodule:: GPy.kern._src.poly - :members: - :undoc-members: - :show-inheritance: - -GPy.kern._src.prod module -------------------------- - -.. automodule:: GPy.kern._src.prod - :members: - :undoc-members: - :show-inheritance: - -GPy.kern._src.rbf module ------------------------- - -.. automodule:: GPy.kern._src.rbf - :members: - :undoc-members: - :show-inheritance: - -GPy.kern._src.splitKern module ------------------------------- - -.. automodule:: GPy.kern._src.splitKern - :members: - :undoc-members: - :show-inheritance: - -GPy.kern._src.static module ---------------------------- - -.. automodule:: GPy.kern._src.static - :members: - :undoc-members: - :show-inheritance: - -GPy.kern._src.stationary module -------------------------------- - -.. automodule:: GPy.kern._src.stationary - :members: - :undoc-members: - :show-inheritance: - -GPy.kern._src.symbolic module ------------------------------ - -.. automodule:: GPy.kern._src.symbolic - :members: - :undoc-members: - :show-inheritance: - -GPy.kern._src.trunclinear module --------------------------------- - -.. automodule:: GPy.kern._src.trunclinear - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: GPy.kern._src - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/Makefile b/doc/Makefile index 546113b3..e064cc60 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -2,19 +2,24 @@ # # You can set these variables from the command line. -SPHINXOPTS = -a -w log.txt -E +SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = -BUILDDIR = _build +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) . +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source # the i18n builder cannot share the environment and doctrees with the others -I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source -.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext +.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" @@ -25,22 +30,26 @@ help: @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)/* - + rm -rf $(BUILDDIR)/* html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @@ -82,6 +91,14 @@ qthelp: @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/GPy.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 @@ -109,6 +126,12 @@ latexpdf: $(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 @@ -152,3 +175,18 @@ 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/conf.py b/doc/conf.py deleted file mode 100644 index 39bb4ceb..00000000 --- a/doc/conf.py +++ /dev/null @@ -1,429 +0,0 @@ -# -*- coding: utf-8 -*- -# -# GPy documentation build configuration file, created by -# sphinx-quickstart on Fri Jan 18 15:30:28 2013. -# -# 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. - -#autodoc_default_flags = ['members', 'show-inheritance', 'private-members', 'special-members'] -#autodoc_default_flags = ['private-members', 'special-members'] -#autodoc_default_flags = 'private-members' -#autodoc_member_order = "source" - -#def autodoc_skip_member(app, what, name, obj, skip, options): - #exclusions = ('__weakref__', # special-members - #'__doc__', '__module__', '__dict__', # undoc-members - #) - #exclude = name in exclusions - - #inclusions = ('_src') - #include = name in inclusions - #if include: - #print app, what, name, obj, skip, options - #return False - #return skip or exclude - -#def setup(app): - ##app.connect('autodoc-process-docstring', cut_lines(2)) - ##app.connect('autodoc_default_flags', autodoc_default_flags) - ##app.connect('autodoc_member_order', autodoc_member_order) - #app.connect('autodoc-skip-member', autodoc_skip_member) - -import sys -import os - -print "python exec:", sys.executable -print "sys.path:", sys.path -try: - import numpy - print "numpy: %s, %s" % (numpy.__version__, numpy.__file__) -except ImportError: - print "no numpy" -try: - import matplotlib - print "matplotlib: %s, %s" % (matplotlib.__version__, matplotlib.__file__) -except ImportError: - print "no matplotlib" -try: - import ipython - print "ipython: %s, %s" % (ipython.__version__, ipython.__file__) -except ImportError: - print "no ipython" -try: - import sphinx - print "sphinx: %s, %s" % (sphinx.__version__, sphinx.__file__) -except ImportError: - print "no sphinx" - -print "sys.path:", sys.path - -# 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('../GPy')) - -#print "sys.path.after:", sys.path - -# If your extensions are in another directory, add it here. If the directory -# is relative to the documentation root, use os.path.abspath to make it -# absolute, like shown here. -sys.path.append(os.path.abspath('sphinxext')) - -# 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('./sphinxext')) - -# -- 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. -print "Importing extensions" - -extensions = ['sphinx.ext.autodoc', - #'sphinx.ext.doctest' - 'sphinx.ext.viewcode', - #'sphinx.ext.pngmath', - 'sphinx.ext.mathjax', - # 'ipython_directive', - # 'ipython_console_highlighting' - #'matplotlib.sphinxext.plot_directive' - ] -plot_formats = [('png', 80), ('pdf', 50)] - -#pngmath_latex_preamble=r'\usepackage[active]{preview}\usepackage{MnSymbol}' # + other custom stuff for inline math, such as non-default math fonts etc. -#pngmath_use_preview=True - -print "finished importing" - -############################################################################## -## -## Mock out imports with C dependencies because ReadTheDocs can't build them. -############################################################################# - -class Mock(object): - __all__ = [] - def __init__(self, *args, **kwargs): - pass - - def __call__(self, *args, **kwargs): - return Mock() - - @classmethod - def __getattr__(cls, name): - if name in ('__file__', '__path__'): - return '/dev/null' - elif name[0] == name[0].upper(): - mockType = type(name, (), {}) - mockType.__module__ = __name__ - return mockType - else: - return Mock() - -#import mock - -print "Mocking" -MOCK_MODULES = ['scipy.linalg', 'scipy.linalg.lapack', 'scipy.special', 'scipy.io', 'scipy.integrate', 'scipy.linalg', 'scipy.linalg.cython_blas', 'scipy.optimize', - 'sympy.utilities', 'sympy.utilities.codegen', 'sympy.core.cache', - 'sympy.core', 'sympy.parsing', 'sympy.parsing.sympy_parser', 'Tango', 'numdifftools' - ] -for mod_name in MOCK_MODULES: - sys.modules[mod_name] = Mock() - - -# ----------------------- READTHEDOCS ------------------ -on_rtd = os.environ.get('READTHEDOCS', None) == 'True' - -#on_rtd = True -if on_rtd: - sys.path.append(os.path.abspath('../GPy')) - - import subprocess - - proc = subprocess.Popen("pwd", stdout=subprocess.PIPE, shell=True) - (out, err) = proc.communicate() - print "program output:", out - proc = subprocess.Popen("ls ../", stdout=subprocess.PIPE, shell=True) - (out, err) = proc.communicate() - print "program output:", out - #Lets regenerate our rst files from the source, -P adds private modules (i.e kern._src) - proc = subprocess.Popen("sphinx-apidoc -P -f -o . ../GPy", stdout=subprocess.PIPE, shell=True) - (out, err) = proc.communicate() - print "program output:", out - #proc = subprocess.Popen("whereis numpy", stdout=subprocess.PIPE, shell=True) - #(out, err) = proc.communicate() - #print "program output:", out - #proc = subprocess.Popen("whereis matplotlib", stdout=subprocess.PIPE, shell=True) - #(out, err) = proc.communicate() - #print "program output:", out - -print "Compiled files" - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - -# The suffix of source filenames. -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'GPy' -copyright = u'2013, Author' - -# 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 = '' -# The full version, including alpha/beta/rc tags. -release = '' - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -#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 = ['_build'] - -# 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 = 'default' - -# A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] - - -# -- 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 = 'alabaster' - -# This is to revert to the default theme on readthedocs -html_style = '/alabaster.css' - -# 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'] - -# 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 - -# Output file base name for HTML help builder. -htmlhelp_basename = 'GPydoc' - - -# -- 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': '\\usepackage{MnSymbol,amsmath}', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, author, documentclass [howto/manual]). -latex_documents = [ - ('index', 'GPy.tex', u'GPy Documentation', - u'Author', '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 = [ - ('index', 'gpy', u'GPy Documentation', - [u'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 = [ - ('index', 'GPy', u'GPy Documentation', - u'Author', 'GPy', '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' - - -# -- Options for Epub output --------------------------------------------------- - -# Bibliographic Dublin Core info. -epub_title = u'GPy' -epub_author = u'Author' -epub_publisher = u'Author' -epub_copyright = u'2013, Author' - -# 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 = () - -# 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 = [] - -# The depth of the table of contents in toc.ncx. -#epub_tocdepth = 3 - -# Allow duplicate toc entries. -#epub_tocdup = True diff --git a/doc/doc-requirements.txt b/doc/doc-requirements.txt deleted file mode 100644 index 0b5ac59b..00000000 --- a/doc/doc-requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -ipython -numpy -scipy diff --git a/doc/installation.rst b/doc/installation.rst deleted file mode 100644 index 35352272..00000000 --- a/doc/installation.rst +++ /dev/null @@ -1,31 +0,0 @@ -============== - Installation -============== - - -Linux -============ - - -Windows -====================== -One easy way to get a Python distribution with the required packages is to use the Anaconda environment from Continuum Analytics. - -* Download and install the free version of Anaconda according to your operating system from `their website `_. -* Open a (new) terminal window: - - * Navigate to Applications/Accessories/cmd, or - * open *anaconda Command Prompt* from windows *start* - -You should now be able to launch a Python interpreter by typing *ipython* in the terminal. In the ipython prompt, you can check your installation by importing the libraries we will need later: -:: - $ import numpy - $ import pylab - -To install the latest version of GPy, *git* is required. A *git* client on Windows can be found `here `_. It is recommened to install with the option "*Use Git from the Windows Command Prompt*". Then, GPy can be installed with the following command -:: - pip install git+https://github.com/SheffieldML/GPy.git@devel - -MacOSX -=================================== - diff --git a/doc/kernel_implementation.rst b/doc/kernel_implementation.rst deleted file mode 100644 index c566d21d..00000000 --- a/doc/kernel_implementation.rst +++ /dev/null @@ -1,49 +0,0 @@ - -*************************** -List of implemented kernels -*************************** - -The following table shows the implemented kernels in GPy and gives the details of the implemented function for each kernel. - -==================== =========== ===== =========== ====== ======= =========== =============== ======= =========== ====== ====== ======= -NAME Dimension ARD get/set K Kdiag dK_dtheta dKdiag_dtheta dK_dX dKdiag_dX psi0 psi1 psi2 -==================== =========== ===== =========== ====== ======= =========== =============== ======= =========== ====== ====== ======= -bias n |tick| |tick| |tick| |tick| |tick| |tick| |tick| |tick| |tick| |tick| --------------------- ----------- ----- ----------- ------ ------- ----------- --------------- ------- ----------- ------ ------ ------- -Brownian 1 |tick| |tick| |tick| |tick| |tick| |tick| |tick| --------------------- ----------- ----- ----------- ------ ------- ----------- --------------- ------- ----------- ------ ------ ------- -exponential n yes |tick| |tick| |tick| |tick| |tick| |tick| |tick| --------------------- ----------- ----- ----------- ------ ------- ----------- --------------- ------- ----------- ------ ------ ------- -finite_dimensional n |tick| |tick| |tick| |tick| |tick| --------------------- ----------- ----- ----------- ------ ------- ----------- --------------- ------- ----------- ------ ------ ------- -linear n yes |tick| |tick| |tick| |tick| |tick| |tick| |tick| |tick| |tick| --------------------- ----------- ----- ----------- ------ ------- ----------- --------------- ------- ----------- ------ ------ ------- -Matern32 n yes |tick| |tick| |tick| |tick| |tick| |tick| |tick| --------------------- ----------- ----- ----------- ------ ------- ----------- --------------- ------- ----------- ------ ------ ------- -Matern52 n yes |tick| |tick| |tick| |tick| |tick| |tick| |tick| --------------------- ----------- ----- ----------- ------ ------- ----------- --------------- ------- ----------- ------ ------ ------- -periodic_exponential 1 |tick| |tick| |tick| |tick| |tick| --------------------- ----------- ----- ----------- ------ ------- ----------- --------------- ------- ----------- ------ ------ ------- -periodic_Matern32 1 |tick| |tick| |tick| |tick| |tick| --------------------- ----------- ----- ----------- ------ ------- ----------- --------------- ------- ----------- ------ ------ ------- -periodic_Matern52 1 |tick| |tick| |tick| |tick| |tick| --------------------- ----------- ----- ----------- ------ ------- ----------- --------------- ------- ----------- ------ ------ ------- -rational quadratic 1 |tick| |tick| |tick| |tick| |tick| |tick| |tick| --------------------- ----------- ----- ----------- ------ ------- ----------- --------------- ------- ----------- ------ ------ ------- -rbf n yes |tick| |tick| |tick| |tick| |tick| |tick| |tick| |tick| |tick| |tick| --------------------- ----------- ----- ----------- ------ ------- ----------- --------------- ------- ----------- ------ ------ ------- -spline 1 |tick| |tick| |tick| |tick| |tick| |tick| --------------------- ----------- ----- ----------- ------ ------- ----------- --------------- ------- ----------- ------ ------ ------- -white n |tick| |tick| |tick| |tick| |tick| |tick| |tick| |tick| |tick| |tick| -==================== =========== ===== =========== ====== ======= =========== =============== ======= =========== ====== ====== ======= - -Depending on the use, all functions may not be required - - * ``get/set, K, Kdiag``: compulsory - * ``dK_dtheta``: necessary to optimize the model - * ``dKdiag_dtheta``: sparse models, BGPLVM, GPs with uncertain inputs - * ``dK_dX``: sparse models, GPLVM, BGPLVM, GPs with uncertain inputs - * ``dKdiag_dX``: sparse models, BGPLVM, GPs with uncertain inputs - * ``psi0, psi1, psi2``: BGPLVM, GPs with uncertain inputs - -.. |tick| image:: Figures/tick.png diff --git a/doc/make.bat b/doc/make.bat deleted file mode 100644 index 40a74901..00000000 --- a/doc/make.bat +++ /dev/null @@ -1,190 +0,0 @@ -@ECHO OFF - -REM Command file for Sphinx documentation - -if "%SPHINXBUILD%" == "" ( - set SPHINXBUILD=sphinx-build -) -set BUILDDIR=_build -set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . -set I18NSPHINXOPTS=%SPHINXOPTS% . -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. linkcheck to check all external links for integrity - echo. doctest to run all doctests embedded in 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 -) - -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\GPy.qhcp - echo.To view the help file: - echo.^> assistant -collectionFile %BUILDDIR%\qthelp\GPy.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" == "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 -) - -:end diff --git a/doc/source/.#conf.py b/doc/source/.#conf.py new file mode 120000 index 00000000..307d8733 --- /dev/null +++ b/doc/source/.#conf.py @@ -0,0 +1 @@ +maxz@maxz-sitran.8058:1442579222 \ No newline at end of file diff --git a/doc/GPy.core.parameterization.rst b/doc/source/GPy.core.parameterization.rst similarity index 86% rename from doc/GPy.core.parameterization.rst rename to doc/source/GPy.core.parameterization.rst index 4877a06d..788e3af8 100644 --- a/doc/GPy.core.parameterization.rst +++ b/doc/source/GPy.core.parameterization.rst @@ -28,6 +28,14 @@ GPy.core.parameterization.lists_and_dicts module :undoc-members: :show-inheritance: +GPy.core.parameterization.observable module +------------------------------------------- + +.. automodule:: GPy.core.parameterization.observable + :members: + :undoc-members: + :show-inheritance: + GPy.core.parameterization.observable_array module ------------------------------------------------- @@ -84,6 +92,14 @@ GPy.core.parameterization.transformations module :undoc-members: :show-inheritance: +GPy.core.parameterization.updateable module +------------------------------------------- + +.. automodule:: GPy.core.parameterization.updateable + :members: + :undoc-members: + :show-inheritance: + GPy.core.parameterization.variational module -------------------------------------------- diff --git a/doc/GPy.core.rst b/doc/source/GPy.core.rst similarity index 82% rename from doc/GPy.core.rst rename to doc/source/GPy.core.rst index 3c236612..66878101 100644 --- a/doc/GPy.core.rst +++ b/doc/source/GPy.core.rst @@ -51,10 +51,10 @@ GPy.core.sparse_gp_mpi module :undoc-members: :show-inheritance: -GPy.core.svigp module ---------------------- +GPy.core.svgp module +-------------------- -.. automodule:: GPy.core.svigp +.. automodule:: GPy.core.svgp :members: :undoc-members: :show-inheritance: @@ -67,6 +67,14 @@ GPy.core.symbolic module :undoc-members: :show-inheritance: +GPy.core.verbose_optimization module +------------------------------------ + +.. automodule:: GPy.core.verbose_optimization + :members: + :undoc-members: + :show-inheritance: + Module contents --------------- diff --git a/doc/GPy.examples.rst b/doc/source/GPy.examples.rst similarity index 76% rename from doc/GPy.examples.rst rename to doc/source/GPy.examples.rst index 7fc8a123..a2919eab 100644 --- a/doc/GPy.examples.rst +++ b/doc/source/GPy.examples.rst @@ -44,22 +44,6 @@ GPy.examples.regression module :undoc-members: :show-inheritance: -GPy.examples.stochastic module ------------------------------- - -.. automodule:: GPy.examples.stochastic - :members: - :undoc-members: - :show-inheritance: - -GPy.examples.tutorials module ------------------------------ - -.. automodule:: GPy.examples.tutorials - :members: - :undoc-members: - :show-inheritance: - Module contents --------------- diff --git a/doc/GPy.inference.latent_function_inference.rst b/doc/source/GPy.inference.latent_function_inference.rst similarity index 86% rename from doc/GPy.inference.latent_function_inference.rst rename to doc/source/GPy.inference.latent_function_inference.rst index 98d16705..c374e73b 100644 --- a/doc/GPy.inference.latent_function_inference.rst +++ b/doc/source/GPy.inference.latent_function_inference.rst @@ -28,14 +28,6 @@ GPy.inference.latent_function_inference.expectation_propagation module :undoc-members: :show-inheritance: -GPy.inference.latent_function_inference.expectation_propagation_dtc module --------------------------------------------------------------------------- - -.. automodule:: GPy.inference.latent_function_inference.expectation_propagation_dtc - :members: - :undoc-members: - :show-inheritance: - GPy.inference.latent_function_inference.fitc module --------------------------------------------------- @@ -68,18 +60,18 @@ GPy.inference.latent_function_inference.posterior module :undoc-members: :show-inheritance: -GPy.inference.latent_function_inference.var_dtc module ------------------------------------------------------- +GPy.inference.latent_function_inference.svgp module +--------------------------------------------------- -.. automodule:: GPy.inference.latent_function_inference.var_dtc +.. automodule:: GPy.inference.latent_function_inference.svgp :members: :undoc-members: :show-inheritance: -GPy.inference.latent_function_inference.var_dtc_gpu module ----------------------------------------------------------- +GPy.inference.latent_function_inference.var_dtc module +------------------------------------------------------ -.. automodule:: GPy.inference.latent_function_inference.var_dtc_gpu +.. automodule:: GPy.inference.latent_function_inference.var_dtc :members: :undoc-members: :show-inheritance: @@ -92,6 +84,14 @@ GPy.inference.latent_function_inference.var_dtc_parallel module :undoc-members: :show-inheritance: +GPy.inference.latent_function_inference.var_gauss module +-------------------------------------------------------- + +.. automodule:: GPy.inference.latent_function_inference.var_gauss + :members: + :undoc-members: + :show-inheritance: + Module contents --------------- diff --git a/doc/GPy.inference.mcmc.rst b/doc/source/GPy.inference.mcmc.rst similarity index 100% rename from doc/GPy.inference.mcmc.rst rename to doc/source/GPy.inference.mcmc.rst diff --git a/doc/GPy.inference.optimization.rst b/doc/source/GPy.inference.optimization.rst similarity index 88% rename from doc/GPy.inference.optimization.rst rename to doc/source/GPy.inference.optimization.rst index a81a8e68..f5f2a930 100644 --- a/doc/GPy.inference.optimization.rst +++ b/doc/source/GPy.inference.optimization.rst @@ -36,14 +36,6 @@ GPy.inference.optimization.scg module :undoc-members: :show-inheritance: -GPy.inference.optimization.sgd module -------------------------------------- - -.. automodule:: GPy.inference.optimization.sgd - :members: - :undoc-members: - :show-inheritance: - GPy.inference.optimization.stochastics module --------------------------------------------- diff --git a/doc/GPy.inference.rst b/doc/source/GPy.inference.rst similarity index 100% rename from doc/GPy.inference.rst rename to doc/source/GPy.inference.rst diff --git a/doc/GPy.kern.rst b/doc/source/GPy.kern.rst similarity index 72% rename from doc/GPy.kern.rst rename to doc/source/GPy.kern.rst index 5a0c61c2..9ee59ed6 100644 --- a/doc/GPy.kern.rst +++ b/doc/source/GPy.kern.rst @@ -1,13 +1,6 @@ GPy.kern package ================ -Subpackages ------------ - -.. toctree:: - - GPy.kern._src - Module contents --------------- diff --git a/doc/GPy.likelihoods.rst b/doc/source/GPy.likelihoods.rst similarity index 91% rename from doc/GPy.likelihoods.rst rename to doc/source/GPy.likelihoods.rst index 323bb609..15d1952b 100644 --- a/doc/GPy.likelihoods.rst +++ b/doc/source/GPy.likelihoods.rst @@ -12,6 +12,14 @@ GPy.likelihoods.bernoulli module :undoc-members: :show-inheritance: +GPy.likelihoods.binomial module +------------------------------- + +.. automodule:: GPy.likelihoods.binomial + :members: + :undoc-members: + :show-inheritance: + GPy.likelihoods.exponential module ---------------------------------- diff --git a/doc/GPy.mappings.rst b/doc/source/GPy.mappings.rst similarity index 54% rename from doc/GPy.mappings.rst rename to doc/source/GPy.mappings.rst index c13642cc..dad16d34 100644 --- a/doc/GPy.mappings.rst +++ b/doc/source/GPy.mappings.rst @@ -12,6 +12,30 @@ GPy.mappings.additive module :undoc-members: :show-inheritance: +GPy.mappings.compound module +---------------------------- + +.. automodule:: GPy.mappings.compound + :members: + :undoc-members: + :show-inheritance: + +GPy.mappings.constant module +---------------------------- + +.. automodule:: GPy.mappings.constant + :members: + :undoc-members: + :show-inheritance: + +GPy.mappings.identity module +---------------------------- + +.. automodule:: GPy.mappings.identity + :members: + :undoc-members: + :show-inheritance: + GPy.mappings.kernel module -------------------------- @@ -36,6 +60,14 @@ GPy.mappings.mlp module :undoc-members: :show-inheritance: +GPy.mappings.piecewise_linear module +------------------------------------ + +.. automodule:: GPy.mappings.piecewise_linear + :members: + :undoc-members: + :show-inheritance: + Module contents --------------- diff --git a/doc/GPy.models.rst b/doc/source/GPy.models.rst similarity index 92% rename from doc/GPy.models.rst rename to doc/source/GPy.models.rst index cb043afa..e65b4fb0 100644 --- a/doc/GPy.models.rst +++ b/doc/source/GPy.models.rst @@ -28,6 +28,14 @@ GPy.models.bcgplvm module :undoc-members: :show-inheritance: +GPy.models.dpgplvm module +------------------------- + +.. automodule:: GPy.models.dpgplvm + :members: + :undoc-members: + :show-inheritance: + GPy.models.gp_classification module ----------------------------------- @@ -60,14 +68,6 @@ GPy.models.gp_kronecker_gaussian_regression module :undoc-members: :show-inheritance: -GPy.models.gp_multioutput_regression module -------------------------------------------- - -.. automodule:: GPy.models.gp_multioutput_regression - :members: - :undoc-members: - :show-inheritance: - GPy.models.gp_regression module ------------------------------- @@ -108,6 +108,22 @@ GPy.models.mrd module :undoc-members: :show-inheritance: +GPy.models.one_vs_all_classification module +------------------------------------------- + +.. automodule:: GPy.models.one_vs_all_classification + :members: + :undoc-members: + :show-inheritance: + +GPy.models.one_vs_all_sparse_classification module +-------------------------------------------------- + +.. automodule:: GPy.models.one_vs_all_sparse_classification + :members: + :undoc-members: + :show-inheritance: + GPy.models.sparse_gp_classification module ------------------------------------------ @@ -132,14 +148,6 @@ GPy.models.sparse_gp_minibatch module :undoc-members: :show-inheritance: -GPy.models.sparse_gp_multioutput_regression module --------------------------------------------------- - -.. automodule:: GPy.models.sparse_gp_multioutput_regression - :members: - :undoc-members: - :show-inheritance: - GPy.models.sparse_gp_regression module -------------------------------------- @@ -172,14 +180,6 @@ GPy.models.ss_mrd module :undoc-members: :show-inheritance: -GPy.models.svigp_regression module ----------------------------------- - -.. automodule:: GPy.models.svigp_regression - :members: - :undoc-members: - :show-inheritance: - GPy.models.warped_gp module --------------------------- diff --git a/doc/GPy.plotting.matplot_dep.latent_space_visualizations.controllers.rst b/doc/source/GPy.plotting.matplot_dep.latent_space_visualizations.controllers.rst similarity index 100% rename from doc/GPy.plotting.matplot_dep.latent_space_visualizations.controllers.rst rename to doc/source/GPy.plotting.matplot_dep.latent_space_visualizations.controllers.rst diff --git a/doc/GPy.plotting.matplot_dep.latent_space_visualizations.rst b/doc/source/GPy.plotting.matplot_dep.latent_space_visualizations.rst similarity index 100% rename from doc/GPy.plotting.matplot_dep.latent_space_visualizations.rst rename to doc/source/GPy.plotting.matplot_dep.latent_space_visualizations.rst diff --git a/doc/GPy.plotting.matplot_dep.rst b/doc/source/GPy.plotting.matplot_dep.rst similarity index 100% rename from doc/GPy.plotting.matplot_dep.rst rename to doc/source/GPy.plotting.matplot_dep.rst diff --git a/doc/GPy.plotting.rst b/doc/source/GPy.plotting.rst similarity index 100% rename from doc/GPy.plotting.rst rename to doc/source/GPy.plotting.rst diff --git a/doc/GPy.rst b/doc/source/GPy.rst similarity index 100% rename from doc/GPy.rst rename to doc/source/GPy.rst diff --git a/doc/GPy.testing.rst b/doc/source/GPy.testing.rst similarity index 50% rename from doc/GPy.testing.rst rename to doc/source/GPy.testing.rst index 45bb307f..9ee1e34b 100644 --- a/doc/GPy.testing.rst +++ b/doc/source/GPy.testing.rst @@ -4,6 +4,30 @@ GPy.testing package Submodules ---------- +GPy.testing.bgplvm_minibatch_tests module +----------------------------------------- + +.. automodule:: GPy.testing.bgplvm_minibatch_tests + :members: + :undoc-members: + :show-inheritance: + +GPy.testing.cacher_tests module +------------------------------- + +.. automodule:: GPy.testing.cacher_tests + :members: + :undoc-members: + :show-inheritance: + +GPy.testing.cython_tests module +------------------------------- + +.. automodule:: GPy.testing.cython_tests + :members: + :undoc-members: + :show-inheritance: + GPy.testing.examples_tests module --------------------------------- @@ -20,6 +44,14 @@ GPy.testing.fitc module :undoc-members: :show-inheritance: +GPy.testing.gp_tests module +--------------------------- + +.. automodule:: GPy.testing.gp_tests + :members: + :undoc-members: + :show-inheritance: + GPy.testing.index_operations_tests module ----------------------------------------- @@ -52,6 +84,46 @@ GPy.testing.likelihood_tests module :undoc-members: :show-inheritance: +GPy.testing.linalg_test module +------------------------------ + +.. automodule:: GPy.testing.linalg_test + :members: + :undoc-members: + :show-inheritance: + +GPy.testing.link_function_tests module +-------------------------------------- + +.. automodule:: GPy.testing.link_function_tests + :members: + :undoc-members: + :show-inheritance: + +GPy.testing.mapping_tests module +-------------------------------- + +.. automodule:: GPy.testing.mapping_tests + :members: + :undoc-members: + :show-inheritance: + +GPy.testing.meanfunc_tests module +--------------------------------- + +.. automodule:: GPy.testing.meanfunc_tests + :members: + :undoc-members: + :show-inheritance: + +GPy.testing.misc_tests module +----------------------------- + +.. automodule:: GPy.testing.misc_tests + :members: + :undoc-members: + :show-inheritance: + GPy.testing.model_tests module ------------------------------ @@ -60,6 +132,14 @@ GPy.testing.model_tests module :undoc-members: :show-inheritance: +GPy.testing.mpi_tests module +---------------------------- + +.. automodule:: GPy.testing.mpi_tests + :members: + :undoc-members: + :show-inheritance: + GPy.testing.observable_tests module ----------------------------------- @@ -92,6 +172,22 @@ GPy.testing.prior_tests module :undoc-members: :show-inheritance: +GPy.testing.rv_transformation_tests module +------------------------------------------ + +.. automodule:: GPy.testing.rv_transformation_tests + :members: + :undoc-members: + :show-inheritance: + +GPy.testing.svgp_tests module +----------------------------- + +.. automodule:: GPy.testing.svgp_tests + :members: + :undoc-members: + :show-inheritance: + Module contents --------------- diff --git a/doc/GPy.util.rst b/doc/source/GPy.util.rst similarity index 91% rename from doc/GPy.util.rst rename to doc/source/GPy.util.rst index e50efdfb..354a3cce 100644 --- a/doc/GPy.util.rst +++ b/doc/source/GPy.util.rst @@ -20,6 +20,22 @@ GPy.util.caching module :undoc-members: :show-inheritance: +GPy.util.choleskies module +-------------------------- + +.. automodule:: GPy.util.choleskies + :members: + :undoc-members: + :show-inheritance: + +GPy.util.choleskies_cython module +--------------------------------- + +.. automodule:: GPy.util.choleskies_cython + :members: + :undoc-members: + :show-inheritance: + GPy.util.classification module ------------------------------ @@ -68,14 +84,6 @@ GPy.util.diag module :undoc-members: :show-inheritance: -GPy.util.erfcx module ---------------------- - -.. automodule:: GPy.util.erfcx - :members: - :undoc-members: - :show-inheritance: - GPy.util.functions module ------------------------- @@ -108,6 +116,14 @@ GPy.util.linalg module :undoc-members: :show-inheritance: +GPy.util.linalg_cython module +----------------------------- + +.. automodule:: GPy.util.linalg_cython + :members: + :undoc-members: + :show-inheritance: + GPy.util.linalg_gpu module -------------------------- @@ -140,14 +156,6 @@ GPy.util.mocap module :undoc-members: :show-inheritance: -GPy.util.mpi module -------------------- - -.. automodule:: GPy.util.mpi - :members: - :undoc-members: - :show-inheritance: - GPy.util.multioutput module --------------------------- diff --git a/doc/source/conf.py b/doc/source/conf.py new file mode 100644 index 00000000..f705064b --- /dev/null +++ b/doc/source/conf.py @@ -0,0 +1,289 @@ +# -*- coding: utf-8 -*- +# +# GPy documentation build configuration file, created by +# sphinx-quickstart on Fri Sep 18 18:16:28 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.coverage', + 'sphinx.ext.mathjax', + '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'GPy' +copyright = u'2015, GPy Authors' +author = u'GPy Authors' + +# 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.8.8' +# The full version, including alpha/beta/rc tags. +release = '0.8.8' + +# 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 = False + + +# -- 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 = 'alabaster' + +# 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 = 'GPydoc' + +# -- 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, 'GPy.tex', u'GPy Documentation', + u'GPy Authors', '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, 'gpy', u'GPy 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, 'GPy', u'GPy Documentation', + author, 'GPy', '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 diff --git a/doc/index.rst b/doc/source/index.rst similarity index 63% rename from doc/index.rst rename to doc/source/index.rst index b8e572a2..c35f1e3f 100644 --- a/doc/index.rst +++ b/doc/source/index.rst @@ -1,5 +1,5 @@ .. GPy documentation master file, created by - sphinx-quickstart on Fri Jan 18 17:36:01 2013. + sphinx-quickstart on Fri Sep 18 18:16:28 2015. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. @@ -13,26 +13,18 @@ This documentation is mostly aimed at developers interacting closely with the co The code can be found on our `Github project page `_. It is open source and provided under the BSD license. -.. * `Basic Gaussian process regression `_ -.. * `Interacting with models `_ -.. * `A kernel overview `_ -.. * `Writing new kernels `_ -.. * `Writing new models `_ -.. * `Parameterization handles `_ - -.. You may also be interested by some examples in the GPy/examples folder. - Contents: .. toctree:: - :maxdepth: 3 - + :maxdepth: 4 + GPy - + Indices and tables ================== * :ref:`genindex` * :ref:`modindex` * :ref:`search` + diff --git a/doc/source/index.rst~ b/doc/source/index.rst~ new file mode 100644 index 00000000..48ec0422 --- /dev/null +++ b/doc/source/index.rst~ @@ -0,0 +1,22 @@ +.. GPy documentation master file, created by + sphinx-quickstart on Fri Sep 18 18:16:28 2015. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to GPy's documentation! +=============================== + +Contents: + +.. toctree:: + :maxdepth: 2 + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + diff --git a/doc/modules.rst b/doc/source/modules.rst similarity index 100% rename from doc/modules.rst rename to doc/source/modules.rst diff --git a/doc/sphinxext/ipython_console_highlighting.py b/doc/sphinxext/ipython_console_highlighting.py deleted file mode 100644 index f5cced41..00000000 --- a/doc/sphinxext/ipython_console_highlighting.py +++ /dev/null @@ -1,115 +0,0 @@ -"""reST directive for syntax-highlighting ipython interactive sessions. - -XXX - See what improvements can be made based on the new (as of Sept 2009) -'pycon' lexer for the python console. At the very least it will give better -highlighted tracebacks. -""" - -#----------------------------------------------------------------------------- -# Needed modules - -# Standard library -import re - -# Third party -from pygments.lexer import Lexer, do_insertions -from pygments.lexers.agile import (PythonConsoleLexer, PythonLexer, - PythonTracebackLexer) -from pygments.token import Comment, Generic - -from sphinx import highlighting - -#----------------------------------------------------------------------------- -# Global constants -line_re = re.compile('.*?\n') - -#----------------------------------------------------------------------------- -# Code begins - classes and functions - -class IPythonConsoleLexer(Lexer): - """ - For IPython console output or doctests, such as: - - .. sourcecode:: ipython - - In [1]: a = 'foo' - - In [2]: a - Out[2]: 'foo' - - In [3]: print a - foo - - In [4]: 1 / 0 - - Notes: - - - Tracebacks are not currently supported. - - - It assumes the default IPython prompts, not customized ones. - """ - - name = 'IPython console session' - aliases = ['ipython'] - mimetypes = ['text/x-ipython-console'] - input_prompt = re.compile("(In \[[0-9]+\]: )|( \.\.\.+:)") - output_prompt = re.compile("(Out\[[0-9]+\]: )|( \.\.\.+:)") - continue_prompt = re.compile(" \.\.\.+:") - tb_start = re.compile("\-+") - - def get_tokens_unprocessed(self, text): - pylexer = PythonLexer(**self.options) - tblexer = PythonTracebackLexer(**self.options) - - curcode = '' - insertions = [] - for match in line_re.finditer(text): - line = match.group() - input_prompt = self.input_prompt.match(line) - continue_prompt = self.continue_prompt.match(line.rstrip()) - output_prompt = self.output_prompt.match(line) - if line.startswith("#"): - insertions.append((len(curcode), - [(0, Comment, line)])) - elif input_prompt is not None: - insertions.append((len(curcode), - [(0, Generic.Prompt, input_prompt.group())])) - curcode += line[input_prompt.end():] - elif continue_prompt is not None: - insertions.append((len(curcode), - [(0, Generic.Prompt, continue_prompt.group())])) - curcode += line[continue_prompt.end():] - elif output_prompt is not None: - # Use the 'error' token for output. We should probably make - # our own token, but error is typicaly in a bright color like - # red, so it works fine for our output prompts. - insertions.append((len(curcode), - [(0, Generic.Error, output_prompt.group())])) - curcode += line[output_prompt.end():] - else: - if curcode: - for item in do_insertions(insertions, - pylexer.get_tokens_unprocessed(curcode)): - yield item - curcode = '' - insertions = [] - yield match.start(), Generic.Output, line - if curcode: - for item in do_insertions(insertions, - pylexer.get_tokens_unprocessed(curcode)): - yield item - - -def setup(app): - """Setup as a sphinx extension.""" - - # This is only a lexer, so adding it below to pygments appears sufficient. - # But if somebody knows that the right API usage should be to do that via - # sphinx, by all means fix it here. At least having this setup.py - # suppresses the sphinx warning we'd get without it. - pass - -#----------------------------------------------------------------------------- -# Register the extension as a valid pygments lexer -highlighting.lexers['ipython'] = IPythonConsoleLexer() - diff --git a/doc/sphinxext/ipython_directive.py b/doc/sphinxext/ipython_directive.py deleted file mode 100644 index 2c2696c1..00000000 --- a/doc/sphinxext/ipython_directive.py +++ /dev/null @@ -1,835 +0,0 @@ -# -*- coding: utf-8 -*- -"""Sphinx directive to support embedded IPython code. - -This directive allows pasting of entire interactive IPython sessions, prompts -and all, and their code will actually get re-executed at doc build time, with -all prompts renumbered sequentially. It also allows you to input code as a pure -python input by giving the argument python to the directive. The output looks -like an interactive ipython section. - -To enable this directive, simply list it in your Sphinx ``conf.py`` file -(making sure the directory where you placed it is visible to sphinx, as is -needed for all Sphinx directives). - -By default this directive assumes that your prompts are unchanged IPython ones, -but this can be customized. The configurable options that can be placed in -conf.py are - -ipython_savefig_dir: - The directory in which to save the figures. This is relative to the - Sphinx source directory. The default is `html_static_path`. -ipython_rgxin: - The compiled regular expression to denote the start of IPython input - lines. The default is re.compile('In \[(\d+)\]:\s?(.*)\s*'). You - shouldn't need to change this. -ipython_rgxout: - The compiled regular expression to denote the start of IPython output - lines. The default is re.compile('Out\[(\d+)\]:\s?(.*)\s*'). You - shouldn't need to change this. -ipython_promptin: - The string to represent the IPython input prompt in the generated ReST. - The default is 'In [%d]:'. This expects that the line numbers are used - in the prompt. -ipython_promptout: - - The string to represent the IPython prompt in the generated ReST. The - default is 'Out [%d]:'. This expects that the line numbers are used - in the prompt. - -ToDo ----- - -- Turn the ad-hoc test() function into a real test suite. -- Break up ipython-specific functionality from matplotlib stuff into better - separated code. - -Authors -------- - -- John D Hunter: orignal author. -- Fernando Perez: refactoring, documentation, cleanups, port to 0.11. -- VáclavŠmilauer : Prompt generalizations. -- Skipper Seabold, refactoring, cleanups, pure python addition -""" - -#----------------------------------------------------------------------------- -# Imports -#----------------------------------------------------------------------------- - -# Stdlib -import cStringIO -import os -import re -import sys -import tempfile -import ast - -# To keep compatibility with various python versions -try: - from hashlib import md5 -except ImportError: - from md5 import md5 - -# Third-party -try: - import matplotlib - matplotlib.use('Agg') -except ImportError: - print "Couldn't find matplotlib" - -import sphinx -from docutils.parsers.rst import directives -from docutils import nodes -from sphinx.util.compat import Directive - -# Our own -from IPython import Config, InteractiveShell -from IPython.core.profiledir import ProfileDir -from IPython.utils import io - -#----------------------------------------------------------------------------- -# Globals -#----------------------------------------------------------------------------- -# for tokenizing blocks -COMMENT, INPUT, OUTPUT = range(3) - -#----------------------------------------------------------------------------- -# Functions and class declarations -#----------------------------------------------------------------------------- -def block_parser(part, rgxin, rgxout, fmtin, fmtout): - """ - part is a string of ipython text, comprised of at most one - input, one ouput, comments, and blank lines. The block parser - parses the text into a list of:: - - blocks = [ (TOKEN0, data0), (TOKEN1, data1), ...] - - where TOKEN is one of [COMMENT | INPUT | OUTPUT ] and - data is, depending on the type of token:: - - COMMENT : the comment string - - INPUT: the (DECORATOR, INPUT_LINE, REST) where - DECORATOR: the input decorator (or None) - INPUT_LINE: the input as string (possibly multi-line) - REST : any stdout generated by the input line (not OUTPUT) - - - OUTPUT: the output string, possibly multi-line - """ - - block = [] - lines = part.split('\n') - N = len(lines) - i = 0 - decorator = None - while 1: - - if i==N: - # nothing left to parse -- the last line - break - - line = lines[i] - i += 1 - line_stripped = line.strip() - if line_stripped.startswith('#'): - block.append((COMMENT, line)) - continue - - if line_stripped.startswith('@'): - # we're assuming at most one decorator -- may need to - # rethink - decorator = line_stripped - continue - - # does this look like an input line? - matchin = rgxin.match(line) - if matchin: - lineno, inputline = int(matchin.group(1)), matchin.group(2) - - # the ....: continuation string - continuation = ' %s:'%''.join(['.']*(len(str(lineno))+2)) - Nc = len(continuation) - # input lines can continue on for more than one line, if - # we have a '\' line continuation char or a function call - # echo line 'print'. The input line can only be - # terminated by the end of the block or an output line, so - # we parse out the rest of the input line if it is - # multiline as well as any echo text - - rest = [] - while i 1: - if input_lines[-1] != "": - input_lines.append('') # make sure there's a blank line - # so splitter buffer gets reset - - continuation = ' %s:'%''.join(['.']*(len(str(lineno))+2)) - Nc = len(continuation) - - if is_savefig: - image_file, image_directive = self.process_image(decorator) - - ret = [] - is_semicolon = False - - for i, line in enumerate(input_lines): - if line.endswith(';'): - is_semicolon = True - - if i==0: - # process the first input line - if is_verbatim: - self.process_input_line('') - self.IP.execution_count += 1 # increment it anyway - else: - # only submit the line in non-verbatim mode - self.process_input_line(line, store_history=True) - formatted_line = '%s %s'%(input_prompt, line) - else: - # process a continuation line - if not is_verbatim: - self.process_input_line(line, store_history=True) - - formatted_line = '%s %s'%(continuation, line) - - if not is_suppress: - ret.append(formatted_line) - - if not is_suppress and len(rest.strip()) and is_verbatim: - # the "rest" is the standard output of the - # input, which needs to be added in - # verbatim mode - ret.append(rest) - - self.cout.seek(0) - output = self.cout.read() - if not is_suppress and not is_semicolon: - ret.append(output) - elif is_semicolon: # get spacing right - ret.append('') - - self.cout.truncate(0) - return (ret, input_lines, output, is_doctest, image_file, - image_directive) - #print 'OUTPUT', output # dbg - - def process_output(self, data, output_prompt, - input_lines, output, is_doctest, image_file): - """Process data block for OUTPUT token.""" - if is_doctest: - submitted = data.strip() - found = output - if found is not None: - found = found.strip() - - # XXX - fperez: in 0.11, 'output' never comes with the prompt - # in it, just the actual output text. So I think all this code - # can be nuked... - - # the above comment does not appear to be accurate... (minrk) - - ind = found.find(output_prompt) - if ind<0: - e='output prompt="%s" does not match out line=%s' % \ - (output_prompt, found) - raise RuntimeError(e) - found = found[len(output_prompt):].strip() - - if found!=submitted: - e = ('doctest failure for input_lines="%s" with ' - 'found_output="%s" and submitted output="%s"' % - (input_lines, found, submitted) ) - raise RuntimeError(e) - #print 'doctest PASSED for input_lines="%s" with found_output="%s" and submitted output="%s"'%(input_lines, found, submitted) - - def process_comment(self, data): - """Process data fPblock for COMMENT token.""" - if not self.is_suppress: - return [data] - - def save_image(self, image_file): - """ - Saves the image file to disk. - """ - self.ensure_pyplot() - command = 'plt.gcf().savefig("%s")'%image_file - #print 'SAVEFIG', command # dbg - self.process_input_line('bookmark ipy_thisdir', store_history=False) - self.process_input_line('cd -b ipy_savedir', store_history=False) - self.process_input_line(command, store_history=False) - self.process_input_line('cd -b ipy_thisdir', store_history=False) - self.process_input_line('bookmark -d ipy_thisdir', store_history=False) - self.clear_cout() - - - def process_block(self, block): - """ - process block from the block_parser and return a list of processed lines - """ - ret = [] - output = None - input_lines = None - lineno = self.IP.execution_count - - input_prompt = self.promptin%lineno - output_prompt = self.promptout%lineno - image_file = None - image_directive = None - - for token, data in block: - if token==COMMENT: - out_data = self.process_comment(data) - elif token==INPUT: - (out_data, input_lines, output, is_doctest, image_file, - image_directive) = \ - self.process_input(data, input_prompt, lineno) - elif token==OUTPUT: - out_data = \ - self.process_output(data, output_prompt, - input_lines, output, is_doctest, - image_file) - if out_data: - ret.extend(out_data) - - # save the image files - if image_file is not None: - self.save_image(image_file) - - return ret, image_directive - - def ensure_pyplot(self): - if self._pyplot_imported: - return - self.process_input_line('import matplotlib.pyplot as plt', - store_history=False) - - def process_pure_python(self, content): - """ - content is a list of strings. it is unedited directive conent - - This runs it line by line in the InteractiveShell, prepends - prompts as needed capturing stderr and stdout, then returns - the content as a list as if it were ipython code - """ - output = [] - savefig = False # keep up with this to clear figure - multiline = False # to handle line continuation - multiline_start = None - fmtin = self.promptin - - ct = 0 - - for lineno, line in enumerate(content): - - line_stripped = line.strip() - if not len(line): - output.append(line) - continue - - # handle decorators - if line_stripped.startswith('@'): - output.extend([line]) - if 'savefig' in line: - savefig = True # and need to clear figure - continue - - # handle comments - if line_stripped.startswith('#'): - output.extend([line]) - continue - - # deal with lines checking for multiline - continuation = u' %s:'% ''.join(['.']*(len(str(ct))+2)) - if not multiline: - modified = u"%s %s" % (fmtin % ct, line_stripped) - output.append(modified) - ct += 1 - try: - ast.parse(line_stripped) - output.append(u'') - except Exception: # on a multiline - multiline = True - multiline_start = lineno - else: # still on a multiline - modified = u'%s %s' % (continuation, line) - output.append(modified) - try: - mod = ast.parse( - '\n'.join(content[multiline_start:lineno+1])) - if isinstance(mod.body[0], ast.FunctionDef): - # check to see if we have the whole function - for element in mod.body[0].body: - if isinstance(element, ast.Return): - multiline = False - else: - output.append(u'') - multiline = False - except Exception: - pass - - if savefig: # clear figure if plotted - self.ensure_pyplot() - self.process_input_line('plt.clf()', store_history=False) - self.clear_cout() - savefig = False - - return output - -class IpythonDirective(Directive): - - has_content = True - required_arguments = 0 - optional_arguments = 4 # python, suppress, verbatim, doctest - final_argumuent_whitespace = True - option_spec = { 'python': directives.unchanged, - 'suppress' : directives.flag, - 'verbatim' : directives.flag, - 'doctest' : directives.flag, - } - - shell = EmbeddedSphinxShell() - - def get_config_options(self): - # contains sphinx configuration variables - config = self.state.document.settings.env.config - - # get config variables to set figure output directory - confdir = self.state.document.settings.env.app.confdir - savefig_dir = config.ipython_savefig_dir - source_dir = os.path.dirname(self.state.document.current_source) - if savefig_dir is None: - savefig_dir = config.html_static_path - if isinstance(savefig_dir, list): - savefig_dir = savefig_dir[0] # safe to assume only one path? - savefig_dir = os.path.join(confdir, savefig_dir) - - # get regex and prompt stuff - rgxin = config.ipython_rgxin - rgxout = config.ipython_rgxout - promptin = config.ipython_promptin - promptout = config.ipython_promptout - - return savefig_dir, source_dir, rgxin, rgxout, promptin, promptout - - def setup(self): - # reset the execution count if we haven't processed this doc - #NOTE: this may be borked if there are multiple seen_doc tmp files - #check time stamp? - seen_docs = [i for i in os.listdir(tempfile.tempdir) - if i.startswith('seen_doc')] - if seen_docs: - fname = os.path.join(tempfile.tempdir, seen_docs[0]) - docs = open(fname).read().split('\n') - if not self.state.document.current_source in docs: - self.shell.IP.history_manager.reset() - self.shell.IP.execution_count = 1 - else: # haven't processed any docs yet - docs = [] - - - # get config values - (savefig_dir, source_dir, rgxin, - rgxout, promptin, promptout) = self.get_config_options() - - # and attach to shell so we don't have to pass them around - self.shell.rgxin = rgxin - self.shell.rgxout = rgxout - self.shell.promptin = promptin - self.shell.promptout = promptout - self.shell.savefig_dir = savefig_dir - self.shell.source_dir = source_dir - - # setup bookmark for saving figures directory - - self.shell.process_input_line('bookmark ipy_savedir %s'%savefig_dir, - store_history=False) - self.shell.clear_cout() - - # write the filename to a tempfile because it's been "seen" now - if not self.state.document.current_source in docs: - fd, fname = tempfile.mkstemp(prefix="seen_doc", text=True) - fout = open(fname, 'a') - fout.write(self.state.document.current_source+'\n') - fout.close() - - return rgxin, rgxout, promptin, promptout - - - def teardown(self): - # delete last bookmark - self.shell.process_input_line('bookmark -d ipy_savedir', - store_history=False) - self.shell.clear_cout() - - def run(self): - debug = False - - #TODO, any reason block_parser can't be a method of embeddable shell - # then we wouldn't have to carry these around - rgxin, rgxout, promptin, promptout = self.setup() - - options = self.options - self.shell.is_suppress = 'suppress' in options - self.shell.is_doctest = 'doctest' in options - self.shell.is_verbatim = 'verbatim' in options - - - # handle pure python code - if 'python' in self.arguments: - content = self.content - self.content = self.shell.process_pure_python(content) - - parts = '\n'.join(self.content).split('\n\n') - - lines = ['.. code-block:: ipython',''] - figures = [] - - for part in parts: - - block = block_parser(part, rgxin, rgxout, promptin, promptout) - - if len(block): - rows, figure = self.shell.process_block(block) - for row in rows: - lines.extend([' %s'%line for line in row.split('\n')]) - - if figure is not None: - figures.append(figure) - - #text = '\n'.join(lines) - #figs = '\n'.join(figures) - - for figure in figures: - lines.append('') - lines.extend(figure.split('\n')) - lines.append('') - - #print lines - if len(lines)>2: - if debug: - print '\n'.join(lines) - else: #NOTE: this raises some errors, what's it for? - #print 'INSERTING %d lines'%len(lines) - self.state_machine.insert_input( - lines, self.state_machine.input_lines.source(0)) - - text = '\n'.join(lines) - txtnode = nodes.literal_block(text, text) - txtnode['language'] = 'ipython' - #imgnode = nodes.image(figs) - - # cleanup - self.teardown() - - return []#, imgnode] - -# Enable as a proper Sphinx directive -def setup(app): - setup.app = app - - app.add_directive('ipython', IpythonDirective) - app.add_config_value('ipython_savefig_dir', None, True) - app.add_config_value('ipython_rgxin', - re.compile('In \[(\d+)\]:\s?(.*)\s*'), True) - app.add_config_value('ipython_rgxout', - re.compile('Out\[(\d+)\]:\s?(.*)\s*'), True) - app.add_config_value('ipython_promptin', 'In [%d]:', True) - app.add_config_value('ipython_promptout', 'Out[%d]:', True) - - -# Simple smoke test, needs to be converted to a proper automatic test. -def test(): - - examples = [ - r""" -In [9]: pwd -Out[9]: '/home/jdhunter/py4science/book' - -In [10]: cd bookdata/ -/home/jdhunter/py4science/book/bookdata - -In [2]: from pylab import * - -In [2]: ion() - -In [3]: im = imread('stinkbug.png') - -@savefig mystinkbug.png width=4in -In [4]: imshow(im) -Out[4]: - -""", - r""" - -In [1]: x = 'hello world' - -# string methods can be -# used to alter the string -@doctest -In [2]: x.upper() -Out[2]: 'HELLO WORLD' - -@verbatim -In [3]: x.st -x.startswith x.strip -""", - r""" - -In [130]: url = 'http://ichart.finance.yahoo.com/table.csv?s=CROX\ - .....: &d=9&e=22&f=2009&g=d&a=1&br=8&c=2006&ignore=.csv' - -In [131]: print url.split('&') -['http://ichart.finance.yahoo.com/table.csv?s=CROX', 'd=9', 'e=22', 'f=2009', 'g=d', 'a=1', 'b=8', 'c=2006', 'ignore=.csv'] - -In [60]: import urllib - -""", - r"""\ - -In [133]: import numpy.random - -@suppress -In [134]: numpy.random.seed(2358) - -@doctest -In [135]: numpy.random.rand(10,2) -Out[135]: -array([[ 0.64524308, 0.59943846], - [ 0.47102322, 0.8715456 ], - [ 0.29370834, 0.74776844], - [ 0.99539577, 0.1313423 ], - [ 0.16250302, 0.21103583], - [ 0.81626524, 0.1312433 ], - [ 0.67338089, 0.72302393], - [ 0.7566368 , 0.07033696], - [ 0.22591016, 0.77731835], - [ 0.0072729 , 0.34273127]]) - -""", - - r""" -In [106]: print x -jdh - -In [109]: for i in range(10): - .....: print i - .....: - .....: -0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -""", - - r""" - -In [144]: from pylab import * - -In [145]: ion() - -# use a semicolon to suppress the output -@savefig test_hist.png width=4in -In [151]: hist(np.random.randn(10000), 100); - - -@savefig test_plot.png width=4in -In [151]: plot(np.random.randn(10000), 'o'); - """, - - r""" -# use a semicolon to suppress the output -In [151]: plt.clf() - -@savefig plot_simple.png width=4in -In [151]: plot([1,2,3]) - -@savefig hist_simple.png width=4in -In [151]: hist(np.random.randn(10000), 100); - -""", - r""" -# update the current fig -In [151]: ylabel('number') - -In [152]: title('normal distribution') - - -@savefig hist_with_text.png -In [153]: grid(True) - - """, - ] - # skip local-file depending first example: - examples = examples[1:] - - #ipython_directive.DEBUG = True # dbg - #options = dict(suppress=True) # dbg - options = dict() - for example in examples: - content = example.split('\n') - ipython_directive('debug', arguments=None, options=options, - content=content, lineno=0, - content_offset=None, block_text=None, - state=None, state_machine=None, - ) - -# Run test suite as a script -if __name__=='__main__': - if not os.path.isdir('_static'): - os.mkdir('_static') - test() - print 'All OK? Check figures in _static/' - - diff --git a/doc/tuto_GP_regression.rst b/doc/tuto_GP_regression.rst deleted file mode 100644 index 29eefa72..00000000 --- a/doc/tuto_GP_regression.rst +++ /dev/null @@ -1,142 +0,0 @@ -************************************* -Gaussian process regression tutorial -************************************* - -We will see in this tutorial the basics for building a 1 dimensional and a 2 dimensional Gaussian process regression model, also known as a kriging model. The code shown in this tutorial can be obtained at GPy/examples/tutorials.py, or by running ``GPy.examples.tutorials.tuto_GP_regression()``. - -We first import the libraries we will need: :: - - import pylab as pb - pb.ion() - import numpy as np - import GPy - -1-dimensional model -=================== - -For this toy example, we assume we have the following inputs and outputs:: - - X = np.random.uniform(-3.,3.,(20,1)) - Y = np.sin(X) + np.random.randn(20,1)*0.05 - -Note that the observations Y include some noise. - -The first step is to define the covariance kernel we want to use for the model. We choose here a kernel based on Gaussian kernel (i.e. rbf or square exponential):: - - kernel = GPy.kern.RBF(input_dim=1, variance=1., lengthscale=1.) - -The parameter ``input_dim`` stands for the dimension of the input space. The parameters ``variance`` and ``lengthscale`` are optional. Many other kernels are implemented such as: - -* linear (:py:class:`~GPy.kern.Linear`) -* exponential kernel (:py:class:`GPy.kern.Exponential`) -* Matern 3/2 (:py:class:`GPy.kern.Matern32`) -* Matern 5/2 (:py:class:`GPy.kern.Matern52`) -* spline (:py:class:`GPy.kern.Spline`) -* and many others... - -The inputs required for building the model are the observations and the kernel:: - - m = GPy.models.GPRegression(X,Y,kernel) - -By default, some observation noise is added to the modle. The functions ``print`` and ``plot`` give an insight of the model we have just build. The code:: - - print m - m.plot() - -gives the following output: :: - - Name : GP regression - Log-likelihood : -22.8178418808 - Number of Parameters : 3 - Parameters: - GP_regression. | Value | Constraint | Prior | Tied to - rbf.variance | 1.0 | +ve | | - rbf.lengthscale | 1.0 | +ve | | - Gaussian_noise.variance | 1.0 | +ve | | - -.. figure:: Figures/tuto_GP_regression_m1.png - :align: center - :height: 350px - - GP regression model before optimization of the parameters. The shaded region corresponds to ~95% confidence intervals (ie +/- 2 standard deviation). - -The default values of the kernel parameters may not be relevant for -the current data (for example, the confidence intervals seems too wide -on the previous figure). A common approach is to find the values of -the parameters that maximize the likelihood of the data. It as easy as -calling ``m.optimize`` in GPy:: - - m.optimize() - -If we want to perform some restarts to try to improve the result of the optimization, we can use the ``optimize_restart`` function:: - - m.optimize_restarts(num_restarts = 10) - -Once again, we can use ``print(m)`` and ``m.plot()`` to look at the resulting model resulting model:: - - Name : GP regression - Log-likelihood : 11.947469082 - Number of Parameters : 3 - Parameters: - GP_regression. | Value | Constraint | Prior | Tied to - rbf.variance | 0.74229417323 | +ve | | - rbf.lengthscale | 1.43020495724 | +ve | | - Gaussian_noise.variance | 0.00325654460991 | +ve | | - -.. figure:: Figures/tuto_GP_regression_m2.png - :align: center - :height: 350px - - GP regression model after optimization of the parameters. - - -2-dimensional example -===================== - -Here is a 2 dimensional example:: - - import pylab as pb - pb.ion() - import numpy as np - import GPy - - # sample inputs and outputs - X = np.random.uniform(-3.,3.,(50,2)) - Y = np.sin(X[:,0:1]) * np.sin(X[:,1:2])+np.random.randn(50,1)*0.05 - - # define kernel - ker = GPy.kern.Matern52(2,ARD=True) + GPy.kern.White(2) - - # create simple GP model - m = GPy.models.GPRegression(X,Y,ker) - - # optimize and plot - m.optimize(max_f_eval = 1000) - m.plot() - print(m) - -The flag ``ARD=True`` in the definition of the Matern kernel specifies that we want one lengthscale parameter per dimension (ie the GP is not isotropic). The output of the last two lines is:: - - Name : GP regression - Log-likelihood : 26.787156248 - Number of Parameters : 5 - Parameters: - GP_regression. | Value | Constraint | Prior | Tied to - add.Mat52.variance | 0.385463739076 | +ve | | - add.Mat52.lengthscale | (2,) | +ve | | - add.white.variance | 0.000835329608514 | +ve | | - Gaussian_noise.variance | 0.000835329608514 | +ve | | - -If you want to see the ``ARD`` parameters explicitly print them -directly:: - - >>> print m.add.Mat52.lengthscale - Index | GP_regression.add.Mat52.lengthscale | Constraint | Prior | Tied to - [0] | 1.9575587 | +ve | | N/A - [1] | 1.9689948 | +ve | | N/A - -.. figure:: Figures/tuto_GP_regression_m3.png - :align: center - :height: 350px - - Contour plot of the best predictor (posterior mean). diff --git a/doc/tuto_creating_new_kernels.rst b/doc/tuto_creating_new_kernels.rst deleted file mode 100644 index a8197596..00000000 --- a/doc/tuto_creating_new_kernels.rst +++ /dev/null @@ -1,212 +0,0 @@ -******************** -Creating new kernels -******************** - -We will see in this tutorial how to create new kernels in GPy. We will also give details on how to implement each function of the kernel and illustrate with a running example: the rational quadratic kernel. - -Structure of a kernel in GPy -============================ - -In GPy a kernel object is made of a list of kernpart objects, which correspond to symetric positive definite functions. More precisely, the kernel should be understood as the sum of the kernparts. In order to implement a new covariance, the following steps must be followed - - 1. implement the new covariance as a kernpart object - 2. update the constructors that allow to use the kernpart as a kern object - 3. update the __init__.py file - -Theses three steps are detailed below. - -Implementing a kernpart object -============================== - -We advise the reader to start with copy-pasting an existing kernel and to modify the new file. We will now give a description of the various functions that can be found in a kernpart object. - -**Header** - -The header is similar to all kernels: :: - - from kernpart import kernpart - import numpy as np - - class rational_quadratic(kernpart): - -**__init__(self,input_dim, param1, param2, ...)** - -The implementation of this function in mandatory. - -For all kernparts the first parameter ``input_dim`` corresponds to the dimension of the input space, and the following parameters stand for the parameterization of the kernel. - -You have to call ``super(, self).__init__(input_dim, -name)`` to make sure the input dimension and name of the kernel are -stored in the right place. These attributes are available as -``self.input_dim`` and ``self.name`` at runtime. -.. The following attributes are compulsory: ``self.input_dim`` (the dimension, integer), ``self.name`` (name of the kernel, string), ``self.num_params`` (number of parameters, integer). :: -Parameterization is done by adding -:py:class:``GPy.core.parameter.Param`` objects to ``self`` and use -them as normal numpy ``array-like``s in yout code. The parameters have -to be added by calling -:py:function:``GPy.core.parameterized:Parameterized.add_parameters`` -with the :py:class:``GPy.core.parameter.Param`` objects as arguments. - - def __init__(self,input_dim,variance=1.,lengthscale=1.,power=1.): - super(RationalQuadratic, self).__init__(input_dim, 'rat_quad') - assert input_dim == 1, "For this kernel we assume input_dim=1" - self.variance = Param('variance', variance) - self.lengthscale = Param('lengtscale', lengthscale) - self.power = Param('power', power) - self.add_parameters(self.variance, self.lengthscale, self.power) - -From now on you can use the parameters ``self.variance, -self.lengthscale, self.power`` as normal numpy ``array-like``s in your -code. Updates from the optimization routine will be done -automatically. - -**parameters_changed(self)** - -The implementation of this function is optional. - -This functions deals as a callback for each optimization iteration. If -one optimization step was successfull and the parameters (added by -:py:function:``GPy.core.parameterized:Parameterized.add_parameters``) -this callback function will be called to be able to update any -precomputations for the kernel. - - def parameters_changed(self): - # nothing todo here - - - -.. **_get_params(self)** - -.. The implementation of this function in mandatory. - -.. This function returns a one dimensional array of length ``self.num_params`` containing the value of the parameters. :: - -.. def _get_params(self): -.. return np.hstack((self.variance,self.lengthscale,self.power)) - -.. **_set_params(self,x)** - -.. The implementation of this function in mandatory. - -.. The input is a one dimensional array of length ``self.num_params`` containing the value of the parameters. The function has no output but it updates the values of the attribute associated to the parameters (such as ``self.variance``, ``self.lengthscale``, ...). :: - -.. def _set_params(self,x): -.. self.variance = x[0] -.. self.lengthscale = x[1] -.. self.power = x[2] - -.. **_get_param_names(self)** - -.. The implementation of this function in mandatory. - -.. It returns a list of strings of length ``self.num_params`` corresponding to the parameter names. :: - -.. def _get_param_names(self): -.. return ['variance','lengthscale','power'] - -**K(self,X,X2,target)** - -The implementation of this function in mandatory. - -This function is used to compute the covariance matrix associated with the inputs X, X2 (np.arrays with arbitrary number of line (say :math:`n_1`, :math:`n_2`) and ``self.input_dim`` columns). This function does not returns anything but it adds the :math:`n_1 \times n_2` covariance matrix to the kernpart to the object ``target`` (a :math:`n_1 \times n_2` np.array). This trick allows to compute the covariance matrix of a kernel containing many kernparts with a limited memory use. :: - - def K(self,X,X2,target): - if X2 is None: X2 = X - dist2 = np.square((X-X2.T)/self.lengthscale) - target += self.variance*(1 + dist2/2.)**(-self.power) - -**Kdiag(self,X,target)** - -The implementation of this function in mandatory. - -This function is similar to ``K`` but it computes only the values of the kernel on the diagonal. Thus, ``target`` is a 1-dimensional np.array of length :math:`n_1`. :: - - def Kdiag(self,X,target): - target += self.variance - - -**dK_dtheta(self,dL_dK,X,X2,target)** - -This function is required for the optimization of the parameters. - -Computes the derivative of the likelihood. As previously, the values are added to the object target which is a 1-dimensional np.array of length ``self.input_dim``. For example, if the kernel is parameterized by :math:`\sigma^2,\ \theta`, then :math:`\frac{dL}{d\sigma^2} = \frac{dL}{d K} \frac{dK}{d\sigma^2}` is added to the first element of target and :math:`\frac{dL}{d\theta} = \frac{dL}{d K} \frac{dK}{d\theta}` to the second. :: - - def dK_dtheta(self,dL_dK,X,X2,target): - if X2 is None: X2 = X - dist2 = np.square((X-X2.T)/self.lengthscale) - - dvar = (1 + dist2/2.)**(-self.power) - dl = self.power * self.variance * dist2 * self.lengthscale**(-3) * (1 + dist2/2./self.power)**(-self.power-1) - dp = - self.variance * np.log(1 + dist2/2.) * (1 + dist2/2.)**(-self.power) - - target[0] += np.sum(dvar*dL_dK) - target[1] += np.sum(dl*dL_dK) - target[2] += np.sum(dp*dL_dK) - - -**dKdiag_dtheta(self,dL_dKdiag,X,target)** - -This function is required for BGPLVM, sparse models and uncertain inputs. - -As previously, target is an ``self.num_params`` array and :math:`\frac{dL}{d Kdiag} \frac{dKdiag}{dparam}` is added to each element. :: - - def dKdiag_dtheta(self,dL_dKdiag,X,target): - target[0] += np.sum(dL_dKdiag) - # here self.lengthscale and self.power have no influence on Kdiag so target[1:] are unchanged - -**dK_dX(self,dL_dK,X,X2,target)** - -This function is required for GPLVM, BGPLVM, sparse models and uncertain inputs. - -Computes the derivative of the likelihood with respect to the inputs ``X`` (a :math:`n \times d` np.array). The result is added to target which is a :math:`n \times d` np.array. :: - - def dK_dX(self,dL_dK,X,X2,target): - """derivative of the covariance matrix with respect to X.""" - if X2 is None: X2 = X - dist2 = np.square((X-X2.T)/self.lengthscale) - - dX = -self.variance*self.power * (X-X2.T)/self.lengthscale**2 * (1 + dist2/2./self.lengthscale)**(-self.power-1) - target += np.sum(dL_dK*dX,1)[:,np.newaxis] - -**dKdiag_dX(self,dL_dKdiag,X,target)** - -This function is required for BGPLVM, sparse models and uncertain inputs. As for ``dKdiag_dtheta``, :math:`\frac{dL}{d Kdiag} \frac{dKdiag}{dX}` is added to each element of target. :: - - def dKdiag_dX(self,dL_dKdiag,X,target): - pass - -**Psi statistics** - -The psi statistics and their derivatives are required for BGPLVM and GPS with uncertain inputs. - -The expressions of the psi statistics are: - -TODO - -For the rational quadratic we have: - -TODO - -Update the constructor -====================== - -Once the required functions have been implemented as a kernpart object, the file GPy/kern/constructors.py has to be updated to allow to build a kernel based on the kernpart object. - -The following line should be added in the preamble of the file:: - - from rational_quadratic import rational_quadratic as rational_quadratic_part - -as well as the following block :: - - def rational_quadratic(input_dim,variance=1., lengthscale=1., power=1.): - part = rational_quadraticpart(input_dim,variance, lengthscale, power) - return kern(input_dim, [part]) - - -Update initialization -===================== - -The last step is to update the list of kernels imported from constructor in GPy/kern/__init__.py. - - - diff --git a/doc/tuto_creating_new_models.rst b/doc/tuto_creating_new_models.rst deleted file mode 100644 index 07f6194f..00000000 --- a/doc/tuto_creating_new_models.rst +++ /dev/null @@ -1,100 +0,0 @@ -.. _creating_new_models: - -******************* -Creating new Models -******************* - -In GPy all models inherit from the base class :py:class:`~GPy.core.parameterized.Parameterized`. :py:class:`~GPy.core.parameterized.Parameterized` is a class which allows for parameterization of objects. All it holds is functionality for tying, bounding and fixing of parameters. It also provides the functionality of searching and manipulating parameters by regular expression syntax. See :py:class:`~GPy.core.parameterized.Parameterized` for more information. - -The :py:class:`~GPy.core.model.Model` class provides parameter introspection, objective function and optimization. - -In order to fully use all functionality of -:py:class:`~GPy.core.model.Model` some methods need to be implemented -/ overridden. And the model needs to be told its parameters, such -that it can provide optimized parameter distribution and handling. -In order to explain the functionality of those methods -we will use a wrapper to the numpy ``rosen`` function, which holds -input parameters :math:`\mathbf{X}`. Where -:math:`\mathbf{X}\in\mathbb{R}^{N\times 1}`. - -Obligatory methods -================== - -:py:func:`~GPy.core.model.Model.__init__` : - Initialize the model with the given parameters. These need to - be added to the model by calling - `self.add_parameter()`, where param needs to be a - parameter handle (See parameterized_ for details).:: - - self.X = GPy.Param("input", X) - self.add_parameter(self.X) - -:py:meth:`~GPy.core.model.Model.log_likelihood` : - Returns the log-likelihood of the new model. For our example - this is just the call to ``rosen`` and as we want to minimize - it, we need to negate the objective.:: - - return -scipy.optimize.rosen(self.X) - -:py:meth:`~GPy.core.model.Model.parameters_changed` : - Updates the internal state of the model and sets the gradient of - each parameter handle in the hierarchy with respect to the - log_likelihod. Thus here we need to set the negative derivative of - the rosenbrock function for the parameters. In this case it is the - gradient for self.X.:: - - self.X.gradient = -scipy.optimize.rosen_der(self.X) - - -Here the full code for the `Rosen` class:: - - from GPy import Model, Param - import scipy - class Rosen(Model): - def __init__(self, X, name='rosenbrock'): - super(Rosen, self).__init__(name=name) - self.X = Param("input", X) - self.add_parameter(self.X) - def log_likelihood(self): - return -scipy.optimize.rosen(self.X) - def parameters_changed(self): - self.X.gradient = -scipy.optimize.rosen_der(self.X) - -In order to test the newly created model, we can check the gradients -and optimize a standard rosenbrock run:: - - >>> m = Rosen(np.array([-1,-1])) - >>> print m - Name : rosenbrock - Log-likelihood : -404.0 - Number of Parameters : 2 - Parameters: - rosenbrock. | Value | Constraint | Prior | Tied to - input | (2,) | | | - >>> m.checkgrad(verbose=True) - Name | Ratio | Difference | Analytical | Numerical - ------------------------------------------------------------------------------------------ - rosenbrock.input[[0]] | 1.000000 | 0.000000 | -804.000000 | -804.000000 - rosenbrock.input[[1]] | 1.000000 | 0.000000 | -400.000000 | -400.000000 - >>> m.optimize() - >>> print m - Name : rosenbrock - Log-likelihood : -6.52150088871e-15 - Number of Parameters : 2 - Parameters: - rosenbrock. | Value | Constraint | Prior | Tied to - input | (2,) | | | - >>> print m.input - Index | rosenbrock.input | Constraint | Prior | Tied to - [0] | 0.99999994 | | | N/A - [1] | 0.99999987 | | | N/A - >>> print m.gradient - [ -1.91169809e-06, 1.01852309e-06] - -This is the optimium for the 2D Rosenbrock function, as expected, and -the gradient of the inputs are almost zero. - -Optional methods -================ - -Currently none. diff --git a/doc/tuto_interacting_with_models.rst b/doc/tuto_interacting_with_models.rst deleted file mode 100644 index 80b2ac77..00000000 --- a/doc/tuto_interacting_with_models.rst +++ /dev/null @@ -1,341 +0,0 @@ -.. _interacting_with_models: - -************************************* -Interacting with models -************************************* - -The GPy model class has a set of features which are -designed to make it simple to explore the parameter -space of the model. By default, the scipy optimisers -are used to fit GPy models (via model.optimize()), -for which we provide mechanisms for 'free' optimisation: -GPy can ensure that naturally positive parameters -(such as variances) remain positive. But these mechanisms -are much more powerful than simple reparameterisation, -as we shall see. - -Along this tutorial we'll use a sparse GP regression model -as example. This example can be in ``GPy.examples.regression``. -All of the examples included in GPy return an instance -of a model class, and therefore they can be called in -the following way: :: - - import numpy as np - import pylab as pb - pb.ion() - import GPy - m = GPy.examples.regression.sparse_GP_regression_1D() - -Examining the model using print -=============================== -To see the current state of the model parameters, -and the model's (marginal) likelihood just print the model :: - - print m - -The first thing displayed on the screen is the log-likelihood -value of the model with its current parameters. Below the -log-likelihood, a table with all the model's parameters -is shown. For each parameter, the table contains the name -of the parameter, the current value, and in case there are -defined: constraints, ties and prior distrbutions associated. :: - - Name : sparse gp - Log-likelihood : 588.947189413 - Number of Parameters : 8 - Parameters: - sparse_gp. | Value | Constraint | Prior | Tied to - inducing inputs | (5, 1) | | | - rbf.variance | 1.91644016819 | +ve | | - rbf.lengthscale | 2.62103621347 | +ve | | - Gaussian_noise.variance | 0.00269870373421 | +ve | | - -In this case the kernel parameters (``rbf.variance``, -``rbf.lengthscale``) as well as -the likelihood noise parameter (``Gaussian_noise.variance``), are constrained -to be positive, while the inducing inputs have no -constraints associated. Also there are no ties or prior defined. - -You can also print all subparts of the model, by printing the -subcomponents individually:: - - print m.rbf - -This will print the details of this particular parameter handle:: - - rbf. | Value | Constraint | Prior | Tied to - variance | 1.91644016819 | +ve | | - lengthscale | 2.62103621347 | +ve | | - -When you want to get a closer look into -multivalue parameters, print them directly:: - - print m.inducing_inputs - - Index | sparse_gp.inducing_inputs | Constraint | Prior | Tied to - [0 0] | 2.7189499 | | | N/A - [1 0] | 0.02006533 | | | N/A - [2 0] | -1.5299386 | | | N/A - [3 0] | -2.7001675 | | | N/A - [4 0] | 1.4654162 | | | N/A - -Interacting with Parameters: -======================= -The preferred way of interacting with parameters is to act on the -parameter handle itself. -Interacting with parameter handles is simple. The names, printed by `print m` -are accessible interactively and programatically. For example try to -set kernels (`rbf`) `lengthscale` to `.2` and print the result:: - - m.rbf.lengthscale = .2 - print m - -You should see this:: - - Name : sparse gp - Log-likelihood : 588.947189413 - Number of Parameters : 8 - Parameters: - sparse_gp. | Value | Constraint | Prior | Tied to - inducing inputs | (5, 1) | | | - rbf.variance | 1.91644016819 | +ve | | - rbf.lengthscale | 0.2 | +ve | | - Gaussian_noise.variance | 0.00269870373421 | +ve | | - -This will already have updated the model's inner state, so you can -plot it or see the changes in the posterior `m.posterior` of the model. - -Regular expressions ----------------- -The model's parameters can also be accessed through regular -expressions, by 'indexing' the model with a regular expression, -matching the parameter name. Through indexing by regular expression, -you can only retrieve leafs of the hierarchy, and you can retrieve the -values matched by calling `values()` on the returned object:: - - >>> print m['.*var'] - Index | sparse_gp.rbf.variance | Constraint | Prior | Tied to - [0] | 2.1500132 | | | N/A - ----- | sparse_gp.Gaussian_noise.variance | ---------- | ---------- | ------- - [0] | 0.0024268215 | | | N/A - >>> print m['.*var'].values() - [ 2.1500132 0.00242682] - >>> print m['rbf'] - Index | sparse_gp.rbf.variance | Constraint | Prior | Tied to - [0] | 2.1500132 | | | N/A - ----- | sparse_gp.rbf.lengthscale | ---------- | ---------- | ------- - [0] | 2.6782803 | | | N/A - -There is access to setting parameters by regular expression, -as well. Here are a few examples of how to set parameters by regular expression:: - - >>> m['.*var'] = .1 - >>> print m['.*var'] - Index | sparse_gp.rbf.variance | Constraint | Prior | Tied to - [0] | 0.1 | | | N/A - ----- | sparse_gp.Gaussian_noise.variance | ---------- | ---------- | ------- - [0] | 0.1 | | | N/A - >>> m['.*var'] = [.1, .2] - >>> print m['.*var'] - Index | sparse_gp.rbf.variance | Constraint | Prior | Tied to - [0] | 0.1 | | | N/A - ----- | sparse_gp.Gaussian_noise.variance | ---------- | ---------- | ------- - [0] | 0.2 | | | N/A - -The fact that only leaf nodes can be accesses we can print all -parameters in a flattened view, by printing the regular expression -match of matching all objects:: - - >>> print m[''] - Index | sparse_gp.inducing_inputs | Constraint | Prior | Tied to - [0 0] | -2.6716041 | | | N/A - [1 0] | -1.4665111 | | | N/A - [2 0] | -0.031010293 | | | N/A - [3 0] | 1.4563711 | | | N/A - [4 0] | 2.6803046 | | | N/A - ----- | sparse_gp.rbf.variance | ---------- | ---------- | ------- - [0] | 0.1 | | | N/A - ----- | sparse_gp.rbf.lengthscale | ---------- | ---------- | ------- - [0] | 2.6782803 | | | N/A - ----- | sparse_gp.Gaussian_noise.variance | ---------- | ---------- | ------- - [0] | 0.2 | | | N/A - -Setting and fetching parameters `parameter_array` ------------------------------------------- -Another way to interact with the model's parameters is through the -`parameter_array`. The Parameter array holds all the parameters of the -model in one place and is editable. It can be accessed through -indexing the model for example you can set all the parameters through -this mechanism:: - - >>> new_params = np.r_[[-4,-2,0,2,4], [.5,2], [.3]] - >>> print new_params - array([-4. , -2. , 0. , 2. , 4. , 0.5, 2. , 0.3]) - >>> m[:] = new_params - >>> print m - Name : sparse gp - Log-likelihood : -147.561160209 - Number of Parameters : 8 - Parameters: - sparse_gp. | Value | Constraint | Prior | Tied to - inducing inputs | (5, 1) | | | - rbf.variance | 0.5 | +sq | | - rbf.lengthscale | 2.0 | +ve | | - Gaussian_noise.variance | 0.3 | +sq | | - -Parameters themselves (leafs of the hierarchy) can be indexed and used -the same way as numpy arrays. First let us set a slice of the -`inducing_inputs`:: - - >>> m.inducing_inputs[2:, 0] = [1,3,5] - >>> print m.inducing_indputs - Index | sparse_gp.inducing_inputs | Constraint | Prior | Tied to - [0 0] | -4 | | | N/A - [1 0] | -2 | | | N/A - [2 0] | 1 | | | N/A - [3 0] | 3 | | | N/A - [4 0] | 5 | | | N/A - -Or you use the parameters as normal numpy arrays for calculations:: - - >>> precision = 1./m.Gaussian_noise.variance - array([ 3.33333333]) - -Getting the model's log likelihood -============================================= -Appart form the printing the model, the marginal -log-likelihood can be obtained by using the function -``log_likelihood()``.:: - - >>> m.log_likelihood() - array([-152.83377316]) - -If you want to ensure the log likelihood as a float, call `float()` -around it:: - - >>> float(m.log_likelihood()) - -152.83377316356177 - -Getting the model parameter's gradients -============================ -The gradients of a model can shed light on understanding the -(possibly hard) optimization process. The gradients of each parameter -handle can be accessed through their `gradient` field.:: - - >>> print m.gradient - [ 5.51170031 9.71735112 -4.20282106 -3.45667035 -1.58828165 - -2.11549358 12.40292787 -627.75467803] - >>> print m.rbf.gradient - [ -2.11549358 12.40292787] - >>> m.optimize() - >>> print m.gradient - [ -5.98046560e-04 -3.64576085e-04 1.98005930e-04 3.43381219e-04 - -6.85685104e-04 -1.28800748e-05 1.08552429e-03 2.74058081e-01] - -Adjusting the model's constraints -================================ -When we initially call the example, it was optimized and hence the -log-likelihood gradients were close to zero. However, since -we have been changing the parameters, the gradients are far from zero now. -Next we are going to show how to optimize the model setting different -restrictions on the parameters. - -Once a constraint has been set on a parameter, it is possible to remove -it with the command ``unconstrain()``, which can be called on any -parameter handle of the model. The methods `constrain()` and -`unconstrain()` return the indices which were actually unconstrained, -relative to the parameter handle the method was called on. This is -particularly handy for reporting which parameters where reconstrained, -when reconstraining a parameter, which was already constrained:: - - >>> m.rbf.variance.unconstrain() - array([0]) - >>>m.unconstrain() - array([6, 7]) - -If you want to unconstrain only a specific constraint, you can pass it -as an argument of ``unconstrain(Transformation)`` (:py:class:`~GPy.constraints.Transformation`), or call -the respective method, such as ``unconstrain_fixed()`` (or -``unfix()``) to only unfix fixed parameters.:: - - >>> m.inducing_input[0].fix() - >>> m.unfix() - >>> m.rbf.constrain_positive() - >>> print m - Name : sparse gp - Log-likelihood : 620.741066698 - Number of Parameters : 8 - Parameters: - sparse_gp. | Value | Constraint | Prior | Tied to - inducing inputs | (5, 1) | | | - rbf.variance | 1.48329711218 | +ve | | - rbf.lengthscale | 2.5430947048 | +ve | | - Gaussian_noise.variance | 0.00229714444128 | | | - -As you can see, ``unfix()`` only unfixed the inducing_input, and did -not change the positive constraint of the kernel. - -The parameter handles come with default constraints, so you will -rarely be needing to adjust the constraints of a model. In the rare -cases of needing to adjust the constraints of a model, or in need of -fixing some parameters, you can do so with the functions -``constrain_{positive|negative|bounded|fixed}()``.:: - - m['.*var'].constrain_positive() - -Available Constraints -============== - -* :py:meth:`~GPy.constraints.Logexp` -* :py:meth:`~GPy.constraints.Exponent` -* :py:meth:`~GPy.constraints.Square` -* :py:meth:`~GPy.constraints.Logistic` -* :py:meth:`~GPy.constraints.LogexpNeg` -* :py:meth:`~GPy.constraints.NegativeExponent` -* :py:meth:`~GPy.constraints.NegativeLogexp` - - -Tying Parameters -============ -Not yet implemented for GPy version 0.6.0 - - -Optimizing the model -==================== - -Once we have finished defining the constraints, -we can now optimize the model with the function -``optimize``.:: - - m.Gaussian_noise.constrain_positive() - m.rbf.constrain_positive() - m.optimize() - -By deafult, GPy uses the lbfgsb optimizer. - -Some optional parameters may be discussed here. - -* ``optimizer``: which optimizer to use, currently there are ``lbfgsb, fmin_tnc, - scg, simplex`` or any unique identifier uniquely identifying an - optimizer. Thus, you can say ``m.optimize('bfgs') for using the - ``lbfgsb`` optimizer -* ``messages``: if the optimizer is verbose. Each optimizer has its - own way of printing, so do not be confused by differing messages of - different optimizers -* ``max_iters``: Maximum number of iterations to take. Some optimizers - see iterations as function calls, others as iterations of the - algorithm. Please be advised to look into ``scipy.optimize`` for - more instructions, if the number of iterations matter, so you can - give the right parameters to ``optimize()`` -* ``gtol``: only for some optimizers. Will determine the convergence - criterion, as the tolerance of gradient to finish the optimization. - -Further Reading -=============== - -All of the mechansiams for dealing -with parameters are baked right into GPy.core.model, from which all of -the classes in GPy.models inherrit. To learn how to construct your own -model, you might want to read :ref:`creating_new_models`. If you want -to learn how to create kernels, please refer to -:ref:`creating_new_kernels` diff --git a/doc/tuto_kernel_overview.rst b/doc/tuto_kernel_overview.rst deleted file mode 100644 index fc93491a..00000000 --- a/doc/tuto_kernel_overview.rst +++ /dev/null @@ -1,285 +0,0 @@ - -**************************** -tutorial : A kernel overview -**************************** -The aim of this tutorial is to give a better understanding of the kernel objects in GPy and to list the ones that are already implemented. The code shown in this tutorial can be obtained at GPy/examples/tutorials.py or by running ``GPy.examples.tutorials.tuto_kernel_overview()``. - -First we import the libraries we will need :: - - import pylab as pb - import numpy as np - import GPy - pb.ion() - -For most kernels, the dimension is the only mandatory parameter to define a kernel object. However, it is also possible to specify the values of the parameters. For example, the three following commands are valid for defining a squared exponential kernel (ie rbf or Gaussian) :: - - ker1 = GPy.kern.RBF(1) # Equivalent to ker1 = GPy.kern.RBF(input_dim=1, variance=1., lengthscale=1.) - ker2 = GPy.kern.RBF(input_dim=1, variance = .75, lengthscale=2.) - ker3 = GPy.kern.RBF(1, .5, .5) - -A ``print`` and a ``plot`` functions are implemented to represent kernel objects. The commands :: - - print ker2 - - ker1.plot() - ker2.plot() - ker3.plot() - -return:: - - Name | Value | Constraints | Ties - ------------------------------------------------------- - rbf_variance | 0.7500 | | - rbf_lengthscale | 2.0000 | | - -.. figure:: Figures/tuto_kern_overview_basicplot.png - :align: center - :height: 300px - -Implemented kernels -=================== - -Many kernels are already implemented in GPy. The following figure gives a summary of most of them (a comprehensive list can be list can be found `here `_): - -.. figure:: Figures/tuto_kern_overview_allkern.png - :align: center - :height: 800px - -On the other hand, it is possible to use the `sympy` package to build new kernels. This will be the subject of another tutorial. - -Operations to combine kernels -============================= - -In ``GPy``, kernel objects can be added or multiplied. In both cases, two kinds of operations are possible since one can assume that the kernels to add/multiply are defined on the same space or on different subspaces. In other words, it is possible to use two kernels :math:`k_1,\ k_2` over :math:`\mathbb{R} \times \mathbb{R}` to create - - * a kernel over :math:`\mathbb{R} \times \mathbb{R}`: :math:`k(x,y) = k_1(x,y) \times k_2(x,y)`. - -This is available in GPy via the ``add`` and ``prod`` functions. Here is a quick example :: - - k1 = GPy.kern.RBF(1,1.,2.) - k2 = GPy.kern.Matern32(1, 0.5, 0.2) - - # Product of kernels - k_prod = k1.prod(k2) - - # Sum of kernels - k_add = k1.add(k2) - -.. # plots - pb.figure(figsize=(8,8)) - pb.subplot(2,2,1) - k_prod.plot() - pb.title('prod') - pb.subplot(2,2,2) - k_prodtens.plot() - pb.title('prod') - pb.subplot(2,2,3) - k_add.plot() - pb.title('sum') - pb.subplot(2,2,4) - k_addtens.plot() - pb.title('sum') - pb.subplots_adjust(wspace=0.3, hspace=0.3) - -.. figure:: Figures/tuto_kern_overview_multadd.png - :align: center - :height: 500px - -A shortcut for ``add`` and ``prod`` is provided by the usual ``+`` and ``*`` operators. Here is another example where we create a periodic kernel with some decay :: - - k1 = GPy.kern.RBF(1,1.,2) - k2 = GPy.kern.PeriodicMatern52(1,variance=1e3, lengthscale=1, period = 1.5, lower=-5., upper = 5) - - k = k1 * k2 # equivalent to k = k1.prod(k2) - print k - - # Simulate sample paths - X = np.linspace(-5,5,501)[:,None] - Y = np.random.multivariate_normal(np.zeros(501),k.K(X),1) - -.. # plot - pb.figure(figsize=(10,4)) - pb.subplot(1,2,1) - k.plot() - pb.subplot(1,2,2) - pb.plot(X,Y.T) - pb.ylabel("Sample path") - pb.subplots_adjust(wspace=0.3) - -.. figure:: Figures/tuto_kern_overview_multperdecay.png - :align: center - :height: 300px - -In general, ``kern`` objects can be seen as a sum of ``kernparts`` objects, where the later are covariance functions defined on the same space. For example, the following code :: - - k = (k1+k2)*(k1+k2) - print k.parts[0].name, '\n', k.parts[1].name, '\n', k.parts[1].parts[0].name, '\n', k.parts[1].parts[1].name, '\n' - -returns :: - add_1 - add_2 - rbf - periodic_Matern52 - - -Constraining the parameters -=========================== - -Various constrains can be applied to the parameters of a kernel - - * ``constrain_fixed`` to fix the value of a parameter (the value will not be modified during optimisation) - * ``constrain_positive`` to make sure the parameter is greater than 0. - * ``constrain_bounded`` to impose the parameter to be in a given range. - * ``tie_params`` to impose the value of two (or more) parameters to be equal. - -When calling one of these functions, the parameters to constrain can either by specified by a regular expression that matches its name or by a number that corresponds to the rank of the parameter. Here is an example :: - - k1 = GPy.kern.RBF(1) - k2 = GPy.kern.Matern32(1) - k3 = GPy.kern.White(1) - - k = k1 + k2 + k3 - print k - - k.constrain_positive('.*var') - k.constrain_fixed(np.array([1]),1.75) - k.tie_params('.*len') - k.unconstrain('white') - k.constrain_bounded('white',lower=1e-5,upper=.5) - print k - -with output:: - - Name | Value | Constraints | Ties - --------------------------------------------------------- - rbf_variance | 1.0000 | | - rbf_lengthscale | 1.0000 | | - Mat32_variance | 1.0000 | | - Mat32_lengthscale | 1.0000 | | - white_variance | 1.0000 | | - - - Name | Value | Constraints | Ties - ---------------------------------------------------------- - rbf_variance | 1.0000 | (+ve) | - rbf_lengthscale | 1.7500 | Fixed | (0) - Mat32_variance | 1.0000 | (+ve) | - Mat32_lengthscale | 1.7500 | | (0) - white_variance | 0.3655 | (1e-05, 0.5) | - - -Example : Building an ANOVA kernel -================================== - -In two dimensions ANOVA kernels have the following form: - -.. math:: - - k_{ANOVA}(x,y) = \prod_{i=1}^2 (1 + k_i(x_i,y_i)) = 1 + k_1(x_1,y_1) + k_2(x_2,y_2) + k_1(x_1,y_1) \times k_2(x_2,y_2). - -Let us assume that we want to define an ANOVA kernel with a Matern 3/2 kernel for :math:`k_i`. As seen previously, we can define this kernel as follows :: - - k_cst = GPy.kern.Bias(1,variance=1.) - k_mat = GPy.kern.Matern52(1,variance=1.,lengthscale=3) - Kanova = (k_cst + k_mat).prod(k_cst + k_mat) - print Kanova - -Printing the resulting kernel outputs the following :: - - Name | Value | Constraints | Ties - --------------------------------------------------------------------------- - biasbias_bias_variance | 1.0000 | | (0) - biasbias_bias_variance | 1.0000 | | (3) - biasMat52_bias_variance | 1.0000 | | (0) - biasMat52_Mat52_variance | 1.0000 | | (4) - biasMat52_Mat52_lengthscale | 3.0000 | | (5) - Mat52bias_Mat52_variance | 1.0000 | | (1) - Mat52bias_Mat52_lengthscale | 3.0000 | | (2) - Mat52bias_bias_variance | 1.0000 | | (3) - Mat52Mat52_Mat52_variance | 1.0000 | | (1) - Mat52Mat52_Mat52_lengthscale | 3.0000 | | (2) - Mat52Mat52_Mat52_variance | 1.0000 | | (4) - Mat52Mat52_Mat52_lengthscale | 3.0000 | | (5) - -Note the ties between the parameters of ``Kanova`` that reflect the links between the parameters of the kernparts objects. We can illustrate the use of this kernel on a toy example:: - - # sample inputs and outputs - X = np.random.uniform(-3.,3.,(40,2)) - Y = 0.5*X[:,:1] + 0.5*X[:,1:] + 2*np.sin(X[:,:1]) * np.sin(X[:,1:]) - - # Create GP regression model - m = GPy.models.GPRegression(X,Y,Kanova) - m.plot() - -.. figure:: Figures/tuto_kern_overview_mANOVA.png - :align: center - :height: 300px - -As :math:`k_{ANOVA}` corresponds to the sum of 4 kernels, the best predictor can be splited in a sum of 4 functions - -.. math:: - - bp(x) & = k(x)^t K^{-1} Y \\ - & = (1 + k_1(x_1) + k_2(x_2) + k_1(x_1)k_2(x_2))^t K^{-1} Y \\ - & = 1^t K^{-1} Y + k_1(x_1)^t K^{-1} Y + k_2(x_2)^t K^{-1} Y + (k_1(x_1)k_2(x_2))^t K^{-1} Y - -The submodels can be represented with the option ``which_function`` of ``plot``: :: - - pb.figure(figsize=(20,3)) - pb.subplots_adjust(wspace=0.5) - axs = pb.subplot(1,5,1) - m.plot(ax=axs) - pb.subplot(1,5,2) - pb.ylabel("= ",rotation='horizontal',fontsize='30') - axs = pb.subplot(1,5,3) - m.plot(ax=axs, which_parts=[False,True,False,False]) - pb.ylabel("cst +",rotation='horizontal',fontsize='30') - axs = pb.subplot(1,5,4) - m.plot(ax=axs, which_parts=[False,False,True,False]) - pb.ylabel("+ ",rotation='horizontal',fontsize='30') - axs = pb.subplot(1,5,5) - pb.ylabel("+ ",rotation='horizontal',fontsize='30') - m.plot(ax=axs, which_parts=[False,False,False,True]) - -.. pb.savefig('tuto_kern_overview_mANOVAdec.png',bbox_inches='tight') - -.. figure:: Figures/tuto_kern_overview_mANOVAdec.png - :align: center - :height: 250px - - -.. # code - import pylab as pb - import numpy as np - import GPy - pb.ion() - - ker1 = GPy.kern.RBF(D=1) # Equivalent to ker1 = GPy.kern.RBF(D=1, variance=1., lengthscale=1.) - ker2 = GPy.kern.RBF(D=1, variance = .75, lengthscale=3.) - ker3 = GPy.kern.RBF(1, .5, .25) - - ker1.plot() - ker2.plot() - ker3.plot() - #pb.savefig("Figures/tuto_kern_overview_basicdef.png") - - kernels = [GPy.kern.RBF(1), GPy.kern.Exponential(1), GPy.kern.Matern32(1), GPy.kern.Matern52(1), GPy.kern.Brownian(1), GPy.kern.Bias(1), GPy.kern.Linear(1), GPy.kern.PeriodicExponential(1), GPy.kern.PeriodicMatern32(1), GPy.kern.PeriodicMatern52(1), GPy.kern.White(1)] - kernel_names = ["GPy.kern.RBF", "GPy.kern.Exponential", "GPy.kern.Matern32", "GPy.kern.Matern52", "GPy.kern.Brownian", "GPy.kern.Bias", "GPy.kern.Linear", "GPy.kern.PeriodicExponential", "GPy.kern.PeriodicMatern32", "GPy.kern.PeriodicMatern52", "GPy.kern.White"] - - pb.figure(figsize=(16,12)) - pb.subplots_adjust(wspace=.5, hspace=.5) - for i, kern in enumerate(kernels): - pb.subplot(3,4,i+1) - kern.plot(x=7.5,plot_limits=[0.00001,15.]) - pb.title(kernel_names[i]+ '\n') - #pb.axes([.1,.1,.8,.7]) - #pb.figtext(.5,.9,'Foo Bar', fontsize=18, ha='center') - #pb.figtext(.5,.85,'Lorem ipsum dolor sit amet, consectetur adipiscing elit',fontsize=10,ha='center') - - # actual plot for the noise - i = 11 - X = np.linspace(0.,15.,201) - WN = 0*X - WN[100] = 1. - pb.subplot(3,4,i+1) - pb.plot(X,WN,'b') diff --git a/doc/tuto_parameterized.rst b/doc/tuto_parameterized.rst deleted file mode 100644 index 507ec109..00000000 --- a/doc/tuto_parameterized.rst +++ /dev/null @@ -1,23 +0,0 @@ -.. _parameterized: - -******************* -Parameterization handling -******************* - -Parameterization in GPy is done through so called parameter handles. The parameter handles are handles to parameters of a model of any kind. A parameter handle can be constrained, fixed, randomized and others. All parameters in GPy have a name, with which they can be accessed in the model. The most common way of accesssing a parameter programmatically though, is by variable name. - -Parameter handles -============== - -A parameter handle in GPy is a handle on a parameter, as the name suggests. A parameter can be constrained, fixed, randomized and more (See e.g. `working with models`). This gives the freedom to the model to handle parameter distribution and model updates as efficiently as possible. All parameter handles share a common memory space, which is just a flat numpy array, stored in the highest parent of a model hierarchy. -In the following we will introduce and elucidate the different parameter handles which exist in GPy. - -:py:class:`~GPy.core.parameterization.parameterized.Parameterized` -========== - -A parameterized object itself holds parameter handles and is just a summarization of the parameters below. It can use those parameters to change the internal state of the model and GPy ensures those parameters to allways hold the right value when in an optimization routine or any other update. - -:py:class:`~GPy.core.parameterization.param.Param` -=========== - -The lowest level of parameter is a numpy array. This Param class inherits all functionality of a numpy array and can simply be used as if it where a numpy array. These parameters can be accessed in the same way as a numpy array is indexed.