neuraxle.hyperparams.scipy_distributions

Module-level documentation for neuraxle.hyperparams.scipy_distributions. Here is an inheritance diagram, including dependencies to other base modules of Neuraxle:

Inheritance diagram of neuraxle.hyperparams.scipy_distributions

Functions

scipy_method(func)

Classes

BaseCustomContinuousScipyDistribution(name, …)

BaseCustomDiscreteScipyDistribution(name, …)

Distribution([momtype, a, b, xtol, …])

Gaussian(min_included, max_included, …)

Gaussian distribution that inherits from scipy.stats.rv_continuous

Histogram(histogram, null_default_value, …)

Histogram distribution that inherits from scipy.stats.rv_histogram

Poisson(min_included, max_included, …[, mu])

Poisson distribution that inherits from scipy.stats.rv_discrete

ScipyContinuousDistributionWrapper(…[, …])

ScipyDiscreteDistributionWrapper(…[, …])

ScipyDistributionWrapper(scipy_distribution, …)

Base class for a distribution that wraps a scipy distribution.

ScipyLogUniform(min_included, max_included)

Get a LogUniform distribution.

StdMeanLogNormal(log2_space_mean, …)

Get a normal distribution from std and min.


neuraxle.hyperparams.scipy_distributions.scipy_method(func)[source]
class neuraxle.hyperparams.scipy_distributions.ScipyDistributionWrapper(scipy_distribution, **scipy_distribution_arguments)[source]

Bases: abc.ABC

Base class for a distribution that wraps a scipy distribution.

Usage example:

distribution = ScipyDistributionWrapper(
    scipy_distribution=rv_histogram(histogram=histogram),
    null_default_value=null_default_value
)

See also

HyperparameterDistribution

__init__(scipy_distribution, **scipy_distribution_arguments)[source]

Initialize self. See help(type(self)) for accurate signature.

_override_scipy_methods()[source]
rvs(**kwargs)[source]
rvs_many(**kwargs)[source]
pdf(**kwargs)[source]
cdf(**kwargs)[source]
entropy(**kwargs)[source]
expect(**kwargs)[source]
fit(**kwargs)[source]
fit_loc_scale(**kwargs)[source]
freeze(**kwargs)[source]
interval(**kwargs)[source]
isf(**kwargs)[source]
logcdf(**kwargs)[source]
logpdf(**kwargs)[source]
logsf(**kwargs)[source]
min(**kwargs)[source]
max(**kwargs)[source]
mean(**kwargs)[source]
median(**kwargs)[source]
moment(**kwargs)[source]
nnlf(**kwargs)[source]
ppf(**kwargs)[source]
sf(**kwargs)[source]
stats(**kwargs)[source]
std(**kwargs)[source]
support(**kwargs)[source]
var(**kwargs)[source]
to_sk_learn()[source]
_abc_impl = <_abc_data object>
class neuraxle.hyperparams.scipy_distributions.ScipyContinuousDistributionWrapper(scipy_distribution, null_default_value=None, **kwargs)[source]

Bases: neuraxle.hyperparams.scipy_distributions.ScipyDistributionWrapper, neuraxle.hyperparams.distributions.ContinuousHyperparameterDistribution

