repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
JelteF/PyLaTeX | pylatex/figure.py | Figure.add_plot | def add_plot(self, *args, extension='pdf', **kwargs):
"""Add the current Matplotlib plot to the figure.
The plot that gets added is the one that would normally be shown when
using ``plt.show()``.
Args
----
args:
Arguments passed to plt.savefig for displaying... | python | def add_plot(self, *args, extension='pdf', **kwargs):
"""Add the current Matplotlib plot to the figure.
The plot that gets added is the one that would normally be shown when
using ``plt.show()``.
Args
----
args:
Arguments passed to plt.savefig for displaying... | [
"def",
"add_plot",
"(",
"self",
",",
"*",
"args",
",",
"extension",
"=",
"'pdf'",
",",
"*",
"*",
"kwargs",
")",
":",
"add_image_kwargs",
"=",
"{",
"}",
"for",
"key",
"in",
"(",
"'width'",
",",
"'placement'",
")",
":",
"if",
"key",
"in",
"kwargs",
"... | Add the current Matplotlib plot to the figure.
The plot that gets added is the one that would normally be shown when
using ``plt.show()``.
Args
----
args:
Arguments passed to plt.savefig for displaying the plot.
extension : str
extension of image... | [
"Add",
"the",
"current",
"Matplotlib",
"plot",
"to",
"the",
"figure",
"."
] | 62d9d9912ce8445e6629cdbcb80ad86143a1ed23 | https://github.com/JelteF/PyLaTeX/blob/62d9d9912ce8445e6629cdbcb80ad86143a1ed23/pylatex/figure.py#L64-L91 | train |
JelteF/PyLaTeX | pylatex/figure.py | SubFigure.add_image | def add_image(self, filename, *, width=NoEscape(r'\linewidth'),
placement=None):
"""Add an image to the subfigure.
Args
----
filename: str
Filename of the image.
width: str
Width of the image in LaTeX terms.
placement: str
... | python | def add_image(self, filename, *, width=NoEscape(r'\linewidth'),
placement=None):
"""Add an image to the subfigure.
Args
----
filename: str
Filename of the image.
width: str
Width of the image in LaTeX terms.
placement: str
... | [
"def",
"add_image",
"(",
"self",
",",
"filename",
",",
"*",
",",
"width",
"=",
"NoEscape",
"(",
"r'\\linewidth'",
")",
",",
"placement",
"=",
"None",
")",
":",
"super",
"(",
")",
".",
"add_image",
"(",
"filename",
",",
"width",
"=",
"width",
",",
"pl... | Add an image to the subfigure.
Args
----
filename: str
Filename of the image.
width: str
Width of the image in LaTeX terms.
placement: str
Placement of the figure, `None` is also accepted. | [
"Add",
"an",
"image",
"to",
"the",
"subfigure",
"."
] | 62d9d9912ce8445e6629cdbcb80ad86143a1ed23 | https://github.com/JelteF/PyLaTeX/blob/62d9d9912ce8445e6629cdbcb80ad86143a1ed23/pylatex/figure.py#L119-L133 | train |
JelteF/PyLaTeX | pylatex/base_classes/latex_object.py | LatexObject.escape | def escape(self):
"""Determine whether or not to escape content of this class.
This defaults to `True` for most classes.
"""
if self._escape is not None:
return self._escape
if self._default_escape is not None:
return self._default_escape
return T... | python | def escape(self):
"""Determine whether or not to escape content of this class.
This defaults to `True` for most classes.
"""
if self._escape is not None:
return self._escape
if self._default_escape is not None:
return self._default_escape
return T... | [
"def",
"escape",
"(",
"self",
")",
":",
"if",
"self",
".",
"_escape",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_escape",
"if",
"self",
".",
"_default_escape",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_default_escape",
"return",
"True"
] | Determine whether or not to escape content of this class.
This defaults to `True` for most classes. | [
"Determine",
"whether",
"or",
"not",
"to",
"escape",
"content",
"of",
"this",
"class",
"."
] | 62d9d9912ce8445e6629cdbcb80ad86143a1ed23 | https://github.com/JelteF/PyLaTeX/blob/62d9d9912ce8445e6629cdbcb80ad86143a1ed23/pylatex/base_classes/latex_object.py#L58-L67 | train |
JelteF/PyLaTeX | pylatex/base_classes/latex_object.py | LatexObject._repr_values | def _repr_values(self):
"""Return values that are to be shown in repr string."""
def getattr_better(obj, field):
try:
return getattr(obj, field)
except AttributeError as e:
try:
return getattr(obj, '_' + field)
e... | python | def _repr_values(self):
"""Return values that are to be shown in repr string."""
def getattr_better(obj, field):
try:
return getattr(obj, field)
except AttributeError as e:
try:
return getattr(obj, '_' + field)
e... | [
"def",
"_repr_values",
"(",
"self",
")",
":",
"def",
"getattr_better",
"(",
"obj",
",",
"field",
")",
":",
"try",
":",
"return",
"getattr",
"(",
"obj",
",",
"field",
")",
"except",
"AttributeError",
"as",
"e",
":",
"try",
":",
"return",
"getattr",
"(",... | Return values that are to be shown in repr string. | [
"Return",
"values",
"that",
"are",
"to",
"be",
"shown",
"in",
"repr",
"string",
"."
] | 62d9d9912ce8445e6629cdbcb80ad86143a1ed23 | https://github.com/JelteF/PyLaTeX/blob/62d9d9912ce8445e6629cdbcb80ad86143a1ed23/pylatex/base_classes/latex_object.py#L98-L109 | train |
JelteF/PyLaTeX | pylatex/base_classes/latex_object.py | LatexObject._repr_attributes | def _repr_attributes(self):
"""Return attributes that should be part of the repr string."""
if self._repr_attributes_override is None:
# Default to init arguments
attrs = getfullargspec(self.__init__).args[1:]
mapping = self._repr_attributes_mapping
if map... | python | def _repr_attributes(self):
"""Return attributes that should be part of the repr string."""
if self._repr_attributes_override is None:
# Default to init arguments
attrs = getfullargspec(self.__init__).args[1:]
mapping = self._repr_attributes_mapping
if map... | [
"def",
"_repr_attributes",
"(",
"self",
")",
":",
"if",
"self",
".",
"_repr_attributes_override",
"is",
"None",
":",
"# Default to init arguments",
"attrs",
"=",
"getfullargspec",
"(",
"self",
".",
"__init__",
")",
".",
"args",
"[",
"1",
":",
"]",
"mapping",
... | Return attributes that should be part of the repr string. | [
"Return",
"attributes",
"that",
"should",
"be",
"part",
"of",
"the",
"repr",
"string",
"."
] | 62d9d9912ce8445e6629cdbcb80ad86143a1ed23 | https://github.com/JelteF/PyLaTeX/blob/62d9d9912ce8445e6629cdbcb80ad86143a1ed23/pylatex/base_classes/latex_object.py#L112-L122 | train |
JelteF/PyLaTeX | pylatex/base_classes/latex_object.py | LatexObject.latex_name | def latex_name(self):
"""Return the name of the class used in LaTeX.
It can be `None` when the class doesn't have a name.
"""
star = ('*' if self._star_latex_name else '')
if self._latex_name is not None:
return self._latex_name + star
return self.__class__._... | python | def latex_name(self):
"""Return the name of the class used in LaTeX.
It can be `None` when the class doesn't have a name.
"""
star = ('*' if self._star_latex_name else '')
if self._latex_name is not None:
return self._latex_name + star
return self.__class__._... | [
"def",
"latex_name",
"(",
"self",
")",
":",
"star",
"=",
"(",
"'*'",
"if",
"self",
".",
"_star_latex_name",
"else",
"''",
")",
"if",
"self",
".",
"_latex_name",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_latex_name",
"+",
"star",
"return",
"sel... | Return the name of the class used in LaTeX.
It can be `None` when the class doesn't have a name. | [
"Return",
"the",
"name",
"of",
"the",
"class",
"used",
"in",
"LaTeX",
"."
] | 62d9d9912ce8445e6629cdbcb80ad86143a1ed23 | https://github.com/JelteF/PyLaTeX/blob/62d9d9912ce8445e6629cdbcb80ad86143a1ed23/pylatex/base_classes/latex_object.py#L125-L133 | train |
JelteF/PyLaTeX | pylatex/base_classes/latex_object.py | LatexObject.generate_tex | def generate_tex(self, filepath):
"""Generate a .tex file.
Args
----
filepath: str
The name of the file (without .tex)
"""
with open(filepath + '.tex', 'w', encoding='utf-8') as newf:
self.dump(newf) | python | def generate_tex(self, filepath):
"""Generate a .tex file.
Args
----
filepath: str
The name of the file (without .tex)
"""
with open(filepath + '.tex', 'w', encoding='utf-8') as newf:
self.dump(newf) | [
"def",
"generate_tex",
"(",
"self",
",",
"filepath",
")",
":",
"with",
"open",
"(",
"filepath",
"+",
"'.tex'",
",",
"'w'",
",",
"encoding",
"=",
"'utf-8'",
")",
"as",
"newf",
":",
"self",
".",
"dump",
"(",
"newf",
")"
] | Generate a .tex file.
Args
----
filepath: str
The name of the file (without .tex) | [
"Generate",
"a",
".",
"tex",
"file",
"."
] | 62d9d9912ce8445e6629cdbcb80ad86143a1ed23 | https://github.com/JelteF/PyLaTeX/blob/62d9d9912ce8445e6629cdbcb80ad86143a1ed23/pylatex/base_classes/latex_object.py#L159-L169 | train |
JelteF/PyLaTeX | pylatex/base_classes/latex_object.py | LatexObject.dumps_as_content | def dumps_as_content(self):
"""Create a string representation of the object as content.
This is currently only used to add new lines before and after the
output of the dumps function. These can be added or removed by changing
the `begin_paragraph`, `end_paragraph` and `separate_paragrap... | python | def dumps_as_content(self):
"""Create a string representation of the object as content.
This is currently only used to add new lines before and after the
output of the dumps function. These can be added or removed by changing
the `begin_paragraph`, `end_paragraph` and `separate_paragrap... | [
"def",
"dumps_as_content",
"(",
"self",
")",
":",
"string",
"=",
"self",
".",
"dumps",
"(",
")",
"if",
"self",
".",
"separate_paragraph",
"or",
"self",
".",
"begin_paragraph",
":",
"string",
"=",
"'\\n\\n'",
"+",
"string",
".",
"lstrip",
"(",
"'\\n'",
")... | Create a string representation of the object as content.
This is currently only used to add new lines before and after the
output of the dumps function. These can be added or removed by changing
the `begin_paragraph`, `end_paragraph` and `separate_paragraph`
attributes of the class. | [
"Create",
"a",
"string",
"representation",
"of",
"the",
"object",
"as",
"content",
"."
] | 62d9d9912ce8445e6629cdbcb80ad86143a1ed23 | https://github.com/JelteF/PyLaTeX/blob/62d9d9912ce8445e6629cdbcb80ad86143a1ed23/pylatex/base_classes/latex_object.py#L193-L210 | train |
JelteF/PyLaTeX | pylatex/document.py | Document._propagate_packages | def _propagate_packages(self):
r"""Propogate packages.
Make sure that all the packages included in the previous containers
are part of the full list of packages.
"""
super()._propagate_packages()
for item in (self.preamble):
if isinstance(item, LatexObject)... | python | def _propagate_packages(self):
r"""Propogate packages.
Make sure that all the packages included in the previous containers
are part of the full list of packages.
"""
super()._propagate_packages()
for item in (self.preamble):
if isinstance(item, LatexObject)... | [
"def",
"_propagate_packages",
"(",
"self",
")",
":",
"super",
"(",
")",
".",
"_propagate_packages",
"(",
")",
"for",
"item",
"in",
"(",
"self",
".",
"preamble",
")",
":",
"if",
"isinstance",
"(",
"item",
",",
"LatexObject",
")",
":",
"if",
"isinstance",
... | r"""Propogate packages.
Make sure that all the packages included in the previous containers
are part of the full list of packages. | [
"r",
"Propogate",
"packages",
"."
] | 62d9d9912ce8445e6629cdbcb80ad86143a1ed23 | https://github.com/JelteF/PyLaTeX/blob/62d9d9912ce8445e6629cdbcb80ad86143a1ed23/pylatex/document.py#L129-L143 | train |
JelteF/PyLaTeX | pylatex/document.py | Document.dumps | def dumps(self):
"""Represent the document as a string in LaTeX syntax.
Returns
-------
str
"""
head = self.documentclass.dumps() + '%\n'
head += self.dumps_packages() + '%\n'
head += dumps_list(self.variables) + '%\n'
head += dumps_list(self.pre... | python | def dumps(self):
"""Represent the document as a string in LaTeX syntax.
Returns
-------
str
"""
head = self.documentclass.dumps() + '%\n'
head += self.dumps_packages() + '%\n'
head += dumps_list(self.variables) + '%\n'
head += dumps_list(self.pre... | [
"def",
"dumps",
"(",
"self",
")",
":",
"head",
"=",
"self",
".",
"documentclass",
".",
"dumps",
"(",
")",
"+",
"'%\\n'",
"head",
"+=",
"self",
".",
"dumps_packages",
"(",
")",
"+",
"'%\\n'",
"head",
"+=",
"dumps_list",
"(",
"self",
".",
"variables",
... | Represent the document as a string in LaTeX syntax.
Returns
-------
str | [
"Represent",
"the",
"document",
"as",
"a",
"string",
"in",
"LaTeX",
"syntax",
"."
] | 62d9d9912ce8445e6629cdbcb80ad86143a1ed23 | https://github.com/JelteF/PyLaTeX/blob/62d9d9912ce8445e6629cdbcb80ad86143a1ed23/pylatex/document.py#L145-L158 | train |
JelteF/PyLaTeX | pylatex/document.py | Document.generate_pdf | def generate_pdf(self, filepath=None, *, clean=True, clean_tex=True,
compiler=None, compiler_args=None, silent=True):
"""Generate a pdf file from the document.
Args
----
filepath: str
The name of the file (without .pdf), if it is `None` the
`... | python | def generate_pdf(self, filepath=None, *, clean=True, clean_tex=True,
compiler=None, compiler_args=None, silent=True):
"""Generate a pdf file from the document.
Args
----
filepath: str
The name of the file (without .pdf), if it is `None` the
`... | [
"def",
"generate_pdf",
"(",
"self",
",",
"filepath",
"=",
"None",
",",
"*",
",",
"clean",
"=",
"True",
",",
"clean_tex",
"=",
"True",
",",
"compiler",
"=",
"None",
",",
"compiler_args",
"=",
"None",
",",
"silent",
"=",
"True",
")",
":",
"if",
"compil... | Generate a pdf file from the document.
Args
----
filepath: str
The name of the file (without .pdf), if it is `None` the
``default_filepath`` attribute will be used.
clean: bool
Whether non-pdf files created that are created during compilation
... | [
"Generate",
"a",
"pdf",
"file",
"from",
"the",
"document",
"."
] | 62d9d9912ce8445e6629cdbcb80ad86143a1ed23 | https://github.com/JelteF/PyLaTeX/blob/62d9d9912ce8445e6629cdbcb80ad86143a1ed23/pylatex/document.py#L172-L284 | train |
JelteF/PyLaTeX | pylatex/document.py | Document._select_filepath | def _select_filepath(self, filepath):
"""Make a choice between ``filepath`` and ``self.default_filepath``.
Args
----
filepath: str
the filepath to be compared with ``self.default_filepath``
Returns
-------
str
The selected filepath
... | python | def _select_filepath(self, filepath):
"""Make a choice between ``filepath`` and ``self.default_filepath``.
Args
----
filepath: str
the filepath to be compared with ``self.default_filepath``
Returns
-------
str
The selected filepath
... | [
"def",
"_select_filepath",
"(",
"self",
",",
"filepath",
")",
":",
"if",
"filepath",
"is",
"None",
":",
"return",
"self",
".",
"default_filepath",
"else",
":",
"if",
"os",
".",
"path",
".",
"basename",
"(",
"filepath",
")",
"==",
"''",
":",
"filepath",
... | Make a choice between ``filepath`` and ``self.default_filepath``.
Args
----
filepath: str
the filepath to be compared with ``self.default_filepath``
Returns
-------
str
The selected filepath | [
"Make",
"a",
"choice",
"between",
"filepath",
"and",
"self",
".",
"default_filepath",
"."
] | 62d9d9912ce8445e6629cdbcb80ad86143a1ed23 | https://github.com/JelteF/PyLaTeX/blob/62d9d9912ce8445e6629cdbcb80ad86143a1ed23/pylatex/document.py#L286-L306 | train |
JelteF/PyLaTeX | pylatex/document.py | Document.add_color | def add_color(self, name, model, description):
r"""Add a color that can be used throughout the document.
Args
----
name: str
Name to set for the color
model: str
The color model to use when defining the color
description: str
The value... | python | def add_color(self, name, model, description):
r"""Add a color that can be used throughout the document.
Args
----
name: str
Name to set for the color
model: str
The color model to use when defining the color
description: str
The value... | [
"def",
"add_color",
"(",
"self",
",",
"name",
",",
"model",
",",
"description",
")",
":",
"if",
"self",
".",
"color",
"is",
"False",
":",
"self",
".",
"packages",
".",
"append",
"(",
"Package",
"(",
"\"color\"",
")",
")",
"self",
".",
"color",
"=",
... | r"""Add a color that can be used throughout the document.
Args
----
name: str
Name to set for the color
model: str
The color model to use when defining the color
description: str
The values to use to define the color | [
"r",
"Add",
"a",
"color",
"that",
"can",
"be",
"used",
"throughout",
"the",
"document",
"."
] | 62d9d9912ce8445e6629cdbcb80ad86143a1ed23 | https://github.com/JelteF/PyLaTeX/blob/62d9d9912ce8445e6629cdbcb80ad86143a1ed23/pylatex/document.py#L330-L349 | train |
JelteF/PyLaTeX | pylatex/document.py | Document.change_length | def change_length(self, parameter, value):
r"""Change the length of a certain parameter to a certain value.
Args
----
parameter: str
The name of the parameter to change the length for
value: str
The value to set the parameter to
"""
self.... | python | def change_length(self, parameter, value):
r"""Change the length of a certain parameter to a certain value.
Args
----
parameter: str
The name of the parameter to change the length for
value: str
The value to set the parameter to
"""
self.... | [
"def",
"change_length",
"(",
"self",
",",
"parameter",
",",
"value",
")",
":",
"self",
".",
"preamble",
".",
"append",
"(",
"UnsafeCommand",
"(",
"'setlength'",
",",
"arguments",
"=",
"[",
"parameter",
",",
"value",
"]",
")",
")"
] | r"""Change the length of a certain parameter to a certain value.
Args
----
parameter: str
The name of the parameter to change the length for
value: str
The value to set the parameter to | [
"r",
"Change",
"the",
"length",
"of",
"a",
"certain",
"parameter",
"to",
"a",
"certain",
"value",
"."
] | 62d9d9912ce8445e6629cdbcb80ad86143a1ed23 | https://github.com/JelteF/PyLaTeX/blob/62d9d9912ce8445e6629cdbcb80ad86143a1ed23/pylatex/document.py#L351-L363 | train |
JelteF/PyLaTeX | pylatex/document.py | Document.set_variable | def set_variable(self, name, value):
r"""Add a variable which can be used inside the document.
Variables are defined before the preamble. If a variable with that name
has already been set, the new value will override it for future uses.
This is done by appending ``\renewcommand`` to the... | python | def set_variable(self, name, value):
r"""Add a variable which can be used inside the document.
Variables are defined before the preamble. If a variable with that name
has already been set, the new value will override it for future uses.
This is done by appending ``\renewcommand`` to the... | [
"def",
"set_variable",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"name_arg",
"=",
"\"\\\\\"",
"+",
"name",
"variable_exists",
"=",
"False",
"for",
"variable",
"in",
"self",
".",
"variables",
":",
"if",
"name_arg",
"==",
"variable",
".",
"arguments"... | r"""Add a variable which can be used inside the document.
Variables are defined before the preamble. If a variable with that name
has already been set, the new value will override it for future uses.
This is done by appending ``\renewcommand`` to the document.
Args
----
... | [
"r",
"Add",
"a",
"variable",
"which",
"can",
"be",
"used",
"inside",
"the",
"document",
"."
] | 62d9d9912ce8445e6629cdbcb80ad86143a1ed23 | https://github.com/JelteF/PyLaTeX/blob/62d9d9912ce8445e6629cdbcb80ad86143a1ed23/pylatex/document.py#L365-L395 | train |
JelteF/PyLaTeX | pylatex/config.py | Version1.change | def change(self, **kwargs):
"""Override some attributes of the config in a specific context.
A simple usage example::
with pylatex.config.active.change(indent=False):
# Do stuff where indent should be False
...
Args
----
kwargs:
... | python | def change(self, **kwargs):
"""Override some attributes of the config in a specific context.
A simple usage example::
with pylatex.config.active.change(indent=False):
# Do stuff where indent should be False
...
Args
----
kwargs:
... | [
"def",
"change",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"old_attrs",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"kwargs",
".",
"items",
"(",
")",
":",
"old_attrs",
"[",
"k",
"]",
"=",
"getattr",
"(",
"self",
",",
"k",
",",
"v",
")",
... | Override some attributes of the config in a specific context.
A simple usage example::
with pylatex.config.active.change(indent=False):
# Do stuff where indent should be False
...
Args
----
kwargs:
Key value pairs of the default ... | [
"Override",
"some",
"attributes",
"of",
"the",
"config",
"in",
"a",
"specific",
"context",
"."
] | 62d9d9912ce8445e6629cdbcb80ad86143a1ed23 | https://github.com/JelteF/PyLaTeX/blob/62d9d9912ce8445e6629cdbcb80ad86143a1ed23/pylatex/config.py#L63-L87 | train |
JelteF/PyLaTeX | pylatex/base_classes/command.py | CommandBase.__key | def __key(self):
"""Return a hashable key, representing the command.
Returns
-------
tuple
"""
return (self.latex_name, self.arguments, self.options,
self.extra_arguments) | python | def __key(self):
"""Return a hashable key, representing the command.
Returns
-------
tuple
"""
return (self.latex_name, self.arguments, self.options,
self.extra_arguments) | [
"def",
"__key",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"latex_name",
",",
"self",
".",
"arguments",
",",
"self",
".",
"options",
",",
"self",
".",
"extra_arguments",
")"
] | Return a hashable key, representing the command.
Returns
-------
tuple | [
"Return",
"a",
"hashable",
"key",
"representing",
"the",
"command",
"."
] | 62d9d9912ce8445e6629cdbcb80ad86143a1ed23 | https://github.com/JelteF/PyLaTeX/blob/62d9d9912ce8445e6629cdbcb80ad86143a1ed23/pylatex/base_classes/command.py#L65-L74 | train |
JelteF/PyLaTeX | pylatex/base_classes/command.py | CommandBase.dumps | def dumps(self):
"""Represent the command as a string in LaTeX syntax.
Returns
-------
str
The LaTeX formatted command
"""
options = self.options.dumps()
arguments = self.arguments.dumps()
if self.extra_arguments is None:
return ... | python | def dumps(self):
"""Represent the command as a string in LaTeX syntax.
Returns
-------
str
The LaTeX formatted command
"""
options = self.options.dumps()
arguments = self.arguments.dumps()
if self.extra_arguments is None:
return ... | [
"def",
"dumps",
"(",
"self",
")",
":",
"options",
"=",
"self",
".",
"options",
".",
"dumps",
"(",
")",
"arguments",
"=",
"self",
".",
"arguments",
".",
"dumps",
"(",
")",
"if",
"self",
".",
"extra_arguments",
"is",
"None",
":",
"return",
"r'\\{command}... | Represent the command as a string in LaTeX syntax.
Returns
-------
str
The LaTeX formatted command | [
"Represent",
"the",
"command",
"as",
"a",
"string",
"in",
"LaTeX",
"syntax",
"."
] | 62d9d9912ce8445e6629cdbcb80ad86143a1ed23 | https://github.com/JelteF/PyLaTeX/blob/62d9d9912ce8445e6629cdbcb80ad86143a1ed23/pylatex/base_classes/command.py#L107-L128 | train |
JelteF/PyLaTeX | pylatex/base_classes/command.py | Parameters._format_contents | def _format_contents(self, prefix, separator, suffix):
"""Format the parameters.
The formatting is done using the three arguments suplied to this
function.
Arguments
---------
prefix: str
separator: str
suffix: str
Returns
-------
... | python | def _format_contents(self, prefix, separator, suffix):
"""Format the parameters.
The formatting is done using the three arguments suplied to this
function.
Arguments
---------
prefix: str
separator: str
suffix: str
Returns
-------
... | [
"def",
"_format_contents",
"(",
"self",
",",
"prefix",
",",
"separator",
",",
"suffix",
")",
":",
"params",
"=",
"self",
".",
"_list_args_kwargs",
"(",
")",
"if",
"len",
"(",
"params",
")",
"<=",
"0",
":",
"return",
"''",
"string",
"=",
"prefix",
"+",
... | Format the parameters.
The formatting is done using the three arguments suplied to this
function.
Arguments
---------
prefix: str
separator: str
suffix: str
Returns
-------
str | [
"Format",
"the",
"parameters",
"."
] | 62d9d9912ce8445e6629cdbcb80ad86143a1ed23 | https://github.com/JelteF/PyLaTeX/blob/62d9d9912ce8445e6629cdbcb80ad86143a1ed23/pylatex/base_classes/command.py#L264-L289 | train |
JelteF/PyLaTeX | pylatex/base_classes/command.py | Parameters._list_args_kwargs | def _list_args_kwargs(self):
"""Make a list of strings representing al parameters.
Returns
-------
list
"""
params = []
params.extend(self._positional_args)
params.extend(['{k}={v}'.format(k=k, v=v) for k, v in
self._key_value_args... | python | def _list_args_kwargs(self):
"""Make a list of strings representing al parameters.
Returns
-------
list
"""
params = []
params.extend(self._positional_args)
params.extend(['{k}={v}'.format(k=k, v=v) for k, v in
self._key_value_args... | [
"def",
"_list_args_kwargs",
"(",
"self",
")",
":",
"params",
"=",
"[",
"]",
"params",
".",
"extend",
"(",
"self",
".",
"_positional_args",
")",
"params",
".",
"extend",
"(",
"[",
"'{k}={v}'",
".",
"format",
"(",
"k",
"=",
"k",
",",
"v",
"=",
"v",
"... | Make a list of strings representing al parameters.
Returns
-------
list | [
"Make",
"a",
"list",
"of",
"strings",
"representing",
"al",
"parameters",
"."
] | 62d9d9912ce8445e6629cdbcb80ad86143a1ed23 | https://github.com/JelteF/PyLaTeX/blob/62d9d9912ce8445e6629cdbcb80ad86143a1ed23/pylatex/base_classes/command.py#L291-L304 | train |
JelteF/PyLaTeX | pylatex/math.py | Matrix.dumps_content | def dumps_content(self):
"""Return a string representing the matrix in LaTeX syntax.
Returns
-------
str
"""
import numpy as np
string = ''
shape = self.matrix.shape
for (y, x), value in np.ndenumerate(self.matrix):
if x:
... | python | def dumps_content(self):
"""Return a string representing the matrix in LaTeX syntax.
Returns
-------
str
"""
import numpy as np
string = ''
shape = self.matrix.shape
for (y, x), value in np.ndenumerate(self.matrix):
if x:
... | [
"def",
"dumps_content",
"(",
"self",
")",
":",
"import",
"numpy",
"as",
"np",
"string",
"=",
"''",
"shape",
"=",
"self",
".",
"matrix",
".",
"shape",
"for",
"(",
"y",
",",
"x",
")",
",",
"value",
"in",
"np",
".",
"ndenumerate",
"(",
"self",
".",
... | Return a string representing the matrix in LaTeX syntax.
Returns
-------
str | [
"Return",
"a",
"string",
"representing",
"the",
"matrix",
"in",
"LaTeX",
"syntax",
"."
] | 62d9d9912ce8445e6629cdbcb80ad86143a1ed23 | https://github.com/JelteF/PyLaTeX/blob/62d9d9912ce8445e6629cdbcb80ad86143a1ed23/pylatex/math.py#L133-L156 | train |
JelteF/PyLaTeX | pylatex/headfoot.py | PageStyle.change_thickness | def change_thickness(self, element, thickness):
r"""Change line thickness.
Changes the thickness of the line under/over the header/footer
to the specified thickness.
Args
----
element: str
the name of the element to change thickness for: header, footer
... | python | def change_thickness(self, element, thickness):
r"""Change line thickness.
Changes the thickness of the line under/over the header/footer
to the specified thickness.
Args
----
element: str
the name of the element to change thickness for: header, footer
... | [
"def",
"change_thickness",
"(",
"self",
",",
"element",
",",
"thickness",
")",
":",
"if",
"element",
"==",
"\"header\"",
":",
"self",
".",
"data",
".",
"append",
"(",
"Command",
"(",
"\"renewcommand\"",
",",
"arguments",
"=",
"[",
"NoEscape",
"(",
"r\"\\he... | r"""Change line thickness.
Changes the thickness of the line under/over the header/footer
to the specified thickness.
Args
----
element: str
the name of the element to change thickness for: header, footer
thickness: float
the thickness to set the... | [
"r",
"Change",
"line",
"thickness",
"."
] | 62d9d9912ce8445e6629cdbcb80ad86143a1ed23 | https://github.com/JelteF/PyLaTeX/blob/62d9d9912ce8445e6629cdbcb80ad86143a1ed23/pylatex/headfoot.py#L47-L67 | train |
JelteF/PyLaTeX | pylatex/tikz.py | TikZCoordinate.from_str | def from_str(cls, coordinate):
"""Build a TikZCoordinate object from a string."""
m = cls._coordinate_str_regex.match(coordinate)
if m is None:
raise ValueError('invalid coordinate string')
if m.group(1) == '++':
relative = True
else:
relati... | python | def from_str(cls, coordinate):
"""Build a TikZCoordinate object from a string."""
m = cls._coordinate_str_regex.match(coordinate)
if m is None:
raise ValueError('invalid coordinate string')
if m.group(1) == '++':
relative = True
else:
relati... | [
"def",
"from_str",
"(",
"cls",
",",
"coordinate",
")",
":",
"m",
"=",
"cls",
".",
"_coordinate_str_regex",
".",
"match",
"(",
"coordinate",
")",
"if",
"m",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'invalid coordinate string'",
")",
"if",
"m",
".",
... | Build a TikZCoordinate object from a string. | [
"Build",
"a",
"TikZCoordinate",
"object",
"from",
"a",
"string",
"."
] | 62d9d9912ce8445e6629cdbcb80ad86143a1ed23 | https://github.com/JelteF/PyLaTeX/blob/62d9d9912ce8445e6629cdbcb80ad86143a1ed23/pylatex/tikz.py#L89-L103 | train |
JelteF/PyLaTeX | pylatex/tikz.py | TikZCoordinate.distance_to | def distance_to(self, other):
"""Euclidean distance between two coordinates."""
other_coord = self._arith_check(other)
return math.sqrt(math.pow(self._x - other_coord._x, 2) +
math.pow(self._y - other_coord._y, 2)) | python | def distance_to(self, other):
"""Euclidean distance between two coordinates."""
other_coord = self._arith_check(other)
return math.sqrt(math.pow(self._x - other_coord._x, 2) +
math.pow(self._y - other_coord._y, 2)) | [
"def",
"distance_to",
"(",
"self",
",",
"other",
")",
":",
"other_coord",
"=",
"self",
".",
"_arith_check",
"(",
"other",
")",
"return",
"math",
".",
"sqrt",
"(",
"math",
".",
"pow",
"(",
"self",
".",
"_x",
"-",
"other_coord",
".",
"_x",
",",
"2",
... | Euclidean distance between two coordinates. | [
"Euclidean",
"distance",
"between",
"two",
"coordinates",
"."
] | 62d9d9912ce8445e6629cdbcb80ad86143a1ed23 | https://github.com/JelteF/PyLaTeX/blob/62d9d9912ce8445e6629cdbcb80ad86143a1ed23/pylatex/tikz.py#L151-L156 | train |
JelteF/PyLaTeX | pylatex/tikz.py | TikZNode.dumps | def dumps(self):
"""Return string representation of the node."""
ret_str = []
ret_str.append(Command('node', options=self.options).dumps())
if self.handle is not None:
ret_str.append('({})'.format(self.handle))
if self._node_position is not None:
ret_st... | python | def dumps(self):
"""Return string representation of the node."""
ret_str = []
ret_str.append(Command('node', options=self.options).dumps())
if self.handle is not None:
ret_str.append('({})'.format(self.handle))
if self._node_position is not None:
ret_st... | [
"def",
"dumps",
"(",
"self",
")",
":",
"ret_str",
"=",
"[",
"]",
"ret_str",
".",
"append",
"(",
"Command",
"(",
"'node'",
",",
"options",
"=",
"self",
".",
"options",
")",
".",
"dumps",
"(",
")",
")",
"if",
"self",
".",
"handle",
"is",
"not",
"No... | Return string representation of the node. | [
"Return",
"string",
"representation",
"of",
"the",
"node",
"."
] | 62d9d9912ce8445e6629cdbcb80ad86143a1ed23 | https://github.com/JelteF/PyLaTeX/blob/62d9d9912ce8445e6629cdbcb80ad86143a1ed23/pylatex/tikz.py#L230-L247 | train |
JelteF/PyLaTeX | pylatex/tikz.py | TikZNode.get_anchor_point | def get_anchor_point(self, anchor_name):
"""Return an anchor point of the node, if it exists."""
if anchor_name in self._possible_anchors:
return TikZNodeAnchor(self.handle, anchor_name)
else:
try:
anchor = int(anchor_name.split('_')[1])
excep... | python | def get_anchor_point(self, anchor_name):
"""Return an anchor point of the node, if it exists."""
if anchor_name in self._possible_anchors:
return TikZNodeAnchor(self.handle, anchor_name)
else:
try:
anchor = int(anchor_name.split('_')[1])
excep... | [
"def",
"get_anchor_point",
"(",
"self",
",",
"anchor_name",
")",
":",
"if",
"anchor_name",
"in",
"self",
".",
"_possible_anchors",
":",
"return",
"TikZNodeAnchor",
"(",
"self",
".",
"handle",
",",
"anchor_name",
")",
"else",
":",
"try",
":",
"anchor",
"=",
... | Return an anchor point of the node, if it exists. | [
"Return",
"an",
"anchor",
"point",
"of",
"the",
"node",
"if",
"it",
"exists",
"."
] | 62d9d9912ce8445e6629cdbcb80ad86143a1ed23 | https://github.com/JelteF/PyLaTeX/blob/62d9d9912ce8445e6629cdbcb80ad86143a1ed23/pylatex/tikz.py#L249-L263 | train |
JelteF/PyLaTeX | pylatex/tikz.py | TikZUserPath.dumps | def dumps(self):
"""Return path command representation."""
ret_str = self.path_type
if self.options is not None:
ret_str += self.options.dumps()
return ret_str | python | def dumps(self):
"""Return path command representation."""
ret_str = self.path_type
if self.options is not None:
ret_str += self.options.dumps()
return ret_str | [
"def",
"dumps",
"(",
"self",
")",
":",
"ret_str",
"=",
"self",
".",
"path_type",
"if",
"self",
".",
"options",
"is",
"not",
"None",
":",
"ret_str",
"+=",
"self",
".",
"options",
".",
"dumps",
"(",
")",
"return",
"ret_str"
] | Return path command representation. | [
"Return",
"path",
"command",
"representation",
"."
] | 62d9d9912ce8445e6629cdbcb80ad86143a1ed23 | https://github.com/JelteF/PyLaTeX/blob/62d9d9912ce8445e6629cdbcb80ad86143a1ed23/pylatex/tikz.py#L292-L300 | train |
JelteF/PyLaTeX | pylatex/tikz.py | TikZPathList.dumps | def dumps(self):
"""Return representation of the path command."""
ret_str = []
for item in self._arg_list:
if isinstance(item, TikZUserPath):
ret_str.append(item.dumps())
elif isinstance(item, TikZCoordinate):
ret_str.append(item.dumps())
... | python | def dumps(self):
"""Return representation of the path command."""
ret_str = []
for item in self._arg_list:
if isinstance(item, TikZUserPath):
ret_str.append(item.dumps())
elif isinstance(item, TikZCoordinate):
ret_str.append(item.dumps())
... | [
"def",
"dumps",
"(",
"self",
")",
":",
"ret_str",
"=",
"[",
"]",
"for",
"item",
"in",
"self",
".",
"_arg_list",
":",
"if",
"isinstance",
"(",
"item",
",",
"TikZUserPath",
")",
":",
"ret_str",
".",
"append",
"(",
"item",
".",
"dumps",
"(",
")",
")",... | Return representation of the path command. | [
"Return",
"representation",
"of",
"the",
"path",
"command",
"."
] | 62d9d9912ce8445e6629cdbcb80ad86143a1ed23 | https://github.com/JelteF/PyLaTeX/blob/62d9d9912ce8445e6629cdbcb80ad86143a1ed23/pylatex/tikz.py#L423-L435 | train |
JelteF/PyLaTeX | pylatex/tikz.py | TikZPath.dumps | def dumps(self):
"""Return a representation for the command."""
ret_str = [Command('path', options=self.options).dumps()]
ret_str.append(self.path.dumps())
return ' '.join(ret_str) + ';' | python | def dumps(self):
"""Return a representation for the command."""
ret_str = [Command('path', options=self.options).dumps()]
ret_str.append(self.path.dumps())
return ' '.join(ret_str) + ';' | [
"def",
"dumps",
"(",
"self",
")",
":",
"ret_str",
"=",
"[",
"Command",
"(",
"'path'",
",",
"options",
"=",
"self",
".",
"options",
")",
".",
"dumps",
"(",
")",
"]",
"ret_str",
".",
"append",
"(",
"self",
".",
"path",
".",
"dumps",
"(",
")",
")",
... | Return a representation for the command. | [
"Return",
"a",
"representation",
"for",
"the",
"command",
"."
] | 62d9d9912ce8445e6629cdbcb80ad86143a1ed23 | https://github.com/JelteF/PyLaTeX/blob/62d9d9912ce8445e6629cdbcb80ad86143a1ed23/pylatex/tikz.py#L467-L474 | train |
JelteF/PyLaTeX | pylatex/tikz.py | Plot.dumps | def dumps(self):
"""Represent the plot as a string in LaTeX syntax.
Returns
-------
str
"""
string = Command('addplot', options=self.options).dumps()
if self.coordinates is not None:
string += ' coordinates {%\n'
if self.error_bar is No... | python | def dumps(self):
"""Represent the plot as a string in LaTeX syntax.
Returns
-------
str
"""
string = Command('addplot', options=self.options).dumps()
if self.coordinates is not None:
string += ' coordinates {%\n'
if self.error_bar is No... | [
"def",
"dumps",
"(",
"self",
")",
":",
"string",
"=",
"Command",
"(",
"'addplot'",
",",
"options",
"=",
"self",
".",
"options",
")",
".",
"dumps",
"(",
")",
"if",
"self",
".",
"coordinates",
"is",
"not",
"None",
":",
"string",
"+=",
"' coordinates {%\\... | Represent the plot as a string in LaTeX syntax.
Returns
-------
str | [
"Represent",
"the",
"plot",
"as",
"a",
"string",
"in",
"LaTeX",
"syntax",
"."
] | 62d9d9912ce8445e6629cdbcb80ad86143a1ed23 | https://github.com/JelteF/PyLaTeX/blob/62d9d9912ce8445e6629cdbcb80ad86143a1ed23/pylatex/tikz.py#L530-L565 | train |
SheffieldML/GPyOpt | GPyOpt/core/task/cost.py | CostModel._cost_gp | def _cost_gp(self,x):
"""
Predicts the time cost of evaluating the function at x.
"""
m, _, _, _ = self.cost_model.predict_withGradients(x)
return np.exp(m) | python | def _cost_gp(self,x):
"""
Predicts the time cost of evaluating the function at x.
"""
m, _, _, _ = self.cost_model.predict_withGradients(x)
return np.exp(m) | [
"def",
"_cost_gp",
"(",
"self",
",",
"x",
")",
":",
"m",
",",
"_",
",",
"_",
",",
"_",
"=",
"self",
".",
"cost_model",
".",
"predict_withGradients",
"(",
"x",
")",
"return",
"np",
".",
"exp",
"(",
"m",
")"
] | Predicts the time cost of evaluating the function at x. | [
"Predicts",
"the",
"time",
"cost",
"of",
"evaluating",
"the",
"function",
"at",
"x",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/cost.py#L41-L46 | train |
SheffieldML/GPyOpt | GPyOpt/core/task/cost.py | CostModel._cost_gp_withGradients | def _cost_gp_withGradients(self,x):
"""
Predicts the time cost and its gradient of evaluating the function at x.
"""
m, _, dmdx, _= self.cost_model.predict_withGradients(x)
return np.exp(m), np.exp(m)*dmdx | python | def _cost_gp_withGradients(self,x):
"""
Predicts the time cost and its gradient of evaluating the function at x.
"""
m, _, dmdx, _= self.cost_model.predict_withGradients(x)
return np.exp(m), np.exp(m)*dmdx | [
"def",
"_cost_gp_withGradients",
"(",
"self",
",",
"x",
")",
":",
"m",
",",
"_",
",",
"dmdx",
",",
"_",
"=",
"self",
".",
"cost_model",
".",
"predict_withGradients",
"(",
"x",
")",
"return",
"np",
".",
"exp",
"(",
"m",
")",
",",
"np",
".",
"exp",
... | Predicts the time cost and its gradient of evaluating the function at x. | [
"Predicts",
"the",
"time",
"cost",
"and",
"its",
"gradient",
"of",
"evaluating",
"the",
"function",
"at",
"x",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/cost.py#L48-L53 | train |
SheffieldML/GPyOpt | GPyOpt/core/task/cost.py | CostModel.update_cost_model | def update_cost_model(self, x, cost_x):
"""
Updates the GP used to handle the cost.
param x: input of the GP for the cost model.
param x_cost: values of the time cost at the input locations.
"""
if self.cost_type == 'evaluation_time':
cost_evals = np.log(np.... | python | def update_cost_model(self, x, cost_x):
"""
Updates the GP used to handle the cost.
param x: input of the GP for the cost model.
param x_cost: values of the time cost at the input locations.
"""
if self.cost_type == 'evaluation_time':
cost_evals = np.log(np.... | [
"def",
"update_cost_model",
"(",
"self",
",",
"x",
",",
"cost_x",
")",
":",
"if",
"self",
".",
"cost_type",
"==",
"'evaluation_time'",
":",
"cost_evals",
"=",
"np",
".",
"log",
"(",
"np",
".",
"atleast_2d",
"(",
"np",
".",
"asarray",
"(",
"cost_x",
")"... | Updates the GP used to handle the cost.
param x: input of the GP for the cost model.
param x_cost: values of the time cost at the input locations. | [
"Updates",
"the",
"GP",
"used",
"to",
"handle",
"the",
"cost",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/cost.py#L55-L74 | train |
SheffieldML/GPyOpt | GPyOpt/acquisitions/LP.py | AcquisitionLP.update_batches | def update_batches(self, X_batch, L, Min):
"""
Updates the batches internally and pre-computes the
"""
self.X_batch = X_batch
if X_batch is not None:
self.r_x0, self.s_x0 = self._hammer_function_precompute(X_batch, L, Min, self.model) | python | def update_batches(self, X_batch, L, Min):
"""
Updates the batches internally and pre-computes the
"""
self.X_batch = X_batch
if X_batch is not None:
self.r_x0, self.s_x0 = self._hammer_function_precompute(X_batch, L, Min, self.model) | [
"def",
"update_batches",
"(",
"self",
",",
"X_batch",
",",
"L",
",",
"Min",
")",
":",
"self",
".",
"X_batch",
"=",
"X_batch",
"if",
"X_batch",
"is",
"not",
"None",
":",
"self",
".",
"r_x0",
",",
"self",
".",
"s_x0",
"=",
"self",
".",
"_hammer_functio... | Updates the batches internally and pre-computes the | [
"Updates",
"the",
"batches",
"internally",
"and",
"pre",
"-",
"computes",
"the"
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/acquisitions/LP.py#L40-L46 | train |
SheffieldML/GPyOpt | GPyOpt/acquisitions/LP.py | AcquisitionLP._hammer_function_precompute | def _hammer_function_precompute(self,x0, L, Min, model):
"""
Pre-computes the parameters of a penalizer centered at x0.
"""
if x0 is None: return None, None
if len(x0.shape)==1: x0 = x0[None,:]
m = model.predict(x0)[0]
pred = model.predict(x0)[1].copy()
pr... | python | def _hammer_function_precompute(self,x0, L, Min, model):
"""
Pre-computes the parameters of a penalizer centered at x0.
"""
if x0 is None: return None, None
if len(x0.shape)==1: x0 = x0[None,:]
m = model.predict(x0)[0]
pred = model.predict(x0)[1].copy()
pr... | [
"def",
"_hammer_function_precompute",
"(",
"self",
",",
"x0",
",",
"L",
",",
"Min",
",",
"model",
")",
":",
"if",
"x0",
"is",
"None",
":",
"return",
"None",
",",
"None",
"if",
"len",
"(",
"x0",
".",
"shape",
")",
"==",
"1",
":",
"x0",
"=",
"x0",
... | Pre-computes the parameters of a penalizer centered at x0. | [
"Pre",
"-",
"computes",
"the",
"parameters",
"of",
"a",
"penalizer",
"centered",
"at",
"x0",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/acquisitions/LP.py#L48-L62 | train |
SheffieldML/GPyOpt | GPyOpt/acquisitions/LP.py | AcquisitionLP._hammer_function | def _hammer_function(self, x,x0,r_x0, s_x0):
'''
Creates the function to define the exclusion zones
'''
return norm.logcdf((np.sqrt((np.square(np.atleast_2d(x)[:,None,:]-np.atleast_2d(x0)[None,:,:])).sum(-1))- r_x0)/s_x0) | python | def _hammer_function(self, x,x0,r_x0, s_x0):
'''
Creates the function to define the exclusion zones
'''
return norm.logcdf((np.sqrt((np.square(np.atleast_2d(x)[:,None,:]-np.atleast_2d(x0)[None,:,:])).sum(-1))- r_x0)/s_x0) | [
"def",
"_hammer_function",
"(",
"self",
",",
"x",
",",
"x0",
",",
"r_x0",
",",
"s_x0",
")",
":",
"return",
"norm",
".",
"logcdf",
"(",
"(",
"np",
".",
"sqrt",
"(",
"(",
"np",
".",
"square",
"(",
"np",
".",
"atleast_2d",
"(",
"x",
")",
"[",
":",... | Creates the function to define the exclusion zones | [
"Creates",
"the",
"function",
"to",
"define",
"the",
"exclusion",
"zones"
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/acquisitions/LP.py#L64-L68 | train |
SheffieldML/GPyOpt | GPyOpt/acquisitions/LP.py | AcquisitionLP._penalized_acquisition | def _penalized_acquisition(self, x, model, X_batch, r_x0, s_x0):
'''
Creates a penalized acquisition function using 'hammer' functions around the points collected in the batch
.. Note:: the penalized acquisition is always mapped to the log space. This way gradients can be computed additively a... | python | def _penalized_acquisition(self, x, model, X_batch, r_x0, s_x0):
'''
Creates a penalized acquisition function using 'hammer' functions around the points collected in the batch
.. Note:: the penalized acquisition is always mapped to the log space. This way gradients can be computed additively a... | [
"def",
"_penalized_acquisition",
"(",
"self",
",",
"x",
",",
"model",
",",
"X_batch",
",",
"r_x0",
",",
"s_x0",
")",
":",
"fval",
"=",
"-",
"self",
".",
"acq",
".",
"acquisition_function",
"(",
"x",
")",
"[",
":",
",",
"0",
"]",
"if",
"self",
".",
... | Creates a penalized acquisition function using 'hammer' functions around the points collected in the batch
.. Note:: the penalized acquisition is always mapped to the log space. This way gradients can be computed additively and are more stable. | [
"Creates",
"a",
"penalized",
"acquisition",
"function",
"using",
"hammer",
"functions",
"around",
"the",
"points",
"collected",
"in",
"the",
"batch"
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/acquisitions/LP.py#L70-L89 | train |
SheffieldML/GPyOpt | GPyOpt/acquisitions/LP.py | AcquisitionLP.acquisition_function | def acquisition_function(self, x):
"""
Returns the value of the acquisition function at x.
"""
return self._penalized_acquisition(x, self.model, self.X_batch, self.r_x0, self.s_x0) | python | def acquisition_function(self, x):
"""
Returns the value of the acquisition function at x.
"""
return self._penalized_acquisition(x, self.model, self.X_batch, self.r_x0, self.s_x0) | [
"def",
"acquisition_function",
"(",
"self",
",",
"x",
")",
":",
"return",
"self",
".",
"_penalized_acquisition",
"(",
"x",
",",
"self",
".",
"model",
",",
"self",
".",
"X_batch",
",",
"self",
".",
"r_x0",
",",
"self",
".",
"s_x0",
")"
] | Returns the value of the acquisition function at x. | [
"Returns",
"the",
"value",
"of",
"the",
"acquisition",
"function",
"at",
"x",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/acquisitions/LP.py#L105-L110 | train |
SheffieldML/GPyOpt | GPyOpt/acquisitions/LP.py | AcquisitionLP.d_acquisition_function | def d_acquisition_function(self, x):
"""
Returns the gradient of the acquisition function at x.
"""
x = np.atleast_2d(x)
if self.transform=='softplus':
fval = -self.acq.acquisition_function(x)[:,0]
scale = 1./(np.log1p(np.exp(fval))*(1.+np.exp(-fval)))
... | python | def d_acquisition_function(self, x):
"""
Returns the gradient of the acquisition function at x.
"""
x = np.atleast_2d(x)
if self.transform=='softplus':
fval = -self.acq.acquisition_function(x)[:,0]
scale = 1./(np.log1p(np.exp(fval))*(1.+np.exp(-fval)))
... | [
"def",
"d_acquisition_function",
"(",
"self",
",",
"x",
")",
":",
"x",
"=",
"np",
".",
"atleast_2d",
"(",
"x",
")",
"if",
"self",
".",
"transform",
"==",
"'softplus'",
":",
"fval",
"=",
"-",
"self",
".",
"acq",
".",
"acquisition_function",
"(",
"x",
... | Returns the gradient of the acquisition function at x. | [
"Returns",
"the",
"gradient",
"of",
"the",
"acquisition",
"function",
"at",
"x",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/acquisitions/LP.py#L112-L132 | train |
SheffieldML/GPyOpt | GPyOpt/acquisitions/LP.py | AcquisitionLP.acquisition_function_withGradients | def acquisition_function_withGradients(self, x):
"""
Returns the acquisition function and its its gradient at x.
"""
aqu_x = self.acquisition_function(x)
aqu_x_grad = self.d_acquisition_function(x)
return aqu_x, aqu_x_grad | python | def acquisition_function_withGradients(self, x):
"""
Returns the acquisition function and its its gradient at x.
"""
aqu_x = self.acquisition_function(x)
aqu_x_grad = self.d_acquisition_function(x)
return aqu_x, aqu_x_grad | [
"def",
"acquisition_function_withGradients",
"(",
"self",
",",
"x",
")",
":",
"aqu_x",
"=",
"self",
".",
"acquisition_function",
"(",
"x",
")",
"aqu_x_grad",
"=",
"self",
".",
"d_acquisition_function",
"(",
"x",
")",
"return",
"aqu_x",
",",
"aqu_x_grad"
] | Returns the acquisition function and its its gradient at x. | [
"Returns",
"the",
"acquisition",
"function",
"and",
"its",
"its",
"gradient",
"at",
"x",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/acquisitions/LP.py#L134-L140 | train |
SheffieldML/GPyOpt | GPyOpt/acquisitions/base.py | AcquisitionBase.acquisition_function | def acquisition_function(self,x):
"""
Takes an acquisition and weights it so the domain and cost are taken into account.
"""
f_acqu = self._compute_acq(x)
cost_x, _ = self.cost_withGradients(x)
return -(f_acqu*self.space.indicator_constraints(x))/cost_x | python | def acquisition_function(self,x):
"""
Takes an acquisition and weights it so the domain and cost are taken into account.
"""
f_acqu = self._compute_acq(x)
cost_x, _ = self.cost_withGradients(x)
return -(f_acqu*self.space.indicator_constraints(x))/cost_x | [
"def",
"acquisition_function",
"(",
"self",
",",
"x",
")",
":",
"f_acqu",
"=",
"self",
".",
"_compute_acq",
"(",
"x",
")",
"cost_x",
",",
"_",
"=",
"self",
".",
"cost_withGradients",
"(",
"x",
")",
"return",
"-",
"(",
"f_acqu",
"*",
"self",
".",
"spa... | Takes an acquisition and weights it so the domain and cost are taken into account. | [
"Takes",
"an",
"acquisition",
"and",
"weights",
"it",
"so",
"the",
"domain",
"and",
"cost",
"are",
"taken",
"into",
"account",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/acquisitions/base.py#L33-L39 | train |
SheffieldML/GPyOpt | GPyOpt/acquisitions/base.py | AcquisitionBase.acquisition_function_withGradients | def acquisition_function_withGradients(self, x):
"""
Takes an acquisition and it gradient and weights it so the domain and cost are taken into account.
"""
f_acqu,df_acqu = self._compute_acq_withGradients(x)
cost_x, cost_grad_x = self.cost_withGradients(x)
f_acq_cost = f_... | python | def acquisition_function_withGradients(self, x):
"""
Takes an acquisition and it gradient and weights it so the domain and cost are taken into account.
"""
f_acqu,df_acqu = self._compute_acq_withGradients(x)
cost_x, cost_grad_x = self.cost_withGradients(x)
f_acq_cost = f_... | [
"def",
"acquisition_function_withGradients",
"(",
"self",
",",
"x",
")",
":",
"f_acqu",
",",
"df_acqu",
"=",
"self",
".",
"_compute_acq_withGradients",
"(",
"x",
")",
"cost_x",
",",
"cost_grad_x",
"=",
"self",
".",
"cost_withGradients",
"(",
"x",
")",
"f_acq_c... | Takes an acquisition and it gradient and weights it so the domain and cost are taken into account. | [
"Takes",
"an",
"acquisition",
"and",
"it",
"gradient",
"and",
"weights",
"it",
"so",
"the",
"domain",
"and",
"cost",
"are",
"taken",
"into",
"account",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/acquisitions/base.py#L42-L50 | train |
SheffieldML/GPyOpt | GPyOpt/util/general.py | reshape | def reshape(x,input_dim):
'''
Reshapes x into a matrix with input_dim columns
'''
x = np.array(x)
if x.size ==input_dim:
x = x.reshape((1,input_dim))
return x | python | def reshape(x,input_dim):
'''
Reshapes x into a matrix with input_dim columns
'''
x = np.array(x)
if x.size ==input_dim:
x = x.reshape((1,input_dim))
return x | [
"def",
"reshape",
"(",
"x",
",",
"input_dim",
")",
":",
"x",
"=",
"np",
".",
"array",
"(",
"x",
")",
"if",
"x",
".",
"size",
"==",
"input_dim",
":",
"x",
"=",
"x",
".",
"reshape",
"(",
"(",
"1",
",",
"input_dim",
")",
")",
"return",
"x"
] | Reshapes x into a matrix with input_dim columns | [
"Reshapes",
"x",
"into",
"a",
"matrix",
"with",
"input_dim",
"columns"
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/util/general.py#L76-L84 | train |
SheffieldML/GPyOpt | GPyOpt/util/general.py | spawn | def spawn(f):
'''
Function for parallel evaluation of the acquisition function
'''
def fun(pipe,x):
pipe.send(f(x))
pipe.close()
return fun | python | def spawn(f):
'''
Function for parallel evaluation of the acquisition function
'''
def fun(pipe,x):
pipe.send(f(x))
pipe.close()
return fun | [
"def",
"spawn",
"(",
"f",
")",
":",
"def",
"fun",
"(",
"pipe",
",",
"x",
")",
":",
"pipe",
".",
"send",
"(",
"f",
"(",
"x",
")",
")",
"pipe",
".",
"close",
"(",
")",
"return",
"fun"
] | Function for parallel evaluation of the acquisition function | [
"Function",
"for",
"parallel",
"evaluation",
"of",
"the",
"acquisition",
"function"
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/util/general.py#L144-L151 | train |
SheffieldML/GPyOpt | GPyOpt/util/general.py | values_to_array | def values_to_array(input_values):
'''
Transforms a values of int, float and tuples to a column vector numpy array
'''
if type(input_values)==tuple:
values = np.array(input_values).reshape(-1,1)
elif type(input_values) == np.ndarray:
values = np.atleast_2d(input_values)
elif type... | python | def values_to_array(input_values):
'''
Transforms a values of int, float and tuples to a column vector numpy array
'''
if type(input_values)==tuple:
values = np.array(input_values).reshape(-1,1)
elif type(input_values) == np.ndarray:
values = np.atleast_2d(input_values)
elif type... | [
"def",
"values_to_array",
"(",
"input_values",
")",
":",
"if",
"type",
"(",
"input_values",
")",
"==",
"tuple",
":",
"values",
"=",
"np",
".",
"array",
"(",
"input_values",
")",
".",
"reshape",
"(",
"-",
"1",
",",
"1",
")",
"elif",
"type",
"(",
"inpu... | Transforms a values of int, float and tuples to a column vector numpy array | [
"Transforms",
"a",
"values",
"of",
"int",
"float",
"and",
"tuples",
"to",
"a",
"column",
"vector",
"numpy",
"array"
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/util/general.py#L168-L180 | train |
SheffieldML/GPyOpt | GPyOpt/util/general.py | merge_values | def merge_values(values1,values2):
'''
Merges two numpy arrays by calculating all possible combinations of rows
'''
array1 = values_to_array(values1)
array2 = values_to_array(values2)
if array1.size == 0:
return array2
if array2.size == 0:
return array1
merged_array = [... | python | def merge_values(values1,values2):
'''
Merges two numpy arrays by calculating all possible combinations of rows
'''
array1 = values_to_array(values1)
array2 = values_to_array(values2)
if array1.size == 0:
return array2
if array2.size == 0:
return array1
merged_array = [... | [
"def",
"merge_values",
"(",
"values1",
",",
"values2",
")",
":",
"array1",
"=",
"values_to_array",
"(",
"values1",
")",
"array2",
"=",
"values_to_array",
"(",
"values2",
")",
"if",
"array1",
".",
"size",
"==",
"0",
":",
"return",
"array2",
"if",
"array2",
... | Merges two numpy arrays by calculating all possible combinations of rows | [
"Merges",
"two",
"numpy",
"arrays",
"by",
"calculating",
"all",
"possible",
"combinations",
"of",
"rows"
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/util/general.py#L183-L200 | train |
SheffieldML/GPyOpt | GPyOpt/util/general.py | normalize | def normalize(Y, normalization_type='stats'):
"""Normalize the vector Y using statistics or its range.
:param Y: Row or column vector that you want to normalize.
:param normalization_type: String specifying the kind of normalization
to use. Options are 'stats' to use mean and standard deviation,
or... | python | def normalize(Y, normalization_type='stats'):
"""Normalize the vector Y using statistics or its range.
:param Y: Row or column vector that you want to normalize.
:param normalization_type: String specifying the kind of normalization
to use. Options are 'stats' to use mean and standard deviation,
or... | [
"def",
"normalize",
"(",
"Y",
",",
"normalization_type",
"=",
"'stats'",
")",
":",
"Y",
"=",
"np",
".",
"asarray",
"(",
"Y",
",",
"dtype",
"=",
"float",
")",
"if",
"np",
".",
"max",
"(",
"Y",
".",
"shape",
")",
"!=",
"Y",
".",
"size",
":",
"rai... | Normalize the vector Y using statistics or its range.
:param Y: Row or column vector that you want to normalize.
:param normalization_type: String specifying the kind of normalization
to use. Options are 'stats' to use mean and standard deviation,
or 'maxmin' to use the range of function values.
:r... | [
"Normalize",
"the",
"vector",
"Y",
"using",
"statistics",
"or",
"its",
"range",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/util/general.py#L203-L234 | train |
SheffieldML/GPyOpt | GPyOpt/experiment_design/grid_design.py | GridDesign.get_samples | def get_samples(self, init_points_count):
"""
This method may return less points than requested.
The total number of generated points is the smallest closest integer of n^d to the selected amount of points.
"""
init_points_count = self._adjust_init_points_count(init_points_count... | python | def get_samples(self, init_points_count):
"""
This method may return less points than requested.
The total number of generated points is the smallest closest integer of n^d to the selected amount of points.
"""
init_points_count = self._adjust_init_points_count(init_points_count... | [
"def",
"get_samples",
"(",
"self",
",",
"init_points_count",
")",
":",
"init_points_count",
"=",
"self",
".",
"_adjust_init_points_count",
"(",
"init_points_count",
")",
"samples",
"=",
"np",
".",
"empty",
"(",
"(",
"init_points_count",
",",
"self",
".",
"space"... | This method may return less points than requested.
The total number of generated points is the smallest closest integer of n^d to the selected amount of points. | [
"This",
"method",
"may",
"return",
"less",
"points",
"than",
"requested",
".",
"The",
"total",
"number",
"of",
"generated",
"points",
"is",
"the",
"smallest",
"closest",
"integer",
"of",
"n^d",
"to",
"the",
"selected",
"amount",
"of",
"points",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/experiment_design/grid_design.py#L26-L43 | train |
SheffieldML/GPyOpt | GPyOpt/experiment_design/random_design.py | RandomDesign.get_samples_with_constraints | def get_samples_with_constraints(self, init_points_count):
"""
Draw random samples and only save those that satisfy constraints
Finish when required number of samples is generated
"""
samples = np.empty((0, self.space.dimensionality))
while samples.shape[0] < init_points... | python | def get_samples_with_constraints(self, init_points_count):
"""
Draw random samples and only save those that satisfy constraints
Finish when required number of samples is generated
"""
samples = np.empty((0, self.space.dimensionality))
while samples.shape[0] < init_points... | [
"def",
"get_samples_with_constraints",
"(",
"self",
",",
"init_points_count",
")",
":",
"samples",
"=",
"np",
".",
"empty",
"(",
"(",
"0",
",",
"self",
".",
"space",
".",
"dimensionality",
")",
")",
"while",
"samples",
".",
"shape",
"[",
"0",
"]",
"<",
... | Draw random samples and only save those that satisfy constraints
Finish when required number of samples is generated | [
"Draw",
"random",
"samples",
"and",
"only",
"save",
"those",
"that",
"satisfy",
"constraints",
"Finish",
"when",
"required",
"number",
"of",
"samples",
"is",
"generated"
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/experiment_design/random_design.py#L21-L35 | train |
SheffieldML/GPyOpt | GPyOpt/experiment_design/random_design.py | RandomDesign.fill_noncontinous_variables | def fill_noncontinous_variables(self, samples):
"""
Fill sample values to non-continuous variables in place
"""
init_points_count = samples.shape[0]
for (idx, var) in enumerate(self.space.space_expanded):
if isinstance(var, DiscreteVariable) or isinstance(var, Catego... | python | def fill_noncontinous_variables(self, samples):
"""
Fill sample values to non-continuous variables in place
"""
init_points_count = samples.shape[0]
for (idx, var) in enumerate(self.space.space_expanded):
if isinstance(var, DiscreteVariable) or isinstance(var, Catego... | [
"def",
"fill_noncontinous_variables",
"(",
"self",
",",
"samples",
")",
":",
"init_points_count",
"=",
"samples",
".",
"shape",
"[",
"0",
"]",
"for",
"(",
"idx",
",",
"var",
")",
"in",
"enumerate",
"(",
"self",
".",
"space",
".",
"space_expanded",
")",
"... | Fill sample values to non-continuous variables in place | [
"Fill",
"sample",
"values",
"to",
"non",
"-",
"continuous",
"variables",
"in",
"place"
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/experiment_design/random_design.py#L37-L53 | train |
SheffieldML/GPyOpt | GPyOpt/interface/driver.py | BODriver._get_obj | def _get_obj(self,space):
"""
Imports the acquisition function.
"""
obj_func = self.obj_func
from ..core.task import SingleObjective
return SingleObjective(obj_func, self.config['resources']['cores'], space=space, unfold_args=True) | python | def _get_obj(self,space):
"""
Imports the acquisition function.
"""
obj_func = self.obj_func
from ..core.task import SingleObjective
return SingleObjective(obj_func, self.config['resources']['cores'], space=space, unfold_args=True) | [
"def",
"_get_obj",
"(",
"self",
",",
"space",
")",
":",
"obj_func",
"=",
"self",
".",
"obj_func",
"from",
".",
".",
"core",
".",
"task",
"import",
"SingleObjective",
"return",
"SingleObjective",
"(",
"obj_func",
",",
"self",
".",
"config",
"[",
"'resources... | Imports the acquisition function. | [
"Imports",
"the",
"acquisition",
"function",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/interface/driver.py#L24-L32 | train |
SheffieldML/GPyOpt | GPyOpt/interface/driver.py | BODriver._get_space | def _get_space(self):
"""
Imports the domain.
"""
assert 'space' in self.config, 'The search space is NOT configured!'
space_config = self.config['space']
constraint_config = self.config['constraints']
from ..core.task.space import Design_space
re... | python | def _get_space(self):
"""
Imports the domain.
"""
assert 'space' in self.config, 'The search space is NOT configured!'
space_config = self.config['space']
constraint_config = self.config['constraints']
from ..core.task.space import Design_space
re... | [
"def",
"_get_space",
"(",
"self",
")",
":",
"assert",
"'space'",
"in",
"self",
".",
"config",
",",
"'The search space is NOT configured!'",
"space_config",
"=",
"self",
".",
"config",
"[",
"'space'",
"]",
"constraint_config",
"=",
"self",
".",
"config",
"[",
"... | Imports the domain. | [
"Imports",
"the",
"domain",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/interface/driver.py#L34-L43 | train |
SheffieldML/GPyOpt | GPyOpt/interface/driver.py | BODriver._get_model | def _get_model(self):
"""
Imports the model.
"""
from copy import deepcopy
model_args = deepcopy(self.config['model'])
del model_args['type']
from ..models import select_model
return select_model(self.config['model']['type']).fromConfig(model_arg... | python | def _get_model(self):
"""
Imports the model.
"""
from copy import deepcopy
model_args = deepcopy(self.config['model'])
del model_args['type']
from ..models import select_model
return select_model(self.config['model']['type']).fromConfig(model_arg... | [
"def",
"_get_model",
"(",
"self",
")",
":",
"from",
"copy",
"import",
"deepcopy",
"model_args",
"=",
"deepcopy",
"(",
"self",
".",
"config",
"[",
"'model'",
"]",
")",
"del",
"model_args",
"[",
"'type'",
"]",
"from",
".",
".",
"models",
"import",
"select_... | Imports the model. | [
"Imports",
"the",
"model",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/interface/driver.py#L45-L55 | train |
SheffieldML/GPyOpt | GPyOpt/interface/driver.py | BODriver._get_acquisition | def _get_acquisition(self, model, space):
"""
Imports the acquisition
"""
from copy import deepcopy
acqOpt_config = deepcopy(self.config['acquisition']['optimizer'])
acqOpt_name = acqOpt_config['name']
del acqOpt_config['name']
from ..opt... | python | def _get_acquisition(self, model, space):
"""
Imports the acquisition
"""
from copy import deepcopy
acqOpt_config = deepcopy(self.config['acquisition']['optimizer'])
acqOpt_name = acqOpt_config['name']
del acqOpt_config['name']
from ..opt... | [
"def",
"_get_acquisition",
"(",
"self",
",",
"model",
",",
"space",
")",
":",
"from",
"copy",
"import",
"deepcopy",
"acqOpt_config",
"=",
"deepcopy",
"(",
"self",
".",
"config",
"[",
"'acquisition'",
"]",
"[",
"'optimizer'",
"]",
")",
"acqOpt_name",
"=",
"... | Imports the acquisition | [
"Imports",
"the",
"acquisition"
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/interface/driver.py#L58-L71 | train |
SheffieldML/GPyOpt | GPyOpt/interface/driver.py | BODriver._get_acq_evaluator | def _get_acq_evaluator(self, acq):
"""
Imports the evaluator
"""
from ..core.evaluators import select_evaluator
from copy import deepcopy
eval_args = deepcopy(self.config['acquisition']['evaluator'])
del eval_args['type']
return select_evaluator(self.conf... | python | def _get_acq_evaluator(self, acq):
"""
Imports the evaluator
"""
from ..core.evaluators import select_evaluator
from copy import deepcopy
eval_args = deepcopy(self.config['acquisition']['evaluator'])
del eval_args['type']
return select_evaluator(self.conf... | [
"def",
"_get_acq_evaluator",
"(",
"self",
",",
"acq",
")",
":",
"from",
".",
".",
"core",
".",
"evaluators",
"import",
"select_evaluator",
"from",
"copy",
"import",
"deepcopy",
"eval_args",
"=",
"deepcopy",
"(",
"self",
".",
"config",
"[",
"'acquisition'",
"... | Imports the evaluator | [
"Imports",
"the",
"evaluator"
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/interface/driver.py#L73-L82 | train |
SheffieldML/GPyOpt | GPyOpt/interface/driver.py | BODriver._check_stop | def _check_stop(self, iters, elapsed_time, converged):
"""
Defines the stopping criterion.
"""
r_c = self.config['resources']
stop = False
if converged==0:
stop=True
if r_c['maximum-iterations'] !='NA' and iters>= r_c['maximum-iterations']:
... | python | def _check_stop(self, iters, elapsed_time, converged):
"""
Defines the stopping criterion.
"""
r_c = self.config['resources']
stop = False
if converged==0:
stop=True
if r_c['maximum-iterations'] !='NA' and iters>= r_c['maximum-iterations']:
... | [
"def",
"_check_stop",
"(",
"self",
",",
"iters",
",",
"elapsed_time",
",",
"converged",
")",
":",
"r_c",
"=",
"self",
".",
"config",
"[",
"'resources'",
"]",
"stop",
"=",
"False",
"if",
"converged",
"==",
"0",
":",
"stop",
"=",
"True",
"if",
"r_c",
"... | Defines the stopping criterion. | [
"Defines",
"the",
"stopping",
"criterion",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/interface/driver.py#L84-L98 | train |
SheffieldML/GPyOpt | GPyOpt/interface/driver.py | BODriver.run | def run(self):
"""
Runs the optimization using the previously loaded elements.
"""
space = self._get_space()
obj_func = self._get_obj(space)
model = self._get_model()
acq = self._get_acquisition(model, space)
acq_eval = self._get_acq_evaluator(acq)
... | python | def run(self):
"""
Runs the optimization using the previously loaded elements.
"""
space = self._get_space()
obj_func = self._get_obj(space)
model = self._get_model()
acq = self._get_acquisition(model, space)
acq_eval = self._get_acq_evaluator(acq)
... | [
"def",
"run",
"(",
"self",
")",
":",
"space",
"=",
"self",
".",
"_get_space",
"(",
")",
"obj_func",
"=",
"self",
".",
"_get_obj",
"(",
"space",
")",
"model",
"=",
"self",
".",
"_get_model",
"(",
")",
"acq",
"=",
"self",
".",
"_get_acquisition",
"(",
... | Runs the optimization using the previously loaded elements. | [
"Runs",
"the",
"optimization",
"using",
"the",
"previously",
"loaded",
"elements",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/interface/driver.py#L100-L119 | train |
SheffieldML/GPyOpt | GPyOpt/optimization/optimizer.py | choose_optimizer | def choose_optimizer(optimizer_name, bounds):
"""
Selects the type of local optimizer
"""
if optimizer_name == 'lbfgs':
optimizer = OptLbfgs(bounds)
elif optimizer_name == 'DIRECT':
optimizer = OptDirect(bounds)
elif optimizer_name == 'CMA':
... | python | def choose_optimizer(optimizer_name, bounds):
"""
Selects the type of local optimizer
"""
if optimizer_name == 'lbfgs':
optimizer = OptLbfgs(bounds)
elif optimizer_name == 'DIRECT':
optimizer = OptDirect(bounds)
elif optimizer_name == 'CMA':
... | [
"def",
"choose_optimizer",
"(",
"optimizer_name",
",",
"bounds",
")",
":",
"if",
"optimizer_name",
"==",
"'lbfgs'",
":",
"optimizer",
"=",
"OptLbfgs",
"(",
"bounds",
")",
"elif",
"optimizer_name",
"==",
"'DIRECT'",
":",
"optimizer",
"=",
"OptDirect",
"(",
"bou... | Selects the type of local optimizer | [
"Selects",
"the",
"type",
"of",
"local",
"optimizer"
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/optimization/optimizer.py#L238-L253 | train |
SheffieldML/GPyOpt | GPyOpt/util/arguments_manager.py | ArgumentsManager.evaluator_creator | def evaluator_creator(self, evaluator_type, acquisition, batch_size, model_type, model, space, acquisition_optimizer):
"""
Acquisition chooser from the available options. Guide the optimization through sequential or parallel evalutions of the objective.
"""
acquisition_transformation = s... | python | def evaluator_creator(self, evaluator_type, acquisition, batch_size, model_type, model, space, acquisition_optimizer):
"""
Acquisition chooser from the available options. Guide the optimization through sequential or parallel evalutions of the objective.
"""
acquisition_transformation = s... | [
"def",
"evaluator_creator",
"(",
"self",
",",
"evaluator_type",
",",
"acquisition",
",",
"batch_size",
",",
"model_type",
",",
"model",
",",
"space",
",",
"acquisition_optimizer",
")",
":",
"acquisition_transformation",
"=",
"self",
".",
"kwargs",
".",
"get",
"(... | Acquisition chooser from the available options. Guide the optimization through sequential or parallel evalutions of the objective. | [
"Acquisition",
"chooser",
"from",
"the",
"available",
"options",
".",
"Guide",
"the",
"optimization",
"through",
"sequential",
"or",
"parallel",
"evalutions",
"of",
"the",
"objective",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/util/arguments_manager.py#L17-L38 | train |
SheffieldML/GPyOpt | GPyOpt/acquisitions/LCB.py | AcquisitionLCB._compute_acq | def _compute_acq(self, x):
"""
Computes the GP-Lower Confidence Bound
"""
m, s = self.model.predict(x)
f_acqu = -m + self.exploration_weight * s
return f_acqu | python | def _compute_acq(self, x):
"""
Computes the GP-Lower Confidence Bound
"""
m, s = self.model.predict(x)
f_acqu = -m + self.exploration_weight * s
return f_acqu | [
"def",
"_compute_acq",
"(",
"self",
",",
"x",
")",
":",
"m",
",",
"s",
"=",
"self",
".",
"model",
".",
"predict",
"(",
"x",
")",
"f_acqu",
"=",
"-",
"m",
"+",
"self",
".",
"exploration_weight",
"*",
"s",
"return",
"f_acqu"
] | Computes the GP-Lower Confidence Bound | [
"Computes",
"the",
"GP",
"-",
"Lower",
"Confidence",
"Bound"
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/acquisitions/LCB.py#L31-L37 | train |
SheffieldML/GPyOpt | GPyOpt/acquisitions/LCB.py | AcquisitionLCB._compute_acq_withGradients | def _compute_acq_withGradients(self, x):
"""
Computes the GP-Lower Confidence Bound and its derivative
"""
m, s, dmdx, dsdx = self.model.predict_withGradients(x)
f_acqu = -m + self.exploration_weight * s
df_acqu = -dmdx + self.exploration_weight * dsdx
ret... | python | def _compute_acq_withGradients(self, x):
"""
Computes the GP-Lower Confidence Bound and its derivative
"""
m, s, dmdx, dsdx = self.model.predict_withGradients(x)
f_acqu = -m + self.exploration_weight * s
df_acqu = -dmdx + self.exploration_weight * dsdx
ret... | [
"def",
"_compute_acq_withGradients",
"(",
"self",
",",
"x",
")",
":",
"m",
",",
"s",
",",
"dmdx",
",",
"dsdx",
"=",
"self",
".",
"model",
".",
"predict_withGradients",
"(",
"x",
")",
"f_acqu",
"=",
"-",
"m",
"+",
"self",
".",
"exploration_weight",
"*",... | Computes the GP-Lower Confidence Bound and its derivative | [
"Computes",
"the",
"GP",
"-",
"Lower",
"Confidence",
"Bound",
"and",
"its",
"derivative"
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/acquisitions/LCB.py#L39-L46 | train |
SheffieldML/GPyOpt | GPyOpt/core/task/variables.py | create_variable | def create_variable(descriptor):
"""
Creates a variable from a dictionary descriptor
"""
if descriptor['type'] == 'continuous':
return ContinuousVariable(descriptor['name'], descriptor['domain'], descriptor.get('dimensionality', 1))
elif descriptor['type'] == 'bandit':
return BanditV... | python | def create_variable(descriptor):
"""
Creates a variable from a dictionary descriptor
"""
if descriptor['type'] == 'continuous':
return ContinuousVariable(descriptor['name'], descriptor['domain'], descriptor.get('dimensionality', 1))
elif descriptor['type'] == 'bandit':
return BanditV... | [
"def",
"create_variable",
"(",
"descriptor",
")",
":",
"if",
"descriptor",
"[",
"'type'",
"]",
"==",
"'continuous'",
":",
"return",
"ContinuousVariable",
"(",
"descriptor",
"[",
"'name'",
"]",
",",
"descriptor",
"[",
"'domain'",
"]",
",",
"descriptor",
".",
... | Creates a variable from a dictionary descriptor | [
"Creates",
"a",
"variable",
"from",
"a",
"dictionary",
"descriptor"
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/variables.py#L230-L243 | train |
SheffieldML/GPyOpt | GPyOpt/core/task/variables.py | Variable.expand | def expand(self):
"""
Builds a list of single dimensional variables representing current variable.
Examples:
For single dimensional variable, it is returned as is
discrete of (0,2,4) -> discrete of (0,2,4)
For multi dimensional variable, a list of variables is returned, ... | python | def expand(self):
"""
Builds a list of single dimensional variables representing current variable.
Examples:
For single dimensional variable, it is returned as is
discrete of (0,2,4) -> discrete of (0,2,4)
For multi dimensional variable, a list of variables is returned, ... | [
"def",
"expand",
"(",
"self",
")",
":",
"expanded_variables",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"dimensionality",
")",
":",
"one_d_variable",
"=",
"deepcopy",
"(",
"self",
")",
"one_d_variable",
".",
"dimensionality",
"=",
"1",
... | Builds a list of single dimensional variables representing current variable.
Examples:
For single dimensional variable, it is returned as is
discrete of (0,2,4) -> discrete of (0,2,4)
For multi dimensional variable, a list of variables is returned, each representing a single dimension
... | [
"Builds",
"a",
"list",
"of",
"single",
"dimensional",
"variables",
"representing",
"current",
"variable",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/variables.py#L16-L36 | train |
SheffieldML/GPyOpt | GPyOpt/core/task/variables.py | ContinuousVariable.round | def round(self, value_array):
"""
If value falls within bounds, just return it
otherwise return min or max, whichever is closer to the value
Assumes an 1d array with a single element as an input.
"""
min_value = self.domain[0]
max_value = self.domain[1]
... | python | def round(self, value_array):
"""
If value falls within bounds, just return it
otherwise return min or max, whichever is closer to the value
Assumes an 1d array with a single element as an input.
"""
min_value = self.domain[0]
max_value = self.domain[1]
... | [
"def",
"round",
"(",
"self",
",",
"value_array",
")",
":",
"min_value",
"=",
"self",
".",
"domain",
"[",
"0",
"]",
"max_value",
"=",
"self",
".",
"domain",
"[",
"1",
"]",
"rounded_value",
"=",
"value_array",
"[",
"0",
"]",
"if",
"rounded_value",
"<",
... | If value falls within bounds, just return it
otherwise return min or max, whichever is closer to the value
Assumes an 1d array with a single element as an input. | [
"If",
"value",
"falls",
"within",
"bounds",
"just",
"return",
"it",
"otherwise",
"return",
"min",
"or",
"max",
"whichever",
"is",
"closer",
"to",
"the",
"value",
"Assumes",
"an",
"1d",
"array",
"with",
"a",
"single",
"element",
"as",
"an",
"input",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/variables.py#L100-L116 | train |
SheffieldML/GPyOpt | GPyOpt/core/task/variables.py | BanditVariable.round | def round(self, value_array):
"""
Rounds a bandit variable by selecting the closest point in the domain
Closest here is defined by euclidian distance
Assumes an 1d array of the same length as the single variable value
"""
distances = np.linalg.norm(np.array(self.domain) -... | python | def round(self, value_array):
"""
Rounds a bandit variable by selecting the closest point in the domain
Closest here is defined by euclidian distance
Assumes an 1d array of the same length as the single variable value
"""
distances = np.linalg.norm(np.array(self.domain) -... | [
"def",
"round",
"(",
"self",
",",
"value_array",
")",
":",
"distances",
"=",
"np",
".",
"linalg",
".",
"norm",
"(",
"np",
".",
"array",
"(",
"self",
".",
"domain",
")",
"-",
"value_array",
",",
"axis",
"=",
"1",
")",
"idx",
"=",
"np",
".",
"argmi... | Rounds a bandit variable by selecting the closest point in the domain
Closest here is defined by euclidian distance
Assumes an 1d array of the same length as the single variable value | [
"Rounds",
"a",
"bandit",
"variable",
"by",
"selecting",
"the",
"closest",
"point",
"in",
"the",
"domain",
"Closest",
"here",
"is",
"defined",
"by",
"euclidian",
"distance",
"Assumes",
"an",
"1d",
"array",
"of",
"the",
"same",
"length",
"as",
"the",
"single",... | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/variables.py#L151-L159 | train |
SheffieldML/GPyOpt | GPyOpt/core/task/variables.py | DiscreteVariable.round | def round(self, value_array):
"""
Rounds a discrete variable by selecting the closest point in the domain
Assumes an 1d array with a single element as an input.
"""
value = value_array[0]
rounded_value = self.domain[0]
for domain_value in self.domain:
... | python | def round(self, value_array):
"""
Rounds a discrete variable by selecting the closest point in the domain
Assumes an 1d array with a single element as an input.
"""
value = value_array[0]
rounded_value = self.domain[0]
for domain_value in self.domain:
... | [
"def",
"round",
"(",
"self",
",",
"value_array",
")",
":",
"value",
"=",
"value_array",
"[",
"0",
"]",
"rounded_value",
"=",
"self",
".",
"domain",
"[",
"0",
"]",
"for",
"domain_value",
"in",
"self",
".",
"domain",
":",
"if",
"np",
".",
"abs",
"(",
... | Rounds a discrete variable by selecting the closest point in the domain
Assumes an 1d array with a single element as an input. | [
"Rounds",
"a",
"discrete",
"variable",
"by",
"selecting",
"the",
"closest",
"point",
"in",
"the",
"domain",
"Assumes",
"an",
"1d",
"array",
"with",
"a",
"single",
"element",
"as",
"an",
"input",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/variables.py#L175-L187 | train |
SheffieldML/GPyOpt | GPyOpt/optimization/acquisition_optimizer.py | AcquisitionOptimizer.optimize | def optimize(self, f=None, df=None, f_df=None, duplicate_manager=None):
"""
Optimizes the input function.
:param f: function to optimize.
:param df: gradient of the function to optimize.
:param f_df: returns both the function to optimize and its gradient.
"""
se... | python | def optimize(self, f=None, df=None, f_df=None, duplicate_manager=None):
"""
Optimizes the input function.
:param f: function to optimize.
:param df: gradient of the function to optimize.
:param f_df: returns both the function to optimize and its gradient.
"""
se... | [
"def",
"optimize",
"(",
"self",
",",
"f",
"=",
"None",
",",
"df",
"=",
"None",
",",
"f_df",
"=",
"None",
",",
"duplicate_manager",
"=",
"None",
")",
":",
"self",
".",
"f",
"=",
"f",
"self",
".",
"df",
"=",
"df",
"self",
".",
"f_df",
"=",
"f_df"... | Optimizes the input function.
:param f: function to optimize.
:param df: gradient of the function to optimize.
:param f_df: returns both the function to optimize and its gradient. | [
"Optimizes",
"the",
"input",
"function",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/optimization/acquisition_optimizer.py#L46-L77 | train |
SheffieldML/GPyOpt | GPyOpt/core/task/objective.py | SingleObjective.evaluate | def evaluate(self, x):
"""
Performs the evaluation of the objective at x.
"""
if self.n_procs == 1:
f_evals, cost_evals = self._eval_func(x)
else:
try:
f_evals, cost_evals = self._syncronous_batch_evaluation(x)
except:
... | python | def evaluate(self, x):
"""
Performs the evaluation of the objective at x.
"""
if self.n_procs == 1:
f_evals, cost_evals = self._eval_func(x)
else:
try:
f_evals, cost_evals = self._syncronous_batch_evaluation(x)
except:
... | [
"def",
"evaluate",
"(",
"self",
",",
"x",
")",
":",
"if",
"self",
".",
"n_procs",
"==",
"1",
":",
"f_evals",
",",
"cost_evals",
"=",
"self",
".",
"_eval_func",
"(",
"x",
")",
"else",
":",
"try",
":",
"f_evals",
",",
"cost_evals",
"=",
"self",
".",
... | Performs the evaluation of the objective at x. | [
"Performs",
"the",
"evaluation",
"of",
"the",
"objective",
"at",
"x",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/objective.py#L44-L61 | train |
SheffieldML/GPyOpt | GPyOpt/core/task/objective.py | SingleObjective._syncronous_batch_evaluation | def _syncronous_batch_evaluation(self,x):
"""
Evaluates the function a x, where x can be a single location or a batch. The evaluation is performed in parallel
according to the number of accessible cores.
"""
from multiprocessing import Process, Pipe
# --- parallel evalua... | python | def _syncronous_batch_evaluation(self,x):
"""
Evaluates the function a x, where x can be a single location or a batch. The evaluation is performed in parallel
according to the number of accessible cores.
"""
from multiprocessing import Process, Pipe
# --- parallel evalua... | [
"def",
"_syncronous_batch_evaluation",
"(",
"self",
",",
"x",
")",
":",
"from",
"multiprocessing",
"import",
"Process",
",",
"Pipe",
"# --- parallel evaluation of the function",
"divided_samples",
"=",
"[",
"x",
"[",
"i",
":",
":",
"self",
".",
"n_procs",
"]",
"... | Evaluates the function a x, where x can be a single location or a batch. The evaluation is performed in parallel
according to the number of accessible cores. | [
"Evaluates",
"the",
"function",
"a",
"x",
"where",
"x",
"can",
"be",
"a",
"single",
"location",
"or",
"a",
"batch",
".",
"The",
"evaluation",
"is",
"performed",
"in",
"parallel",
"according",
"to",
"the",
"number",
"of",
"accessible",
"cores",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/objective.py#L80-L101 | train |
SheffieldML/GPyOpt | GPyOpt/core/evaluators/sequential.py | Sequential.compute_batch | def compute_batch(self, duplicate_manager=None,context_manager=None):
"""
Selects the new location to evaluate the objective.
"""
x, _ = self.acquisition.optimize(duplicate_manager=duplicate_manager)
return x | python | def compute_batch(self, duplicate_manager=None,context_manager=None):
"""
Selects the new location to evaluate the objective.
"""
x, _ = self.acquisition.optimize(duplicate_manager=duplicate_manager)
return x | [
"def",
"compute_batch",
"(",
"self",
",",
"duplicate_manager",
"=",
"None",
",",
"context_manager",
"=",
"None",
")",
":",
"x",
",",
"_",
"=",
"self",
".",
"acquisition",
".",
"optimize",
"(",
"duplicate_manager",
"=",
"duplicate_manager",
")",
"return",
"x"... | Selects the new location to evaluate the objective. | [
"Selects",
"the",
"new",
"location",
"to",
"evaluate",
"the",
"objective",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/evaluators/sequential.py#L18-L23 | train |
SheffieldML/GPyOpt | GPyOpt/acquisitions/LCB_mcmc.py | AcquisitionLCB_MCMC._compute_acq | def _compute_acq(self,x):
"""
Integrated GP-Lower Confidence Bound
"""
means, stds = self.model.predict(x)
f_acqu = 0
for m,s in zip(means, stds):
f_acqu += -m + self.exploration_weight * s
return f_acqu/(len(means)) | python | def _compute_acq(self,x):
"""
Integrated GP-Lower Confidence Bound
"""
means, stds = self.model.predict(x)
f_acqu = 0
for m,s in zip(means, stds):
f_acqu += -m + self.exploration_weight * s
return f_acqu/(len(means)) | [
"def",
"_compute_acq",
"(",
"self",
",",
"x",
")",
":",
"means",
",",
"stds",
"=",
"self",
".",
"model",
".",
"predict",
"(",
"x",
")",
"f_acqu",
"=",
"0",
"for",
"m",
",",
"s",
"in",
"zip",
"(",
"means",
",",
"stds",
")",
":",
"f_acqu",
"+=",
... | Integrated GP-Lower Confidence Bound | [
"Integrated",
"GP",
"-",
"Lower",
"Confidence",
"Bound"
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/acquisitions/LCB_mcmc.py#L26-L34 | train |
SheffieldML/GPyOpt | GPyOpt/acquisitions/LCB_mcmc.py | AcquisitionLCB_MCMC._compute_acq_withGradients | def _compute_acq_withGradients(self, x):
"""
Integrated GP-Lower Confidence Bound and its derivative
"""
means, stds, dmdxs, dsdxs = self.model.predict_withGradients(x)
f_acqu = None
df_acqu = None
for m, s, dmdx, dsdx in zip(means, stds, dmdxs, dsdxs):
... | python | def _compute_acq_withGradients(self, x):
"""
Integrated GP-Lower Confidence Bound and its derivative
"""
means, stds, dmdxs, dsdxs = self.model.predict_withGradients(x)
f_acqu = None
df_acqu = None
for m, s, dmdx, dsdx in zip(means, stds, dmdxs, dsdxs):
... | [
"def",
"_compute_acq_withGradients",
"(",
"self",
",",
"x",
")",
":",
"means",
",",
"stds",
",",
"dmdxs",
",",
"dsdxs",
"=",
"self",
".",
"model",
".",
"predict_withGradients",
"(",
"x",
")",
"f_acqu",
"=",
"None",
"df_acqu",
"=",
"None",
"for",
"m",
"... | Integrated GP-Lower Confidence Bound and its derivative | [
"Integrated",
"GP",
"-",
"Lower",
"Confidence",
"Bound",
"and",
"its",
"derivative"
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/acquisitions/LCB_mcmc.py#L36-L52 | train |
SheffieldML/GPyOpt | GPyOpt/core/task/space.py | Design_space._expand_config_space | def _expand_config_space(self):
"""
Expands the config input space into a list of diccionaries, one for each variable_dic
in which the dimensionality is always one.
Example: It would transform
config_space =[ {'name': 'var_1', 'type': 'continuous', 'domain':(-1,1), 'dimensionali... | python | def _expand_config_space(self):
"""
Expands the config input space into a list of diccionaries, one for each variable_dic
in which the dimensionality is always one.
Example: It would transform
config_space =[ {'name': 'var_1', 'type': 'continuous', 'domain':(-1,1), 'dimensionali... | [
"def",
"_expand_config_space",
"(",
"self",
")",
":",
"self",
".",
"config_space_expanded",
"=",
"[",
"]",
"for",
"variable",
"in",
"self",
".",
"config_space",
":",
"variable_dic",
"=",
"variable",
".",
"copy",
"(",
")",
"if",
"'dimensionality'",
"in",
"var... | Expands the config input space into a list of diccionaries, one for each variable_dic
in which the dimensionality is always one.
Example: It would transform
config_space =[ {'name': 'var_1', 'type': 'continuous', 'domain':(-1,1), 'dimensionality':1},
{'name': 'var_2', 't... | [
"Expands",
"the",
"config",
"input",
"space",
"into",
"a",
"list",
"of",
"diccionaries",
"one",
"for",
"each",
"variable_dic",
"in",
"which",
"the",
"dimensionality",
"is",
"always",
"one",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/space.py#L101-L131 | train |
SheffieldML/GPyOpt | GPyOpt/core/task/space.py | Design_space._create_variables_dic | def _create_variables_dic(self):
"""
Returns the variable by passing its name
"""
self.name_to_variable = {}
for variable in self.space_expanded:
self.name_to_variable[variable.name] = variable | python | def _create_variables_dic(self):
"""
Returns the variable by passing its name
"""
self.name_to_variable = {}
for variable in self.space_expanded:
self.name_to_variable[variable.name] = variable | [
"def",
"_create_variables_dic",
"(",
"self",
")",
":",
"self",
".",
"name_to_variable",
"=",
"{",
"}",
"for",
"variable",
"in",
"self",
".",
"space_expanded",
":",
"self",
".",
"name_to_variable",
"[",
"variable",
".",
"name",
"]",
"=",
"variable"
] | Returns the variable by passing its name | [
"Returns",
"the",
"variable",
"by",
"passing",
"its",
"name"
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/space.py#L162-L168 | train |
SheffieldML/GPyOpt | GPyOpt/core/task/space.py | Design_space._translate_space | def _translate_space(self, space):
"""
Translates a list of dictionaries into internal list of variables
"""
self.space = []
self.dimensionality = 0
self.has_types = d = {t: False for t in self.supported_types}
for i, d in enumerate(space):
descriptor... | python | def _translate_space(self, space):
"""
Translates a list of dictionaries into internal list of variables
"""
self.space = []
self.dimensionality = 0
self.has_types = d = {t: False for t in self.supported_types}
for i, d in enumerate(space):
descriptor... | [
"def",
"_translate_space",
"(",
"self",
",",
"space",
")",
":",
"self",
".",
"space",
"=",
"[",
"]",
"self",
".",
"dimensionality",
"=",
"0",
"self",
".",
"has_types",
"=",
"d",
"=",
"{",
"t",
":",
"False",
"for",
"t",
"in",
"self",
".",
"supported... | Translates a list of dictionaries into internal list of variables | [
"Translates",
"a",
"list",
"of",
"dictionaries",
"into",
"internal",
"list",
"of",
"variables"
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/space.py#L170-L191 | train |
SheffieldML/GPyOpt | GPyOpt/core/task/space.py | Design_space._expand_space | def _expand_space(self):
"""
Creates an internal list where the variables with dimensionality larger than one are expanded.
This list is the one that is used internally to do the optimization.
"""
## --- Expand the config space
self._expand_config_space()
## ---... | python | def _expand_space(self):
"""
Creates an internal list where the variables with dimensionality larger than one are expanded.
This list is the one that is used internally to do the optimization.
"""
## --- Expand the config space
self._expand_config_space()
## ---... | [
"def",
"_expand_space",
"(",
"self",
")",
":",
"## --- Expand the config space",
"self",
".",
"_expand_config_space",
"(",
")",
"## --- Expand the space",
"self",
".",
"space_expanded",
"=",
"[",
"]",
"for",
"variable",
"in",
"self",
".",
"space",
":",
"self",
"... | Creates an internal list where the variables with dimensionality larger than one are expanded.
This list is the one that is used internally to do the optimization. | [
"Creates",
"an",
"internal",
"list",
"where",
"the",
"variables",
"with",
"dimensionality",
"larger",
"than",
"one",
"are",
"expanded",
".",
"This",
"list",
"is",
"the",
"one",
"that",
"is",
"used",
"internally",
"to",
"do",
"the",
"optimization",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/space.py#L193-L205 | train |
SheffieldML/GPyOpt | GPyOpt/core/task/space.py | Design_space.objective_to_model | def objective_to_model(self, x_objective):
''' This function serves as interface between objective input vectors and
model input vectors'''
x_model = []
for k in range(self.objective_dimensionality):
variable = self.space_expanded[k]
new_entry = variable.objecti... | python | def objective_to_model(self, x_objective):
''' This function serves as interface between objective input vectors and
model input vectors'''
x_model = []
for k in range(self.objective_dimensionality):
variable = self.space_expanded[k]
new_entry = variable.objecti... | [
"def",
"objective_to_model",
"(",
"self",
",",
"x_objective",
")",
":",
"x_model",
"=",
"[",
"]",
"for",
"k",
"in",
"range",
"(",
"self",
".",
"objective_dimensionality",
")",
":",
"variable",
"=",
"self",
".",
"space_expanded",
"[",
"k",
"]",
"new_entry",... | This function serves as interface between objective input vectors and
model input vectors | [
"This",
"function",
"serves",
"as",
"interface",
"between",
"objective",
"input",
"vectors",
"and",
"model",
"input",
"vectors"
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/space.py#L207-L218 | train |
SheffieldML/GPyOpt | GPyOpt/core/task/space.py | Design_space.model_to_objective | def model_to_objective(self, x_model):
''' This function serves as interface between model input vectors and
objective input vectors
'''
idx_model = 0
x_objective = []
for idx_obj in range(self.objective_dimensionality):
variable = self.space_expanded[idx... | python | def model_to_objective(self, x_model):
''' This function serves as interface between model input vectors and
objective input vectors
'''
idx_model = 0
x_objective = []
for idx_obj in range(self.objective_dimensionality):
variable = self.space_expanded[idx... | [
"def",
"model_to_objective",
"(",
"self",
",",
"x_model",
")",
":",
"idx_model",
"=",
"0",
"x_objective",
"=",
"[",
"]",
"for",
"idx_obj",
"in",
"range",
"(",
"self",
".",
"objective_dimensionality",
")",
":",
"variable",
"=",
"self",
".",
"space_expanded",
... | This function serves as interface between model input vectors and
objective input vectors | [
"This",
"function",
"serves",
"as",
"interface",
"between",
"model",
"input",
"vectors",
"and",
"objective",
"input",
"vectors"
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/space.py#L238-L251 | train |
SheffieldML/GPyOpt | GPyOpt/core/task/space.py | Design_space.get_subspace | def get_subspace(self, dims):
'''
Extracts subspace from the reference of a list of variables in the inputs
of the model.
'''
subspace = []
k = 0
for variable in self.space_expanded:
if k in dims:
subspace.append(variable)
k... | python | def get_subspace(self, dims):
'''
Extracts subspace from the reference of a list of variables in the inputs
of the model.
'''
subspace = []
k = 0
for variable in self.space_expanded:
if k in dims:
subspace.append(variable)
k... | [
"def",
"get_subspace",
"(",
"self",
",",
"dims",
")",
":",
"subspace",
"=",
"[",
"]",
"k",
"=",
"0",
"for",
"variable",
"in",
"self",
".",
"space_expanded",
":",
"if",
"k",
"in",
"dims",
":",
"subspace",
".",
"append",
"(",
"variable",
")",
"k",
"+... | Extracts subspace from the reference of a list of variables in the inputs
of the model. | [
"Extracts",
"subspace",
"from",
"the",
"reference",
"of",
"a",
"list",
"of",
"variables",
"in",
"the",
"inputs",
"of",
"the",
"model",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/space.py#L283-L294 | train |
SheffieldML/GPyOpt | GPyOpt/core/task/space.py | Design_space.indicator_constraints | def indicator_constraints(self,x):
"""
Returns array of ones and zeros indicating if x is within the constraints
"""
x = np.atleast_2d(x)
I_x = np.ones((x.shape[0],1))
if self.constraints is not None:
for d in self.constraints:
try:
... | python | def indicator_constraints(self,x):
"""
Returns array of ones and zeros indicating if x is within the constraints
"""
x = np.atleast_2d(x)
I_x = np.ones((x.shape[0],1))
if self.constraints is not None:
for d in self.constraints:
try:
... | [
"def",
"indicator_constraints",
"(",
"self",
",",
"x",
")",
":",
"x",
"=",
"np",
".",
"atleast_2d",
"(",
"x",
")",
"I_x",
"=",
"np",
".",
"ones",
"(",
"(",
"x",
".",
"shape",
"[",
"0",
"]",
",",
"1",
")",
")",
"if",
"self",
".",
"constraints",
... | Returns array of ones and zeros indicating if x is within the constraints | [
"Returns",
"array",
"of",
"ones",
"and",
"zeros",
"indicating",
"if",
"x",
"is",
"within",
"the",
"constraints"
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/space.py#L297-L312 | train |
SheffieldML/GPyOpt | GPyOpt/core/task/space.py | Design_space.input_dim | def input_dim(self):
"""
Extracts the input dimension of the domain.
"""
n_cont = len(self.get_continuous_dims())
n_disc = len(self.get_discrete_dims())
return n_cont + n_disc | python | def input_dim(self):
"""
Extracts the input dimension of the domain.
"""
n_cont = len(self.get_continuous_dims())
n_disc = len(self.get_discrete_dims())
return n_cont + n_disc | [
"def",
"input_dim",
"(",
"self",
")",
":",
"n_cont",
"=",
"len",
"(",
"self",
".",
"get_continuous_dims",
"(",
")",
")",
"n_disc",
"=",
"len",
"(",
"self",
".",
"get_discrete_dims",
"(",
")",
")",
"return",
"n_cont",
"+",
"n_disc"
] | Extracts the input dimension of the domain. | [
"Extracts",
"the",
"input",
"dimension",
"of",
"the",
"domain",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/space.py#L314-L320 | train |
SheffieldML/GPyOpt | GPyOpt/core/task/space.py | Design_space.round_optimum | def round_optimum(self, x):
"""
Rounds some value x to a feasible value in the design space.
x is expected to be a vector or an array with a single row
"""
x = np.array(x)
if not ((x.ndim == 1) or (x.ndim == 2 and x.shape[0] == 1)):
raise ValueError("Unexpecte... | python | def round_optimum(self, x):
"""
Rounds some value x to a feasible value in the design space.
x is expected to be a vector or an array with a single row
"""
x = np.array(x)
if not ((x.ndim == 1) or (x.ndim == 2 and x.shape[0] == 1)):
raise ValueError("Unexpecte... | [
"def",
"round_optimum",
"(",
"self",
",",
"x",
")",
":",
"x",
"=",
"np",
".",
"array",
"(",
"x",
")",
"if",
"not",
"(",
"(",
"x",
".",
"ndim",
"==",
"1",
")",
"or",
"(",
"x",
".",
"ndim",
"==",
"2",
"and",
"x",
".",
"shape",
"[",
"0",
"]"... | Rounds some value x to a feasible value in the design space.
x is expected to be a vector or an array with a single row | [
"Rounds",
"some",
"value",
"x",
"to",
"a",
"feasible",
"value",
"in",
"the",
"design",
"space",
".",
"x",
"is",
"expected",
"to",
"be",
"a",
"vector",
"or",
"an",
"array",
"with",
"a",
"single",
"row"
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/space.py#L322-L343 | train |
SheffieldML/GPyOpt | GPyOpt/core/task/space.py | Design_space.get_continuous_bounds | def get_continuous_bounds(self):
"""
Extracts the bounds of the continuous variables.
"""
bounds = []
for d in self.space:
if d.type == 'continuous':
bounds.extend([d.domain]*d.dimensionality)
return bounds | python | def get_continuous_bounds(self):
"""
Extracts the bounds of the continuous variables.
"""
bounds = []
for d in self.space:
if d.type == 'continuous':
bounds.extend([d.domain]*d.dimensionality)
return bounds | [
"def",
"get_continuous_bounds",
"(",
"self",
")",
":",
"bounds",
"=",
"[",
"]",
"for",
"d",
"in",
"self",
".",
"space",
":",
"if",
"d",
".",
"type",
"==",
"'continuous'",
":",
"bounds",
".",
"extend",
"(",
"[",
"d",
".",
"domain",
"]",
"*",
"d",
... | Extracts the bounds of the continuous variables. | [
"Extracts",
"the",
"bounds",
"of",
"the",
"continuous",
"variables",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/space.py#L353-L361 | train |
SheffieldML/GPyOpt | GPyOpt/core/task/space.py | Design_space.get_continuous_dims | def get_continuous_dims(self):
"""
Returns the dimension of the continuous components of the domain.
"""
continuous_dims = []
for i in range(self.dimensionality):
if self.space_expanded[i].type == 'continuous':
continuous_dims += [i]
return con... | python | def get_continuous_dims(self):
"""
Returns the dimension of the continuous components of the domain.
"""
continuous_dims = []
for i in range(self.dimensionality):
if self.space_expanded[i].type == 'continuous':
continuous_dims += [i]
return con... | [
"def",
"get_continuous_dims",
"(",
"self",
")",
":",
"continuous_dims",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"dimensionality",
")",
":",
"if",
"self",
".",
"space_expanded",
"[",
"i",
"]",
".",
"type",
"==",
"'continuous'",
":",
... | Returns the dimension of the continuous components of the domain. | [
"Returns",
"the",
"dimension",
"of",
"the",
"continuous",
"components",
"of",
"the",
"domain",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/space.py#L364-L372 | train |
SheffieldML/GPyOpt | GPyOpt/core/task/space.py | Design_space.get_discrete_grid | def get_discrete_grid(self):
"""
Computes a Numpy array with the grid of points that results after crossing the possible outputs of the discrete
variables
"""
sets_grid = []
for d in self.space:
if d.type == 'discrete':
sets_grid.extend([d.doma... | python | def get_discrete_grid(self):
"""
Computes a Numpy array with the grid of points that results after crossing the possible outputs of the discrete
variables
"""
sets_grid = []
for d in self.space:
if d.type == 'discrete':
sets_grid.extend([d.doma... | [
"def",
"get_discrete_grid",
"(",
"self",
")",
":",
"sets_grid",
"=",
"[",
"]",
"for",
"d",
"in",
"self",
".",
"space",
":",
"if",
"d",
".",
"type",
"==",
"'discrete'",
":",
"sets_grid",
".",
"extend",
"(",
"[",
"d",
".",
"domain",
"]",
"*",
"d",
... | Computes a Numpy array with the grid of points that results after crossing the possible outputs of the discrete
variables | [
"Computes",
"a",
"Numpy",
"array",
"with",
"the",
"grid",
"of",
"points",
"that",
"results",
"after",
"crossing",
"the",
"possible",
"outputs",
"of",
"the",
"discrete",
"variables"
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/space.py#L387-L396 | train |
SheffieldML/GPyOpt | GPyOpt/core/task/space.py | Design_space.get_discrete_dims | def get_discrete_dims(self):
"""
Returns the dimension of the discrete components of the domain.
"""
discrete_dims = []
for i in range(self.dimensionality):
if self.space_expanded[i].type == 'discrete':
discrete_dims += [i]
return discrete_dims | python | def get_discrete_dims(self):
"""
Returns the dimension of the discrete components of the domain.
"""
discrete_dims = []
for i in range(self.dimensionality):
if self.space_expanded[i].type == 'discrete':
discrete_dims += [i]
return discrete_dims | [
"def",
"get_discrete_dims",
"(",
"self",
")",
":",
"discrete_dims",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"dimensionality",
")",
":",
"if",
"self",
".",
"space_expanded",
"[",
"i",
"]",
".",
"type",
"==",
"'discrete'",
":",
"discr... | Returns the dimension of the discrete components of the domain. | [
"Returns",
"the",
"dimension",
"of",
"the",
"discrete",
"components",
"of",
"the",
"domain",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/space.py#L399-L407 | train |
SheffieldML/GPyOpt | GPyOpt/core/task/space.py | Design_space.get_bandit | def get_bandit(self):
"""
Extracts the arms of the bandit if any.
"""
arms_bandit = []
for d in self.space:
if d.type == 'bandit':
arms_bandit += tuple(map(tuple, d.domain))
return np.asarray(arms_bandit) | python | def get_bandit(self):
"""
Extracts the arms of the bandit if any.
"""
arms_bandit = []
for d in self.space:
if d.type == 'bandit':
arms_bandit += tuple(map(tuple, d.domain))
return np.asarray(arms_bandit) | [
"def",
"get_bandit",
"(",
"self",
")",
":",
"arms_bandit",
"=",
"[",
"]",
"for",
"d",
"in",
"self",
".",
"space",
":",
"if",
"d",
".",
"type",
"==",
"'bandit'",
":",
"arms_bandit",
"+=",
"tuple",
"(",
"map",
"(",
"tuple",
",",
"d",
".",
"domain",
... | Extracts the arms of the bandit if any. | [
"Extracts",
"the",
"arms",
"of",
"the",
"bandit",
"if",
"any",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/space.py#L422-L430 | train |
SheffieldML/GPyOpt | GPyOpt/models/rfmodel.py | RFModel.predict | def predict(self, X):
"""
Predictions with the model. Returns posterior means and standard deviations at X.
"""
X = np.atleast_2d(X)
m = np.empty(shape=(0,1))
s = np.empty(shape=(0,1))
for k in range(X.shape[0]):
preds = []
for pred in sel... | python | def predict(self, X):
"""
Predictions with the model. Returns posterior means and standard deviations at X.
"""
X = np.atleast_2d(X)
m = np.empty(shape=(0,1))
s = np.empty(shape=(0,1))
for k in range(X.shape[0]):
preds = []
for pred in sel... | [
"def",
"predict",
"(",
"self",
",",
"X",
")",
":",
"X",
"=",
"np",
".",
"atleast_2d",
"(",
"X",
")",
"m",
"=",
"np",
".",
"empty",
"(",
"shape",
"=",
"(",
"0",
",",
"1",
")",
")",
"s",
"=",
"np",
".",
"empty",
"(",
"shape",
"=",
"(",
"0",... | Predictions with the model. Returns posterior means and standard deviations at X. | [
"Predictions",
"with",
"the",
"model",
".",
"Returns",
"posterior",
"means",
"and",
"standard",
"deviations",
"at",
"X",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/models/rfmodel.py#L79-L93 | train |
SheffieldML/GPyOpt | GPyOpt/acquisitions/MPI_mcmc.py | AcquisitionMPI_MCMC._compute_acq | def _compute_acq(self,x):
"""
Integrated Expected Improvement
"""
means, stds = self.model.predict(x)
fmins = self.model.get_fmin()
f_acqu = 0
for m,s,fmin in zip(means, stds, fmins):
_, Phi, _ = get_quantiles(self.jitter, fmin, m, s)
f_acq... | python | def _compute_acq(self,x):
"""
Integrated Expected Improvement
"""
means, stds = self.model.predict(x)
fmins = self.model.get_fmin()
f_acqu = 0
for m,s,fmin in zip(means, stds, fmins):
_, Phi, _ = get_quantiles(self.jitter, fmin, m, s)
f_acq... | [
"def",
"_compute_acq",
"(",
"self",
",",
"x",
")",
":",
"means",
",",
"stds",
"=",
"self",
".",
"model",
".",
"predict",
"(",
"x",
")",
"fmins",
"=",
"self",
".",
"model",
".",
"get_fmin",
"(",
")",
"f_acqu",
"=",
"0",
"for",
"m",
",",
"s",
","... | Integrated Expected Improvement | [
"Integrated",
"Expected",
"Improvement"
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/acquisitions/MPI_mcmc.py#L29-L39 | train |
SheffieldML/GPyOpt | GPyOpt/acquisitions/MPI_mcmc.py | AcquisitionMPI_MCMC._compute_acq_withGradients | def _compute_acq_withGradients(self, x):
"""
Integrated Expected Improvement and its derivative
"""
means, stds, dmdxs, dsdxs = self.model.predict_withGradients(x)
fmins = self.model.get_fmin()
f_acqu = None
df_acqu = None
for m, s, fmin, dmdx, dsdx in zip... | python | def _compute_acq_withGradients(self, x):
"""
Integrated Expected Improvement and its derivative
"""
means, stds, dmdxs, dsdxs = self.model.predict_withGradients(x)
fmins = self.model.get_fmin()
f_acqu = None
df_acqu = None
for m, s, fmin, dmdx, dsdx in zip... | [
"def",
"_compute_acq_withGradients",
"(",
"self",
",",
"x",
")",
":",
"means",
",",
"stds",
",",
"dmdxs",
",",
"dsdxs",
"=",
"self",
".",
"model",
".",
"predict_withGradients",
"(",
"x",
")",
"fmins",
"=",
"self",
".",
"model",
".",
"get_fmin",
"(",
")... | Integrated Expected Improvement and its derivative | [
"Integrated",
"Expected",
"Improvement",
"and",
"its",
"derivative"
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/acquisitions/MPI_mcmc.py#L41-L59 | train |
SheffieldML/GPyOpt | GPyOpt/plotting/plots_bo.py | plot_convergence | def plot_convergence(Xdata,best_Y, filename = None):
'''
Plots to evaluate the convergence of standard Bayesian optimization algorithms
'''
n = Xdata.shape[0]
aux = (Xdata[1:n,:]-Xdata[0:n-1,:])**2
distances = np.sqrt(aux.sum(axis=1))
## Distances between consecutive x's
plt.figure(figs... | python | def plot_convergence(Xdata,best_Y, filename = None):
'''
Plots to evaluate the convergence of standard Bayesian optimization algorithms
'''
n = Xdata.shape[0]
aux = (Xdata[1:n,:]-Xdata[0:n-1,:])**2
distances = np.sqrt(aux.sum(axis=1))
## Distances between consecutive x's
plt.figure(figs... | [
"def",
"plot_convergence",
"(",
"Xdata",
",",
"best_Y",
",",
"filename",
"=",
"None",
")",
":",
"n",
"=",
"Xdata",
".",
"shape",
"[",
"0",
"]",
"aux",
"=",
"(",
"Xdata",
"[",
"1",
":",
"n",
",",
":",
"]",
"-",
"Xdata",
"[",
"0",
":",
"n",
"-"... | Plots to evaluate the convergence of standard Bayesian optimization algorithms | [
"Plots",
"to",
"evaluate",
"the",
"convergence",
"of",
"standard",
"Bayesian",
"optimization",
"algorithms"
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/plotting/plots_bo.py#L122-L150 | train |
SheffieldML/GPyOpt | GPyOpt/core/evaluators/batch_local_penalization.py | LocalPenalization.compute_batch | def compute_batch(self, duplicate_manager=None, context_manager=None):
"""
Computes the elements of the batch sequentially by penalizing the acquisition.
"""
from ...acquisitions import AcquisitionLP
assert isinstance(self.acquisition, AcquisitionLP)
self.acquisition.upd... | python | def compute_batch(self, duplicate_manager=None, context_manager=None):
"""
Computes the elements of the batch sequentially by penalizing the acquisition.
"""
from ...acquisitions import AcquisitionLP
assert isinstance(self.acquisition, AcquisitionLP)
self.acquisition.upd... | [
"def",
"compute_batch",
"(",
"self",
",",
"duplicate_manager",
"=",
"None",
",",
"context_manager",
"=",
"None",
")",
":",
"from",
".",
".",
".",
"acquisitions",
"import",
"AcquisitionLP",
"assert",
"isinstance",
"(",
"self",
".",
"acquisition",
",",
"Acquisit... | Computes the elements of the batch sequentially by penalizing the acquisition. | [
"Computes",
"the",
"elements",
"of",
"the",
"batch",
"sequentially",
"by",
"penalizing",
"the",
"acquisition",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/evaluators/batch_local_penalization.py#L22-L49 | train |
SheffieldML/GPyOpt | manual/notebooks_check.py | check_notebooks_for_errors | def check_notebooks_for_errors(notebooks_directory):
''' Evaluates all notebooks in given directory and prints errors, if any '''
print("Checking notebooks in directory {} for errors".format(notebooks_directory))
failed_notebooks_count = 0
for file in os.listdir(notebooks_directory):
if file.en... | python | def check_notebooks_for_errors(notebooks_directory):
''' Evaluates all notebooks in given directory and prints errors, if any '''
print("Checking notebooks in directory {} for errors".format(notebooks_directory))
failed_notebooks_count = 0
for file in os.listdir(notebooks_directory):
if file.en... | [
"def",
"check_notebooks_for_errors",
"(",
"notebooks_directory",
")",
":",
"print",
"(",
"\"Checking notebooks in directory {} for errors\"",
".",
"format",
"(",
"notebooks_directory",
")",
")",
"failed_notebooks_count",
"=",
"0",
"for",
"file",
"in",
"os",
".",
"listdi... | Evaluates all notebooks in given directory and prints errors, if any | [
"Evaluates",
"all",
"notebooks",
"in",
"given",
"directory",
"and",
"prints",
"errors",
"if",
"any"
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/manual/notebooks_check.py#L8-L24 | train |
SheffieldML/GPyOpt | GPyOpt/models/gpmodel.py | GPModel.predict | def predict(self, X, with_noise=True):
"""
Predictions with the model. Returns posterior means and standard deviations at X. Note that this is different in GPy where the variances are given.
Parameters:
X (np.ndarray) - points to run the prediction for.
with_noise (bool)... | python | def predict(self, X, with_noise=True):
"""
Predictions with the model. Returns posterior means and standard deviations at X. Note that this is different in GPy where the variances are given.
Parameters:
X (np.ndarray) - points to run the prediction for.
with_noise (bool)... | [
"def",
"predict",
"(",
"self",
",",
"X",
",",
"with_noise",
"=",
"True",
")",
":",
"m",
",",
"v",
"=",
"self",
".",
"_predict",
"(",
"X",
",",
"False",
",",
"with_noise",
")",
"# We can take the square root because v is just a diagonal matrix of variances",
"ret... | Predictions with the model. Returns posterior means and standard deviations at X. Note that this is different in GPy where the variances are given.
Parameters:
X (np.ndarray) - points to run the prediction for.
with_noise (bool) - whether to add noise to the prediction. Default is True. | [
"Predictions",
"with",
"the",
"model",
".",
"Returns",
"posterior",
"means",
"and",
"standard",
"deviations",
"at",
"X",
".",
"Note",
"that",
"this",
"is",
"different",
"in",
"GPy",
"where",
"the",
"variances",
"are",
"given",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/models/gpmodel.py#L100-L110 | train |
SheffieldML/GPyOpt | GPyOpt/models/gpmodel.py | GPModel.predict_covariance | def predict_covariance(self, X, with_noise=True):
"""
Predicts the covariance matric for points in X.
Parameters:
X (np.ndarray) - points to run the prediction for.
with_noise (bool) - whether to add noise to the prediction. Default is True.
"""
_, v = se... | python | def predict_covariance(self, X, with_noise=True):
"""
Predicts the covariance matric for points in X.
Parameters:
X (np.ndarray) - points to run the prediction for.
with_noise (bool) - whether to add noise to the prediction. Default is True.
"""
_, v = se... | [
"def",
"predict_covariance",
"(",
"self",
",",
"X",
",",
"with_noise",
"=",
"True",
")",
":",
"_",
",",
"v",
"=",
"self",
".",
"_predict",
"(",
"X",
",",
"True",
",",
"with_noise",
")",
"return",
"v"
] | Predicts the covariance matric for points in X.
Parameters:
X (np.ndarray) - points to run the prediction for.
with_noise (bool) - whether to add noise to the prediction. Default is True. | [
"Predicts",
"the",
"covariance",
"matric",
"for",
"points",
"in",
"X",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/models/gpmodel.py#L112-L121 | train |
SheffieldML/GPyOpt | GPyOpt/models/gpmodel.py | GPModel.predict_withGradients | def predict_withGradients(self, X):
"""
Returns the mean, standard deviation, mean gradient and standard deviation gradient at X.
"""
if X.ndim==1: X = X[None,:]
m, v = self.model.predict(X)
v = np.clip(v, 1e-10, np.inf)
dmdx, dvdx = self.model.predictive_gradient... | python | def predict_withGradients(self, X):
"""
Returns the mean, standard deviation, mean gradient and standard deviation gradient at X.
"""
if X.ndim==1: X = X[None,:]
m, v = self.model.predict(X)
v = np.clip(v, 1e-10, np.inf)
dmdx, dvdx = self.model.predictive_gradient... | [
"def",
"predict_withGradients",
"(",
"self",
",",
"X",
")",
":",
"if",
"X",
".",
"ndim",
"==",
"1",
":",
"X",
"=",
"X",
"[",
"None",
",",
":",
"]",
"m",
",",
"v",
"=",
"self",
".",
"model",
".",
"predict",
"(",
"X",
")",
"v",
"=",
"np",
"."... | Returns the mean, standard deviation, mean gradient and standard deviation gradient at X. | [
"Returns",
"the",
"mean",
"standard",
"deviation",
"mean",
"gradient",
"and",
"standard",
"deviation",
"gradient",
"at",
"X",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/models/gpmodel.py#L129-L140 | train |
SheffieldML/GPyOpt | GPyOpt/models/gpmodel.py | GPModel_MCMC.predict | def predict(self, X):
"""
Predictions with the model for all the MCMC samples. Returns posterior means and standard deviations at X. Note that this is different in GPy where the variances are given.
"""
if X.ndim==1: X = X[None,:]
ps = self.model.param_array.copy()
means... | python | def predict(self, X):
"""
Predictions with the model for all the MCMC samples. Returns posterior means and standard deviations at X. Note that this is different in GPy where the variances are given.
"""
if X.ndim==1: X = X[None,:]
ps = self.model.param_array.copy()
means... | [
"def",
"predict",
"(",
"self",
",",
"X",
")",
":",
"if",
"X",
".",
"ndim",
"==",
"1",
":",
"X",
"=",
"X",
"[",
"None",
",",
":",
"]",
"ps",
"=",
"self",
".",
"model",
".",
"param_array",
".",
"copy",
"(",
")",
"means",
"=",
"[",
"]",
"stds"... | Predictions with the model for all the MCMC samples. Returns posterior means and standard deviations at X. Note that this is different in GPy where the variances are given. | [
"Predictions",
"with",
"the",
"model",
"for",
"all",
"the",
"MCMC",
"samples",
".",
"Returns",
"posterior",
"means",
"and",
"standard",
"deviations",
"at",
"X",
".",
"Note",
"that",
"this",
"is",
"different",
"in",
"GPy",
"where",
"the",
"variances",
"are",
... | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/models/gpmodel.py#L255-L275 | train |
SheffieldML/GPyOpt | GPyOpt/models/gpmodel.py | GPModel_MCMC.get_fmin | def get_fmin(self):
"""
Returns the location where the posterior mean is takes its minimal value.
"""
ps = self.model.param_array.copy()
fmins = []
for s in self.hmc_samples:
if self.model._fixes_ is None:
self.model[:] = s
else:
... | python | def get_fmin(self):
"""
Returns the location where the posterior mean is takes its minimal value.
"""
ps = self.model.param_array.copy()
fmins = []
for s in self.hmc_samples:
if self.model._fixes_ is None:
self.model[:] = s
else:
... | [
"def",
"get_fmin",
"(",
"self",
")",
":",
"ps",
"=",
"self",
".",
"model",
".",
"param_array",
".",
"copy",
"(",
")",
"fmins",
"=",
"[",
"]",
"for",
"s",
"in",
"self",
".",
"hmc_samples",
":",
"if",
"self",
".",
"model",
".",
"_fixes_",
"is",
"No... | Returns the location where the posterior mean is takes its minimal value. | [
"Returns",
"the",
"location",
"where",
"the",
"posterior",
"mean",
"is",
"takes",
"its",
"minimal",
"value",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/models/gpmodel.py#L277-L293 | train |
SheffieldML/GPyOpt | GPyOpt/models/gpmodel.py | GPModel_MCMC.predict_withGradients | def predict_withGradients(self, X):
"""
Returns the mean, standard deviation, mean gradient and standard deviation gradient at X for all the MCMC samples.
"""
if X.ndim==1: X = X[None,:]
ps = self.model.param_array.copy()
means = []
stds = []
dmdxs = []
... | python | def predict_withGradients(self, X):
"""
Returns the mean, standard deviation, mean gradient and standard deviation gradient at X for all the MCMC samples.
"""
if X.ndim==1: X = X[None,:]
ps = self.model.param_array.copy()
means = []
stds = []
dmdxs = []
... | [
"def",
"predict_withGradients",
"(",
"self",
",",
"X",
")",
":",
"if",
"X",
".",
"ndim",
"==",
"1",
":",
"X",
"=",
"X",
"[",
"None",
",",
":",
"]",
"ps",
"=",
"self",
".",
"model",
".",
"param_array",
".",
"copy",
"(",
")",
"means",
"=",
"[",
... | Returns the mean, standard deviation, mean gradient and standard deviation gradient at X for all the MCMC samples. | [
"Returns",
"the",
"mean",
"standard",
"deviation",
"mean",
"gradient",
"and",
"standard",
"deviation",
"gradient",
"at",
"X",
"for",
"all",
"the",
"MCMC",
"samples",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/models/gpmodel.py#L295-L322 | train |
SheffieldML/GPyOpt | GPyOpt/interface/func_loader.py | load_objective | def load_objective(config):
"""
Loads the objective function from a .json file.
"""
assert 'prjpath' in config
assert 'main-file' in config, "The problem file ('main-file') is missing!"
os.chdir(config['prjpath'])
if config['language'].lower()=='python':
assert config['main-fil... | python | def load_objective(config):
"""
Loads the objective function from a .json file.
"""
assert 'prjpath' in config
assert 'main-file' in config, "The problem file ('main-file') is missing!"
os.chdir(config['prjpath'])
if config['language'].lower()=='python':
assert config['main-fil... | [
"def",
"load_objective",
"(",
"config",
")",
":",
"assert",
"'prjpath'",
"in",
"config",
"assert",
"'main-file'",
"in",
"config",
",",
"\"The problem file ('main-file') is missing!\"",
"os",
".",
"chdir",
"(",
"config",
"[",
"'prjpath'",
"]",
")",
"if",
"config",
... | Loads the objective function from a .json file. | [
"Loads",
"the",
"objective",
"function",
"from",
"a",
".",
"json",
"file",
"."
] | 255539dc5927819ca701e44fe3d76cd4864222fa | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/interface/func_loader.py#L7-L21 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.