Skip to content

Commit

Permalink
Release 0.10.0
Browse files Browse the repository at this point in the history
Release 0.10.0
  • Loading branch information
mlindauer authored Jan 11, 2019
2 parents 7f15a59 + 69cafa8 commit b5c3986
Show file tree
Hide file tree
Showing 16 changed files with 470 additions and 90 deletions.
14 changes: 14 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# 0.10.0

## Major changes

* ADD further acquisition functions: PI and LCB
* SMAC can now be installed without installing all its dependencies
* Simplify setup.py by moving most thing to setup.cfg

## Bug fixes

* RM typing as requirement
* FIX import of authors in setup.py
* MAINT use json-file as standard pcs format for internal logging

# 0.9

## Major changes
Expand Down
6 changes: 3 additions & 3 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@

# General information about the project.
project = u'SMAC'
copyright = '2015-%s, %s' % (datetime.datetime.now().year, smac.AUTHORS)
author = smac.AUTHORS
copyright = '2015-%s, %s' % (datetime.datetime.now().year, smac.__author__)
author = smac.__author__

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -243,7 +243,7 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'SMAC3.tex', u'SMAC3 Documentation', smac.AUTHORS, 'manual'),
(master_doc, 'SMAC3.tex', u'SMAC3 Documentation', smac.__author__, 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ psutil
pynisher>=0.4.1
ConfigSpace>=0.4.6,<0.5
scikit-learn>=0.18.0
typing
pyrfr>=0.5.0
sphinx
sphinx_rtd_theme
Expand Down
24 changes: 23 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,24 @@
[metadata]
description-file = README.md
name = smac
author_email = "[email protected]"
description = SMAC3, a Python implementation of 'Sequential Model-based Algorithm Configuration'.
long_description = file: README.md, CHANGELOG.md, LICENSE
license = 3-clause BSD
keywords = machine learning, algorithm configuration, hyperparameter optimization, tuning
classifiers=
Development Status :: 3 - Alpha
Topic :: Utilities
Topic :: Scientific/Engineering
Topic :: Scientific/Engineering :: Artificial Intelligence
License :: OSI Approved :: BSD License
platforms = Linux

[options]
packages = find:

[options.packages.find]
exclude = test

[options.entry_points]
console_scripts =
smac = smac.smac_cli:cmd_line_call
65 changes: 28 additions & 37 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,46 +1,37 @@
import setuptools
import sys

import smac
#!/usr/bin/env python3
import os
from setuptools import setup


with open('requirements.txt') as fh:
requirements = fh.read()
requirements = requirements.split('\n')
requirements = [requirement.strip() for requirement in requirements]

with open("smac/__version__.py") as fh:
version = fh.readlines()[-1].split()[-1].strip("\"'")

if sys.version_info < (3, 5, 2):
raise ValueError('Unsupported Python version %s found. SMAC3 requires Python 3.5.2 or higher.' % sys.version_info)

setuptools.setup(
name="smac",
version=version,
author=smac.AUTHORS,
author_email="[email protected]",
description=("SMAC3, a Python implementation of 'Sequential Model-based "
"Algorithm Configuration'."),
license="3-clause BSD",
keywords="machine learning algorithm configuration hyperparameter "
"optimization tuning",
url="",
entry_points={
'console_scripts': ['smac=smac.smac_cli:cmd_line_call'],
},
packages=setuptools.find_packages(exclude=['test', 'source']),
classifiers=[
"Development Status :: 3 - Alpha",
"Topic :: Utilities",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"License :: OSI Approved :: BSD License",
],
platforms=['Linux'],

def get_version():
version_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "smac", "__init__.py")
for line in open(version_file):
if line.startswith("__version__"):
version = line.split("=")[1].strip().replace("'", "").replace('"', '')
return version
raise RuntimeError("Unable to find version string in %s" % version_file)


def get_author():
version_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "smac", "__init__.py")
for line in open(version_file):
if line.startswith("__author__"):
version = line.split("=")[1].strip().replace("'", "").replace('"', '')
return version
raise RuntimeError("Unable to find author string in %s" % version_file)


setup(
python_requires=">=3.5.2",
install_requires=requirements,
python_requires='>=3.5.2',
tests_require=['mock',
'nose'],
test_suite='nose.collector'
author=get_author(),
version=get_version(),
test_suite="nose.collector",
tests_require=["mock", "nose"]
)
28 changes: 11 additions & 17 deletions smac/__init__.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,27 @@
import os
import sys

if sys.version_info < (3, 5, 2):
raise ValueError("SMAC requires Python 3.5.2 or newer.")

from smac.__version__ import __version__
from smac.utils import dependencies

AUTHORS = "Marius Lindauer, Matthias Feurer, Katharina Eggensperger, " \
"Aaron Klein, Stefan Falkner and Frank Hutter"
__version__ = '0.10.0'
__author__ = 'Marius Lindauer, Matthias Feurer, Katharina Eggensperger, Joshua Marben, André Biedenkapp, Aaron Klein, Stefan Falkner and Frank Hutter'