__init__(scipy_distribution, null_default_value=None, **kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

_abc_impl = <_abc_data object>
class neuraxle.hyperparams.scipy_distributions.ScipyDiscreteDistributionWrapper(scipy_distribution, null_default_value=None, **kwargs)[source]

Bases: neuraxle.hyperparams.scipy_distributions.ScipyDistributionWrapper, neuraxle.hyperparams.distributions.DiscreteHyperparameterDistribution

__init__(scipy_distribution, null_default_value=None, **kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

values()[source]
_abc_impl = <_abc_data object>
class neuraxle.hyperparams.scipy_distributions.BaseCustomDiscreteScipyDistribution(name, min_included, max_included, null_default_value, **kwargs)[source]

Bases: neuraxle.hyperparams.scipy_distributions.ScipyDiscreteDistributionWrapper

__init__(name, min_included, max_included, null_default_value, **kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

_override_scipy_methods()[source]
_pmf(x, *args)[source]
_abc_impl = <_abc_data object>
class neuraxle.hyperparams.scipy_distributions.Distribution(momtype=1, a=None, b=None, xtol=1e-14, badvalue=None, name=None, longname=None, shapes=None, extradoc=None, seed=None)[source]

Bases: scipy.stats._distn_infrastructure.rv_continuous

_pdf(x)[source]
class neuraxle.hyperparams.scipy_distributions.BaseCustomContinuousScipyDistribution(name, min_included, max_included, null_default_value, **kwargs)[source]

Bases: neuraxle.hyperparams.scipy_distributions.ScipyContinuousDistributionWrapper

__init__(name, min_included, max_included, null_default_value, **kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

_override_scipy_methods()[source]
_pdf(x, *args)[source]
_abc_impl = <_abc_data object>
class neuraxle.hyperparams.scipy_distributions.ScipyLogUniform(min_included: float, max_included: float, null_default_value=None)[source]

Bases: neuraxle.hyperparams.distributions.LogSpaceDistributionMixin, neuraxle.hyperparams.scipy_distributions.BaseCustomContinuousScipyDistribution

Get a LogUniform distribution.

Refer to: scipy.stats.loguniform.

See also

set_hyperparams_space(), ScipyDistributionWrapper,

__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

_pdf(x) → float[source]

Calculate the logUniform 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.

_abc_impl = <_abc_data object>
class neuraxle.hyperparams.scipy_distributions.StdMeanLogNormal(log2_space_mean: float, log2_space_std: float, hard_clip_min: float, hard_clip_max: float, null_default_value: float = None)[source]

Bases: neuraxle.hyperparams.distributions.LogSpaceDistributionMixin, neuraxle.hyperparams.scipy_distributions.BaseCustomContinuousScipyDistribution

Get a normal distribution from std and min.

See also

NormalScipyDistribution, set_hyperparams_space(), HyperparameterDistribution, ScipyDistributionWrapper, neuraxle.hyperparams.space.HyperparameterSamples, neuraxle.hyperparams.space.HyperparameterSpace, neuraxle.base.BaseStep

__init__(log2_space_mean: float, log2_space_std: float, hard_clip_min: float, hard_clip_max: float, null_default_value: float = None)[source]

Create a normal distribution from mean and standard deviation.

Parameters
  • log2_space_mean (float) – the most common value to pop

  • log2_space_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.

_pdf(x)[source]
_abc_impl = <_abc_data object>
class neuraxle.hyperparams.scipy_distributions.Gaussian(min_included: int, max_included: int, null_default_value: float = None)[source]

Bases: neuraxle.hyperparams.scipy_distributions.BaseCustomContinuousScipyDistribution

Gaussian distribution that inherits from scipy.stats.rv_continuous

Example usage :

gaussian_distribution = Gaussian(
    min_included=0,
    max_included=10,
    null_default_value=0.0
)

assert 0.0 <= gaussian_distribution.rvs() <= 10.0
assert gaussian_distribution.pdf(10) < 0.001
assert gaussian_distribution.pdf(0) < 0.42
assert 0.55 > gaussian_distribution.cdf(5.0) > 0.45
assert gaussian_distribution.cdf(0) == 0.0

See also

GaussianScipyDistribution, ScipyDistributionWrapper, set_hyperparams_space(), HyperparameterDistribution, neuraxle.hyperparams.space.HyperparameterSamples, neuraxle.hyperparams.space.HyperparameterSpace, neuraxle.base.BaseStep

__init__(min_included: int, max_included: int, null_default_value: float = None)[source]

Initialize self. See help(type(self)) for accurate signature.

_pdf(x)[source]
_abc_impl = <_abc_data object>
class neuraxle.hyperparams.scipy_distributions.Poisson(min_included: float, max_included: float, null_default_value: float = None, mu=0.6)[source]

Bases: neuraxle.hyperparams.scipy_distributions.BaseCustomDiscreteScipyDistribution

Poisson distribution that inherits from scipy.stats.rv_discrete

Example usage :

poisson_distribution = Poisson(
    min_included=0.0,
    max_included=10.0,
    null_default_value=0.0,
    mu=5.0
)

rvs = [poisson_distribution.rvs() for i in range(10)]
assert not all(x == rvs[0] for x in rvs)
assert 0.0 <= poisson_distribution.rvs() <= 10.0
assert poisson_distribution.pdf(10) == 0.01813278870782187
assert np.isclose(poisson_distribution.pdf(0), 0.006737946999085467)
assert poisson_distribution.cdf(5.0) == 0.6159606548330632
assert poisson_distribution.cdf(0) == 0.006737946999085467

See also

set_hyperparams_space(), PoissonScipyDistribution, HyperparameterDistribution, ScipyDistributionWrapper, HyperparameterSamples, HyperparameterSpace, BaseStep

__init__(min_included: float, max_included: float, null_default_value: float = None, mu=0.6)[source]

Initialize self. See help(type(self)) for accurate signature.

_pmf(x)[source]
_abc_impl = <_abc_data object>
class neuraxle.hyperparams.scipy_distributions.Histogram(histogram: numpy.histogram, null_default_value: float = None, **kwargs)[source]

Bases: neuraxle.hyperparams.scipy_distributions.ScipyDiscreteDistributionWrapper

Histogram distribution that inherits from scipy.stats.rv_histogram

Example usage :

hist_dist = Histogram(
     histogram=np.histogram(data, bins=100),
     null_default_value=0.0
)

assert min(data) <= hist_dist.rvs() <= max(data)
assert 1.0 > hist_dist.pdf(x=1.0) > 0.0
assert hist_dist.pdf(x=np.max(data)) == 0.0
assert hist_dist.pdf(x=np.min(data)) < 0.001
assert hist_dist.cdf(x=np.max(data)) == 1.0
assert 0.55 > hist_dist.cdf(x=np.median(data)) > 0.45
assert hist_dist.cdf(x=np.min(data)) == 0.0

See also

HyperparameterDistribution, ScipyDistributionWrapper, Poisson, Gaussian, set_hyperparams_space(), HyperparameterSamples, HyperparameterSpace, BaseStep

__init__(histogram: numpy.histogram, null_default_value: float = None, **kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

_abc_impl = <_abc_data object>