Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, parameters, name='Normal'):
# We expect input of type parameters = [mean, stddev]
if not isinstance(parameters, list):
raise TypeError('Input of normal model is of type list')
if len(parameters) != 2:
raise RuntimeError('Input list must be of length 2, containing [mean, stddev]')
input_connector = InputConnector.from_list(parameters)
super().__init__(input_connector, name)
def __init__(self, parameters, name='Gaussian'):
# We expect input of type parameters = [mu, sigma]
if not isinstance(parameters, list):
raise TypeError('Input of Normal model is of type list')
if len(parameters) != 2:
raise RuntimeError('Input list must be of length 2, containing [mu1, mu1].')
input_connector = InputConnector.from_list(parameters)
super().__init__(input_connector, name)
def __init__(self, parameters, name='Normal'):
# We expect input of type parameters = [mean, stddev]
if not isinstance(parameters, list):
raise TypeError('Input of normal model is of type list')
if len(parameters) != 2:
raise RuntimeError('Input list must be of length 2, containing [mean, stddev]')
input_connector = InputConnector.from_list(parameters)
super().__init__(input_connector, name)
----------
parameters: list
Contains the probabilistic models and hyperparameters from which the model derives.
The list has two entries: from the first entry mean of the distribution and from the second entry variance is derived.
Note that the second value of the list is strictly greater than 0.
name: string
The name that should be given to the probabilistic model in the journal file.
"""
if not isinstance(parameters, list):
raise TypeError('Input for Normal has to be of type list.')
if len(parameters)<2:
raise ValueError('Input for Normal has to be of length 2.')
input_parameters = InputConnector.from_list(parameters)
super(Normal, self).__init__(input_parameters, name)
self.visited = False
----------
parameters: list
A list of ProbabilisticModels
Returns
-------
InputConnector
"""
if isinstance(parameters, list):
unnested_parameters = []
parameters_count = 0
for item in parameters:
input_parameters_from_item = item
if isinstance(item, list):
input_parameters_from_item = InputConnector.from_list(item)
elif isinstance(item, (Hyperparameter, ProbabilisticModel)):
input_parameters_from_item = InputConnector.from_model(item)
elif isinstance(item, Number):
input_parameters_from_item = InputConnector.from_number(item)
elif not isinstance(item, InputConnector):
raise TypeError('Unsupported type.')
unnested_parameters.append(input_parameters_from_item)
parameters_count += input_parameters_from_item.get_parameter_count()
# here, unnested_parameters is a list of InputConnector and parameters_count hold the total number of
# parameters in this list
input_parameters = InputConnector(parameters_count)
index = 0
for param in unnested_parameters:
for pi in range(0, param.get_parameter_count()):
Parameters
----------
parameters: list
A list containing one entry, the probability of the distribution.
name: string
The name that should be given to the probabilistic model in the journal file.
"""
if not isinstance(parameters, list):
raise TypeError('Input for Bernoulli has to be of type list.')
if len(parameters)!=1:
raise ValueError('Input for Bernoulli has to be of length 1.')
self._dimension = len(parameters)
input_parameters = InputConnector.from_list(parameters)
super(Bernoulli, self).__init__(input_parameters, name)
self.visited = False
Parameters
----------
parameters: list
A list containing one entry, the mean of the distribution.
name: string
The name that should be given to the probabilistic model in the journal file.
"""
if not isinstance(parameters, list):
raise TypeError('Input for Poisson has to be of type list.')
if len(parameters)!=1:
raise ValueError('Input for Poisson has to be of length 1.')
self._dimension = 1
input_parameters = InputConnector.from_list(parameters)
super(Poisson, self).__init__(input_parameters, name)
self.visited = False
def __init__(self, parameters, name='Gaussian'):
# We expect input of type parameters = [mu, sigma]
if not isinstance(parameters, list):
raise TypeError('Input of Normal model is of type list')
if len(parameters) != 2:
raise RuntimeError('Input list must be of length 2, containing [mu1, mu1].')
input_connector = InputConnector.from_list(parameters)
super().__init__(input_connector, name)