__MANDATORY_PACKAGES__ = '''
__MANDATORY_PACKAGES__ = """
numpy>=1.7.1
scipy>=0.18.1
six
psutil
pynisher>=0.4.1
ConfigSpace>=0.4.6,<0.5
scikit-learn>=0.18.0
pyrfr>=0.5.0
ConfigSpace>=0.4.6,<0.5
emcee>=2.1.0
george
cython
psutil
pyDOE
statsmodels
joblib
sobol_seq
'''
"""
dependencies.verify_packages(__MANDATORY_PACKAGES__)

if sys.version_info < (3, 5, 2):
raise ValueError("SMAC requires Python 3.5.2 or newer.")

dependencies.verify_packages(__MANDATORY_PACKAGES__)

if os.name != 'posix':
print(
Expand Down
4 changes: 0 additions & 4 deletions smac/__version__.py

This file was deleted.

6 changes: 4 additions & 2 deletions smac/configspace/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from functools import partial

from ConfigSpace import ConfigurationSpace, Configuration, CategoricalHyperparameter
from ConfigSpace import ConfigurationSpace, Configuration, Constant,\
CategoricalHyperparameter, UniformFloatHyperparameter, \
UniformIntegerHyperparameter, InCondition
from ConfigSpace.read_and_write import pcs, pcs_new, json
from ConfigSpace.util import get_one_exchange_neighbourhood
from smac.configspace.util import convert_configurations_to_array

get_one_exchange_neighbourhood = partial(get_one_exchange_neighbourhood, stdev=0.05, num_neighbors=8)
get_one_exchange_neighbourhood = partial(get_one_exchange_neighbourhood, stdev=0.05, num_neighbors=8)
103 changes: 103 additions & 0 deletions smac/optimizer/acquisition.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,3 +340,106 @@ def calculate_log_ei():
"Expected Improvement is smaller than 0 for at least one sample.")

return log_ei.reshape((-1, 1))


class PI(AbstractAcquisitionFunction):
def __init__(self,
model: AbstractEPM,
par: float=0.0):

"""Computes the probability of improvement for a given x over the best so far value as
acquisition value.
:math:`P(f_{t+1}(\mathbf{X})\geq f(\mathbf{X^+})) :=
\Phi(\frac{\mu(\mathbf{X}) - f(\mathbf{X^+})}{\sigma(\mathbf{X})})`,
with :math:`f(X^+)` as the incumbent and :math:`\Phi` the cdf of the standard normal
Parameters
----------
model : AbstractEPM
A model that implements at least
- predict_marginalized_over_instances(X)
par : float, default=0.0
Controls the balance between exploration and exploitation of the
acquisition function.
"""
super(PI, self).__init__(model)
self.long_name = 'Probability of Improvement'
self.par = par
self.eta = None

def _compute(self, X: np.ndarray):
"""Computes the PI value.
Parameters
----------
X: np.ndarray(N, D)
Points to evaluate PI. N is the number of points and D the dimension for the points
Returns
-------
np.ndarray(N,1)
Expected Improvement of X
"""
if self.eta is None:
raise ValueError('No current best specified. Call update('
'eta=<float>) to inform the acquisition function '
'about the current best value.')

if len(X.shape) == 1:
X = X[:, np.newaxis]
m, var_ = self.model.predict_marginalized_over_instances(X)
std = np.sqrt(var_)
return norm.cdf((self.eta - m - self.par) / std)


class LCB(AbstractAcquisitionFunction):
def __init__(self,
model: AbstractEPM,
par: float=1.0):

"""Computes the lower confidence bound for a given x over the best so far value as
acquisition value.
:math:`LCB(X) = \mu(\mathbf{X}) - \sqrt(\beta_t)\sigma(\mathbf{X})`
Returns -LCB(X) as the acquisition_function optimizer maximizes the acquisition value.
Parameters
----------
model : AbstractEPM
A model that implements at least
- predict_marginalized_over_instances(X)
par : float, default=0.0
Controls the balance between exploration and exploitation of the
acquisition function.
"""
super(LCB, self).__init__(model)
self.long_name = 'Lower Confidence Bound'
self.par = par
self.eta = None # to be compatible with the existing update calls in SMBO
self.num_data = None

def _compute(self, X: np.ndarray):
"""Computes the LCB value.
Parameters
----------
X: np.ndarray(N, D)
Points to evaluate LCB. N is the number of points and D the dimension for the points
Returns
-------
np.ndarray(N,1)
Expected Improvement of X
"""
if self.num_data is None:
raise ValueError('No current number of Datapoints specified. Call update('
'num_data=<int>) to inform the acquisition function '
'about the number of datapoints.')
if len(X.shape) == 1:
X = X[:, np.newaxis]
m, var_ = self.model.predict_marginalized_over_instances(X)
std = np.sqrt(var_)
beta = 2*np.log((X.shape[1] * self.num_data**2) / self.par)
return -(m - np.sqrt(beta)*std)
Loading

0 comments on commit b5c3986

Please sign in to comment.