neuraxle.hyperparams.distributions¶
Module-level documentation for neuraxle.hyperparams.distributions. Here is an inheritance diagram, including dependencies to other base modules of Neuraxle:
Hyperparameter Distributions¶
Here you’ll find a few hyperparameter distributions. It’s also possible to create yours by inheriting
from the base class. Each distribution must override the method rvs
, which will return a sampled value from
the distribution.
Functions
|
Classes
|
Get a random boolean hyperparameter. |
|
Get a random value from a choice list of possible value for this hyperparameter. |
Continuous distributions. |
|
Discrete distributions. |
|
|
Get a mixture of multiple distribution |
|
This is an hyperparameter that won’t change again, but that is still expressed as a distribution. |
|
Base class for other hyperparameter distributions. |
|
|
|
Get a LogNormal distribution. |
Use this mixin when your distribution samples from a log-space distribution to identify it. |
|
|
Get a LogUniform distribution. |
|
Get a normal distribution. |
Inherit from this class to represent a |
|
|
Get a random value from a choice list of possible value for this hyperparameter. |
|
A quantized wrapper for another distribution: will round() the returned |
|
Get a random integer within a range |
|
Get a uniform distribution. |
Examples using neuraxle.hyperparams.distributions.Boolean
¶
Examples using neuraxle.hyperparams.distributions.Choice
¶
Examples using neuraxle.hyperparams.distributions.LogUniform
¶
Examples using neuraxle.hyperparams.distributions.RandInt
¶
-
class
neuraxle.hyperparams.distributions.
HyperparameterDistribution
(null_default_value: Any = None)[source]¶ Bases:
object
Base class for other hyperparameter distributions.
This is the abstract class of the abstract classes. Please inherit from these mid-level abstract classes:
OrdinalHyperparameterDistribution
-
__init__
(null_default_value: Any = None)[source]¶ Create a HyperparameterDistribution. This method should still be called with super if it gets overriden.
-
pdf
(x: Any) → float[source]¶ Abstract method for probability distribution function value at x.
- Return type
float
- Parameters
x – value where the probability distribution function is evaluated.
- Returns
The probability distribution function value.
-
cdf
(x: Any) → float[source]¶ Abstract method for cumulative distribution function value at x. Therefore, p = cdf(x).
- Return type
float
- Parameters
x – value where the cumulative distribution function is evaluated.
- Returns
The cumulative distribution function value.
-
icdf
(p: float) → Any[source]¶ This is the inverse of the cumulative distribution function, where x = icdf(p).
- Parameters
x – value where the cumulative distribution function is evaluated.
- Returns
The cumulative distribution function value.
-
min
() → float[source]¶ Abstract method for obtaining minimum value that can sampled in distribution.
- Returns
minimal value that can be sampled from distribution.
-
max
() → float[source]¶ Abstract method for obtaining maximal value that can sampled in distribution.
- Returns
maximal value that can be sampled from distribution.
-
mean
() → float[source]¶ Abstract method for calculating distribution mean value.
- Returns
distribution mean value.
-
std
() → float[source]¶ Base method to calculate distribution std value by taking sqrt of variance value.
- Returns
distribution std value.
-
var
() → float[source]¶ Abstract method for calculate distribution variance value.
: return: distribution variance value.
-
_abc_impl
= <_abc_data object>¶
-
class
neuraxle.hyperparams.distributions.
ContinuousHyperparameterDistribution
(null_default_value=None)[source]¶ Bases:
neuraxle.hyperparams.distributions.HyperparameterDistribution
Continuous distributions.
See also
DiscreteHyperparameterDistribution
OrdinalHyperparameterDistribution
-
__init__
(null_default_value=None)[source]¶ Create a HyperparameterDistribution. This method should still be called with super if it gets overriden.
-
icdf
(p: float) → Any[source]¶ This is the inverse of the cumulative distribution function, where x = icdf(p).
-
_pseudo_min
() → float[source]¶ This is like the function min, but in case it is infinite, there will be a clipping to at least 4 sigmas.
-
_pseudo_max
() → float[source]¶ This is like the function max, but in case it is infinite, there will be a clipping to at most 4 sigmas.
-
_abc_impl
= <_abc_data object>¶
-
-
class
neuraxle.hyperparams.distributions.
DiscreteHyperparameterDistribution
(null_default_value=None)[source]¶ Bases:
neuraxle.hyperparams.distributions.HyperparameterDistribution
Discrete distributions.
Ineritors will have to implement the following method at least:
DiscreteHyperparameterDistribution.values()
.See also
ContinuousHyperparameterDistribution
OrdinalHyperparameterDistribution
-
__init__
(null_default_value=None)[source]¶ Create a HyperparameterDistribution. This method should still be called with super if it gets overriden.
-
icdf
(p: float) → Any[source]¶ This is the inverse of the cumulative distribution function, where x = icdf(p).
-
_abc_impl
= <_abc_data object>¶
-
-
class
neuraxle.hyperparams.distributions.
OrdinalDiscreteHyperparameterDistribution
(null_default_value=None)[source]¶ Bases:
neuraxle.hyperparams.distributions.DiscreteHyperparameterDistribution
Inherit from this class to represent a
DiscreteHyperparameterDistribution
that contains values inDiscreteHyperparameterDistribution.values()
that are in order such that they would sort the same way, either ascending or descending.The usage of this class indicates the AutoML wheter it should consider the different values like a categorical or a numerical variable.
-
__init__
(null_default_value=None)[source]¶ Create a HyperparameterDistribution. This method should still be called with super if it gets overriden.
-
_abc_impl
= <_abc_data object>¶
-
-
class
neuraxle.hyperparams.distributions.
LogSpaceDistributionMixin
[source]¶ Bases:
object
Use this mixin when your distribution samples from a log-space distribution to identify it.
-
class
neuraxle.hyperparams.distributions.
FixedHyperparameter
(value, null_default_value=None)[source]¶ Bases:
neuraxle.hyperparams.distributions.DiscreteHyperparameterDistribution
This is an hyperparameter that won’t change again, but that is still expressed as a distribution.
-
__init__
(value, null_default_value=None)[source]¶ Create a still hyperparameter
- Parameters
value – what will be returned by calling
.rvs()
.
-
pdf
(x) → float[source]¶ Probability distribution function value at x. Since the parameter is fixed, the value return is 1 when x == value and 0 otherwise.
- Return type
float
- Parameters
x – value where the probability distribution function is evaluated.
- Returns
The probability distribution function value.
-
cdf
(x) → float[source]¶ Cumulative distribution function value at x. Since the parameter is fixed, the value return is 1 if x>= value and 0 otherwise.
- Return type
float
- Parameters
x – value where the cumulative distribution function is evaluated.
- Returns
The cumulative distribution function value.
-
min
()[source]¶ Calculate minimum value that can be sampled in a fixed distribution.
- Returns
minimal value return from distribution.
-
max
()[source]¶ Calculate maximum value that can be sampled in a fixed distribution.
- Returns
maximum value return from distribution.
-
mean
()[source]¶ Calculate mean value (also called esperance) of the random variable.
- Returns
mean value of the random variable.
-
var
()[source]¶ Calculate variance value of the random variable.
- Returns
variance value of the random variable.
-
_abc_impl
= <_abc_data object>¶
-
-
class
neuraxle.hyperparams.distributions.
Boolean
(proba_is_true: Optional[float] = None, null_default_value=False)[source]¶ Bases:
neuraxle.hyperparams.distributions.DiscreteHyperparameterDistribution
Get a random boolean hyperparameter.
-
__init__
(proba_is_true: Optional[float] = None, null_default_value=False)[source]¶ Create a boolean hyperparameter with given probability.
Boolean distribution is in fact a Bernouilli distribution where given probability set occurance probability of having value 1. (1 - probability) gives occurance probability of having value 0.
- Parameters
proba (float) – a float corresponding to proportion of 1 over 0.
null_default_value (default choice value. if None, default choice value will be the first choice) – default value for distribution
-
pdf
(x) → float[source]¶ Calculate the boolean probability mass function value at position x. :rtype:
float
:param x: value where the probability mass function is evaluated. :return: value of the probability mass function.
-
cdf
(x) → float[source]¶ Calculate the boolean cumulative distribution function value at position x. :rtype:
float
:param x: value where the cumulative distribution function is evaluated. :return: value of the cumulative distribution function.
-
min
()[source]¶ Calculate minimum value that can be sampled in a boolean distribution.
- Returns
minimal value return from distribution.
-
max
()[source]¶ Calculate maximum value that can be sampled in a boolean distribution.
- Returns
maximum value return from distribution.
-
mean
()[source]¶ Calculate mean value (also called esperance) of the random variable.
- Returns
mean value of the random variable.
-
var
()[source]¶ Calculate variance value of the random variable.
- Returns
variance value of the random variable.
-
_abc_impl
= <_abc_data object>¶
-
-
class
neuraxle.hyperparams.distributions.
Choice
(choice_list: List[Any], probas: Optional[List[float]] = None, null_default_value=None)[source]¶ Bases:
neuraxle.hyperparams.distributions.DiscreteHyperparameterDistribution
Get a random value from a choice list of possible value for this hyperparameter.
When narrowed, the choice will only collapse to a single element when narrowed enough. For example, if there are 4 items in the list, only at a narrowing value of 0.25 that the first item will be kept alone.
-
__init__
(choice_list: List[Any], probas: Optional[List[float]] = None, null_default_value=None)[source]¶ Create a random choice hyperparameter from the given list.
- Parameters
choice_list (List) – a list of values to sample from.
null_default_value (default choice value. if None, default choice value will be the first choice) – default value for distribution
-
pdf
(x) → float[source]¶ Calculate the choice probability mass function value at position x. :rtype:
float
:param x: value where the probability mass function is evaluated. :return: value of the probability mass function.
-
cdf
(x) → float[source]¶ Calculate the choice probability cumulative distribution function value at position x. The index in the list is used to know how the choice is performed. :rtype:
float
:param x: value where the cumulative distribution function is evaluated. :return: value of the cumulative distribution function.
-
min
()[source]¶ Calculate minimum value that can be sampled in a choice distribution.
Here the minimal index in the list is return. In this case it returns 0.
- Returns
minimal value return from distribution.
-
max
()[source]¶ Calculate maximal value that can be sampled in a choice distribution.
Here the maximal index in the list is return. In this case it returns the length value of the list.
- Returns
maximal value return from distribution.
-
mean
()[source]¶ Calculate mean value (also called esperance) of the random variable.
- Returns
mean value of the random variable.
-
var
()[source]¶ Calculate variance value of the random variable.
- Returns
variance value of the random variable.
-
_abc_impl
= <_abc_data object>¶
-
-
class
neuraxle.hyperparams.distributions.
PriorityChoice
(choice_list: List[Any], probas: Optional[List[float]] = None, null_default_value=None)[source]¶ Bases:
neuraxle.hyperparams.distributions.OrdinalDiscreteHyperparameterDistribution
Get a random value from a choice list of possible value for this hyperparameter.
This is a choice that is ordinal and where the first choice is the most important one, as well as the default.
The first parameters are kept until the end when the list is narrowed (it is narrowed progressively), unless there is a best guess that surpasses some of the top choices.
-
__init__
(choice_list: List[Any], probas: Optional[List[float]] = None, null_default_value=None)[source]¶ Create a random choice hyperparameter from the given list (choice_list). The first parameters in the choice_list will be kept longer when narrowing the space.
- Parameters
choice_list (List) – a list of values to sample from.
null_default_value (default choice value. if None, default choice value will be the first choice) – default value for distribution
-
pdf
(x) → float[source]¶ Calculate the choice probability mass function value at position x. :rtype:
float
:param x: value where the probability mass function is evaluated. :return: value of the probability mass function.
-
cdf
(x) → float[source]¶ Calculate the choice probability cumulative distribution function value at position x. The index in the list is used to know how the choice is performed. :rtype:
float
:param x: value where the cumulative distribution function is evaluated. :return: value of the cumulative distribution function.
-
min
()[source]¶ Calculate minimum value that can be sampled in a priority choice distribution.
Here the minimal index in the list is return. In this case it returns 0.
- Returns
minimal value return from distribution.
-
max
()[source]¶ Calculate maximal value that can be sampled in a priority choice distribution.
Here the maximal index in the list is return. In this case it returns the length value of the list.
- Returns
maximal value return from distribution.
-
mean
()[source]¶ Calculate mean value (also called esperance) of the random variable.
- Returns
mean value of the random variable.
-
var
()[source]¶ Calculate variance value of the random variable.
- Returns
variance value of the random variable.
-
_abc_impl
= <_abc_data object>¶
-
-
class
neuraxle.hyperparams.distributions.
WrappedDiscreteHyperparameterDistribution
(hd: neuraxle.hyperparams.distributions.HyperparameterDistribution = None, hds: List[neuraxle.hyperparams.distributions.HyperparameterDistribution] = None, null_default_value=None)[source]¶ Bases:
neuraxle.hyperparams.distributions.DiscreteHyperparameterDistribution
-
__init__
(hd: neuraxle.hyperparams.distributions.HyperparameterDistribution = None, hds: List[neuraxle.hyperparams.distributions.HyperparameterDistribution] = None, null_default_value=None)[source]¶ Create a wrapper that will surround another HyperparameterDistribution. The wrapper might use one (hd) and/or many (hds) HyperparameterDistribution depending on the argument(s) used.
- Parameters
hd (
HyperparameterDistribution
) – the other HyperparameterDistribution to wrap.hds – the others HyperparameterDistribution to wrap.
-
_abc_impl
= <_abc_data object>¶
-
-
class
neuraxle.hyperparams.distributions.
Quantized
(hd: neuraxle.hyperparams.distributions.HyperparameterDistribution = None, hds: List[neuraxle.hyperparams.distributions.HyperparameterDistribution] = None, null_default_value=None)[source]¶ Bases:
neuraxle.hyperparams.distributions.WrappedDiscreteHyperparameterDistribution
A quantized wrapper for another distribution: will round() the returned
HyperparameterDistribution.rvs()
number.-
rvs
() → int[source]¶ Will return an integer, rounded from the output of the previous distribution.
- Returns
an integer.
-
pdf
(x) → float[source]¶ Calculate the Quantized probability mass function value at position x of a continuous distribution. :rtype:
float
:param x: value where the probability mass function is evaluated. :return: value of the probability mass function.
-
cdf
(x) → float[source]¶ Calculate the Quantized cumulative distribution function at position x of a continuous distribution. :rtype:
float
:param x: value where the cumulative distribution function is evaluated. :return: value of the cumulative distribution function.
-
min
()[source]¶ Calculate minimum value that can be sampled in the quanitzed version of the distribution.
- Returns
minimal value return from distribution.
-
max
()[source]¶ Calculate maximal value that can be sampled in the quantized version of the distribution.
- Returns
maximal value return from distribution.
-
mean
() → float[source]¶ Calculate mean value (also called esperance) of the random variable.
- Returns
mean value of the random variable.
-
var
() → float[source]¶ Calculate variance value of the random variable.
- Returns
variance value of the random variable.
-
_abc_impl
= <_abc_data object>¶
-
-
class
neuraxle.hyperparams.distributions.
RandInt
(min_included: int, max_included: int, null_default_value: int = None)[source]¶ Bases:
neuraxle.hyperparams.distributions.DiscreteHyperparameterDistribution
Get a random integer within a range
-
__init__
(min_included: int, max_included: int, null_default_value: int = None)[source]¶ Create a quantized random uniform distribution. A random integer between the two values inclusively will be returned.
- Parameters
min_included (
int
) – minimum integer, included.max_included (
int
) – maximum integer, included.null_default_value (int) – null default value for distribution. if None, take the min_included
-
rvs
() → int[source]¶ Will return an integer in the specified range as specified at creation.
- Returns
an integer.
-
pdf
(x) → float[source]¶ Calculate the random int mass function value at position x. :rtype:
float
:param x: value where the probability mass function is evaluated. :return: value of the probability mass function.
-
cdf
(x) → float[source]¶ Calculate the random int cumulative distribution function value at position x. :rtype:
float
:param x: value where the cumulative distribution function is evaluated. :return: value of the cumulative distribution function.
-
min
()[source]¶ Calculate minimum value that can be sampled in the randint distribution.
- Returns
minimal value return from distribution.
-
max
()[source]¶ Calculate maximal value that can be sampled in the randint distribution.
- Returns
maximal value return from distribution.
-
mean
()[source]¶ Calculate mean value (also called esperance) of the random variable.
- Returns
mean value of the random variable.
-
var
()[source]¶ Calculate variance value of the random variable.
- Returns
variance value of the random variable.
-
_abc_impl
= <_abc_data object>¶
-
-
class
neuraxle.hyperparams.distributions.
Uniform
(min_included: float, max_included: float, null_default_value=None)[source]¶ Bases:
neuraxle.hyperparams.distributions.ContinuousHyperparameterDistribution
Get a uniform distribution.
-
__init__
(min_included: float, max_included: float, null_default_value=None)[source]¶ Create a random uniform distribution. A random float between the two values somehow inclusively will be returned.
-
rvs
() → float[source]¶ Will return a float value in the specified range as specified at creation.
- Returns
a float.
-
pdf
(x)[source]¶ Calculate the Uniform probability distribution value at position x.
- Parameters
x – value where the probability distribution function is evaluated.
- Returns
value of the probability distribution function.
-
cdf
(x)[source]¶ Calculate the Uniform cumulative distribution value at position x. :param x: value where the cumulative distribution function is evaluated. :return: value of the cumulative distribution function.
-
min
()[source]¶ Calculate minimum value that can be sampled in the uniform distribution.
- Returns
minimal value return from distribution.
-
max
()[source]¶ Calculate maximal value that can be sampled in the uniform distribution.
- Returns
maximal value return from distribution.
-
mean
()[source]¶ Calculate mean value (also called esperance) of the random variable.
- Returns
mean value of the random variable.
-
var
()[source]¶ Calculate variance value of the random variable.
- Returns
variance value of the random variable.
-
_abc_impl
= <_abc_data object>¶
-
-
class
neuraxle.hyperparams.distributions.
LogUniform
(min_included: float, max_included: float, null_default_value=None)[source]¶ Bases:
neuraxle.hyperparams.distributions.LogSpaceDistributionMixin
,neuraxle.hyperparams.distributions.ContinuousHyperparameterDistribution
Get a LogUniform distribution.
For example, this is good for neural networks’ learning rates: that vary exponentially.
-
__init__
(min_included: float, max_included: float, null_default_value=None)[source]¶ Create a quantized random log uniform distribution. A random float between the two values inclusively will be returned.
- Parameters
min_included (
float
) – minimum integer, should be somehow included.max_included (
float
) – maximum integer, should be somehow included.null_default_value (int) – null default value for distribution. if None, take the min_included
-
rvs
() → float[source]¶ Will return a float value in the specified range as specified at creation.
- Returns
a float.
-
pdf
(x) → float[source]¶ Calculate the logUniform probability distribution value at position x. :rtype:
float
:param x: value where the probability distribution function is evaluated. :return: value of the probability distribution function.
-
cdf
(x) → float[source]¶ Calculate the logUniform cumulative distribution value at position x. :rtype:
float
:param x: value where the cumulative distribution function is evaluated. :return: value of the cumulative distribution function.
-
min
()[source]¶ Calculate minimum value that can be sampled in the LogUniform distribution.
- Returns
minimal value return from distribution.
-
max
()[source]¶ Calculate maximal value that can be sampled in the LogUniform distribution.
- Returns
maximal value return from distribution.
-
mean
()[source]¶ Calculate mean value (also called esperance) of the random variable.
- Returns
mean value of the random variable.
-
var
()[source]¶ Calculate variance value of the random variable.
- Returns
variance value of the random variable.
-
_abc_impl
= <_abc_data object>¶
-
-
class
neuraxle.hyperparams.distributions.
Normal
(mean: float, std: float, hard_clip_min: float = None, hard_clip_max: float = None, null_default_value: float = None)[source]¶ Bases:
neuraxle.hyperparams.distributions.ContinuousHyperparameterDistribution
Get a normal distribution.
-
__init__
(mean: float, std: float, hard_clip_min: float = None, hard_clip_max: float = None, null_default_value: float = None)[source]¶ Create a normal distribution from mean and standard deviation.
- Parameters
mean (float) – the most common value to pop
std (float) – the standard deviation (that is, the sqrt of the variance).
hard_clip_min (float) – if not none, rvs will return max(result, hard_clip_min).
hard_clip_max (float) – if not none, rvs will return min(result, hard_clip_min).
null_default_value (float) – if none, null default value will be set to hard_clip_min.
-
rvs
() → float[source]¶ Will return a float value in the specified range as specified at creation.
- Returns
a float.
-
pdf
(x) → float[source]¶ Calculate the Normal probability distribution value at position x. :rtype:
float
:param x: value where the probability distribution function is evaluated. :return: value of the probability distribution function.
-
cdf
(x) → float[source]¶ Calculate the Normal cumulative distribution value at position x. :rtype:
float
:param x: value where the cumulative distribution function is evaluated. :return: value of the cumulative distribution function.
-
min
()[source]¶ Calculate minimum value that can be sampled in the Normal distribution.
- Returns
minimal value return from distribution.
-
max
()[source]¶ Calculate minimum value that can be sampled in the Normal distribution.
- Returns
minimal value return from distribution.
-
mean
()[source]¶ Calculate mean value (also called esperance) of the random variable.
- Returns
mean value of the random variable.
-
std
()[source]¶ Calculate standard deviation value of the random variable.
- Returns
standard deviation value of the random variable.
-
var
()[source]¶ Calculate variance value of the random variable.
- Returns
variance value of the random variable.
-
_abc_impl
= <_abc_data object>¶
-
-
class
neuraxle.hyperparams.distributions.
LogNormal
(log2_space_mean: float, log2_space_std: float, hard_clip_min: float = None, hard_clip_max: float = None, null_default_value=None)[source]¶ Bases:
neuraxle.hyperparams.distributions.LogSpaceDistributionMixin
,neuraxle.hyperparams.distributions.ContinuousHyperparameterDistribution
Get a LogNormal distribution.
-
static
from_regular_mean_std
(mean: float, std: float, hard_clip_min: float = None, hard_clip_max: float = None)[source]¶
-
__init__
(log2_space_mean: float, log2_space_std: float, hard_clip_min: float = None, hard_clip_max: float = None, null_default_value=None)[source]¶ Create a LogNormal distribution.
- Parameters
log2_space_mean (
float
) – the most common value to pop, but before taking 2**value.log2_space_std (
float
) – the standard deviation of the most common value to pop, but before taking 2**value.hard_clip_min (
float
) – if not none, rvs will return max(result, hard_clip_min). This value is not checked in logspace (so it is checked after the exp).hard_clip_max (
float
) – if not none, rvs will return min(result, hard_clip_min). This value is not checked in logspace (so it is checked after the exp).null_default_value (int) – null default value for distribution. if None, take the hard_clip_min
-
rvs
() → float[source]¶ Will return a float value in the specified range as specified at creation. Note: the range at creation was in log space. The return value is after taking an exponent.
- Returns
a float.
-
pdf
(x) → float[source]¶ Calculate the LogNormal probability distribution value at position x. :rtype:
float
:param x: value where the probability distribution function is evaluated. :return: value of the probability distribution function.
-
cdf
(x) → float[source]¶ Calculate the LogNormal cumulative distribution value at position x. :rtype:
float
:param x: value where the cumulative distribution function is evaluated. :return: value of the cumulative distribution function.
-
min
()[source]¶ Calculate minimum value that can be sampled in the LogNormal distribution.
- Returns
minimal value return from distribution.
-
max
()[source]¶ Calculate maximal value that can be sampled in the LogNormal distribution.
- Returns
maximal value return from distribution.
-
_pseudo_min
() → float[source]¶ This is like the function min, but in case it is of 0, there will be a clipping to at least 4 sigmas.
-
mean
()[source]¶ Calculate mean value (also called esperance) of the random variable.
- Returns
mean value of the random variable.
-
var
()[source]¶ Calculate variance value (also called esperance) of the random variable.
- Returns
variance value of the random variable.
-
_abc_impl
= <_abc_data object>¶
-
static
-
class
neuraxle.hyperparams.distributions.
DistributionMixture
(distributions: List[neuraxle.hyperparams.distributions.HyperparameterDistribution], distribution_amplitudes: List[float])[source]¶ Bases:
neuraxle.hyperparams.distributions.DiscreteHyperparameterDistribution
Get a mixture of multiple distribution
-
__init__
(distributions: List[neuraxle.hyperparams.distributions.HyperparameterDistribution], distribution_amplitudes: List[float])[source]¶ Create a mixture of multiple distributions.
Distribution amplitude are normalized to make sure that the sum equals one. This normalization ensure to keep a random variable at the end (0 < probability < 1).
- Parameters
distributions – list of multiple instantiated distribution.
distribution_amplitudes – list of float representing the amplitude in the probability distribution function for each distribution.
-
static
build_gaussian_mixture
(distribution_amplitudes: List[float], means: List[float], stds: List[float], distributions_mins: List[float], distributions_max: List[float], use_logs: bool = False, use_quantized_distributions: bool = False) → neuraxle.hyperparams.distributions.DistributionMixture[source]¶ Create a gaussian mixture.
Will create a mixture distribution which consist of multiple gaussians of different amplitudes, means, standard deviations, mins and max.
- Parameters
distribution_amplitudes – list of different amplitudes to infer to the mixture. The amplitudes are normalized to sum to 1.
means – list of means to infer mean to each gaussian.
stds – list of standard deviations to infer standard deviation to each gaussian.
distributions_mins – list of minimum value that will clip each gaussian. If it is -Inf or None, it will not be clipped.
distributions_max – list of maximal value that will clip each gaussian. If it is +Inf or None, it will not be clipped.
distributions_max – bool weither to use a quantized version or not.
use_logs (
bool
) – use logs booleanuse_quantized_distributions (
bool
) – use quantized distributions boolean
:return DistributionMixture instance
-
rvs
() → float[source]¶ Will return a float value drawned from the distribution mixture.
- Returns
a float.
-
pdf
(x) → float[source]¶ Calculate the mixture probability distribution value at position x.
- Return type
float
- Parameters
x – value where the probability distribution function is evaluated.
- Returns
value of the probability distribution function.
-
cdf
(x) → float[source]¶ Calculate the mixture cumulative distribution value at position x.
- Return type
float
- Parameters
x – value where the cumulative distribution function is evaluated.
- Returns
value of the cumulative distribution function.
-
mean
() → float[source]¶ Calculate mean of the mixture.
Mean of the distribution mixture is calculated using the following equation:
\[mean = \sum_{i=1}^n w_i * \mu_i,\]where \(w_i\) and \(\mu_i\) are respectively the amplitude and mean of each distribution.
- Returns
mean value of the mixture.
-
var
() → float[source]¶ Calculate variance of the mixture.
Variance of a mixture is calculated using the following equation:
\[variance = (\sum_{i=1}^n w_i * \sigma_i * \mu_i) - \mu^2,\]where \(w_i\), \(\sigma_i\) and \(\mu_i\) are respectively the amplitude, standard deviation and mean of each distribution and \(\mu\) is the mean of the whole mixture.
- Returns
standard deviation value of the mixtture.
-
std
() → float[source]¶ Calculate standard deviation of the mixture.
- Returns
standard deviation value of the mixtture.
-
min
() → float[source]¶ Calculate minimal domain value of the mixture.
- Returns
minimal domain value of the mixtture.
-
max
() → float[source]¶ Calculate minimal domain value of the mixture.
- Returns
minimal domain value of the mixture.
-
is_discrete
() → bool[source]¶ Check if the distribution is discrete.
- Returns
True if the distribution is discrete, False otherwise.
-
values
() → List[float][source]¶ Get all the values of the distribution.
- Returns
list of all the values of the distribution.
-
probabilities
() → List[float][source]¶ Get all the probabilities of the distribution.
- Returns
list of all the probabilities of the distribution.
-
_abc_impl
= <_abc_data object>¶
-
-
class
neuraxle.hyperparams.distributions.
LogDistributionMixture
(distributions: List[neuraxle.hyperparams.distributions.HyperparameterDistribution], distribution_amplitudes: List[float])[source]¶ Bases:
neuraxle.hyperparams.distributions.DistributionMixture
-
rvs
() → float[source]¶ Will return a float value drawned from the distribution mixture.
- Returns
a float.
-
_abc_impl
= <_abc_data object>¶
-