Esempio n. 1
0
    def are_models_valid(self, modelparams):
        return self.underlying_model.are_models_valid(modelparams)

    def domain(self, expparams):
        return self.underlying_model.domain(expparams)
    
    def are_expparam_dtypes_consistent(self, expparams):
        return self.underlying_model.are_expparam_dtypes_consistent(expparams)
    
    def update_timestep(self, modelparams, expparams):
        return self.underlying_model.update_timestep(modelparams, expparams)

    def canonicalize(self, modelparams):
        return self.underlying_model.canonicalize(modelparams)

PoisonModes = enum.enum("ALE", "MLE")

class PoisonedModel(DerivedModel):
    r"""
    Model that simulates sampling error incurred by the MLE or ALE methods of
    reconstructing likelihoods from sample data. The true likelihood given by an
    underlying model is perturbed by a normally distributed random variable
    :math:`\epsilon`, and then truncated to the interval :math:`[0, 1]`.
    
    The variance of :math:`\epsilon` can be specified either as a constant,
    to simulate ALE (in which samples are collected until a given threshold is
    met), or as proportional to the variance of a possibly-hedged binomial
    estimator, to simulate MLE.
    
    :param Model underlying_model: The "true" model to be poisoned.
    :param float tol: For ALE, specifies the given error tolerance to simulate.
Esempio n. 2
0
        self.underlying_model.clear_cache()

    def n_outcomes(self, expparams):
        return self.underlying_model.n_outcomes(expparams)

    def are_models_valid(self, modelparams):
        return self.underlying_model.are_models_valid(modelparams)

    def update_timestep(self, modelparams, expparams):
        return self.underlying_model.update_timestep(modelparams, expparams)

    def canonicalize(self, modelparams):
        return self.underlying_model.canonicalize(modelparams)


PoisonModes = enum.enum("ALE", "MLE")


class PoisonedModel(DerivedModel):
    # TODO: refactor to use DerivedModel
    r"""
    Model that simulates sampling error incurred by the MLE or ALE methods of
    reconstructing likelihoods from sample data. The true likelihood given by an
    underlying model is perturbed by a normally distributed random variable
    :math:`\epsilon`, and then truncated to the interval :math:`[0, 1]`.
    
    The variance of :math:`\epsilon` can be specified either as a constant,
    to simulate ALE (in which samples are collected until a given threshold is
    met), or as proportional to the variance of a possibly-hedged binomial
    estimator, to simulate MLE.
    
Esempio n. 3
0
    for port in count(10000):
        try:
            listener = multiprocessing.connection.Listener(
                ('localhost', int(port)), authkey='notreallysecret')
            return listener, port
        except socket.error as ex:
            if ex.errno != 98:  # Err 98 is port not available.
                raise ex


## ENUMS ######################################################################

Properties = enum.enum(
    "TITLE",
    "STATUS",
    "MAXPROG",
    "PROGRESS",
    # TODO: max/min progress
)

Actions = enum.enum("GET", "SET", "COMPLETE", "CLOSE")

## CLASSES ####################################################################


class ProgressDialog(object):
    # TODO: docstring

    def __init__(self,
                 task_title="Progress",
                 task_status="Waiting...",
Esempio n. 4
0
    for port in count(10000):
        try:
            listener = multiprocessing.connection.Listener(
                ('localhost', int(port)),
                authkey='notreallysecret'
            )
            return listener, port
        except socket.error as ex:
            if ex.errno != 98: # Err 98 is port not available.
                raise ex
    
   
## ENUMS ######################################################################

Properties = enum.enum(
    "TITLE", "STATUS", "MAXPROG", "PROGRESS",
    # TODO: max/min progress
)
    
Actions = enum.enum(
    "GET", "SET", "COMPLETE", "CLOSE"
)

## CLASSES ####################################################################

class ProgressDialog(object):
    # TODO: docstring
    
    def __init__(self,
            task_title="Progress",
            task_status="Waiting...",
            maxprog=100,
Esempio n. 5
0
# for BCRB and BED classes
import scipy.optimize as opt
from qinfer._lib import enum # <- TODO: replace with flufl.enum!

from abc import ABCMeta, abstractmethod
import warnings

from qinfer.finite_difference import *

## FUNCTIONS ###################################################################

def identity(arg): return arg

## CLASSES #####################################################################

OptimizationAlgorithms = enum.enum("NULL", "CG", "NCG", "NELDER_MEAD")

class Heuristic(object):
    r"""
    Defines a heuristic used for selecting new experiments without explicit
    optimization of the risk. As an example, the :math:`t_k = (9/8)^k`
    heuristic discussed by [FGC12]_ does not make explicit reference to the
    risk, and so would be appropriate as a `Heuristic` subclass.
    In particular, the [FGC12]_ heuristic is implemented by the
    :class:`ExpSparseHeuristic` class.

    Note that the design of this abstract base class is still being decided,
    such that it is a placeholder for now.
    """
    __metaclass__ = ABCMeta
    
Esempio n. 6
0
from abc import ABCMeta, abstractmethod
import warnings

from qinfer.finite_difference import *

## FUNCTIONS ###################################################################


def identity(arg):
    return arg


## CLASSES #####################################################################

OptimizationAlgorithms = enum.enum("NULL", "CG", "NCG", "NELDER_MEAD")


class Heuristic(with_metaclass(ABCMeta, object)):
    r"""
    Defines a heuristic used for selecting new experiments without explicit
    optimization of the risk. As an example, the :math:`t_k = (9/8)^k`
    heuristic discussed by [FGC12]_ does not make explicit reference to the
    risk, and so would be appropriate as a `Heuristic` subclass.
    In particular, the [FGC12]_ heuristic is implemented by the
    :class:`ExpSparseHeuristic` class.
    """
    def __init__(self, updater):
        self._updater = updater

    @abstractmethod