neuraxle.hyperparams.scipy_distributions

Functions

get_index_in_list_with_bool(choice_list, value)

scipy_method(func)

Classes

BaseCustomContinuousScipyDistribution(name, …)

BaseCustomDiscreteScipyDistribution(name, …)

Boolean(proba_is_true[, null_default_value])

Get a random boolean hyperparameter.

Choice(choice_list, probas[, null_default_value])

Get a random value from a choice list of possible value for this hyperparameter.

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

FixedHyperparameter(value[, null_default_value])

This is an hyperparameter that won’t change again, but that is still expressed as a distribution.

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

LogNormal(log2_space_mean, log2_space_std, …)

Get a normal distribution.

LogUniform(min_included, max_included[, …])

Get a LogUniform distribution.

Normal(mean, std, hard_clip_min, …)

LogNormal distribution that wraps a continuous scipy distribution

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

Poisson distribution that inherits from scipy.stats.rv_discrete

Quantized(hd, hds[, null_default_value])

A quantized wrapper for another distribution: will round() the rvs number.

RandInt(min_included, max_included, **kwargs)

Rand int scipy distribution.

ScipyContinuousDistributionWrapper(…[, …])

ScipyDiscreteDistributionWrapper(…[, …])

ScipyDistributionWrapper(scipy_distribution, …)

Base class for a distribution that wraps a scipy distribution.

Uniform(min_included, max_included[, …])

Get a uniform distribution.

class neuraxle.hyperparams.scipy_distributions.BaseCustomContinuousScipyDistribution(name, min_included, max_included, null_default_value, **kwargs)[source]
_abc_impl = <_abc_data object>
_override_scipy_methods()[source]
_pdf(x, *args)[source]
class neuraxle.hyperparams.scipy_distributions.BaseCustomDiscreteScipyDistribution(name, min_included, max_included, null_default_value, **kwargs)[source]
_abc_impl = <_abc_data object>
_override_scipy_methods()[source]
_pmf(x, *args)[source]
class neuraxle.hyperparams.scipy_distributions.Boolean(proba_is_true: Optional[float] = None, null_default_value=False)[source]

Get a random boolean hyperparameter.

_abc_impl = <_abc_data object>
_pmf(x)[source]

Calculate the boolean probability mass function value at position x. :param x: value where the probability mass function is evaluated. :return: value of the probability mass function.

class neuraxle.hyperparams.scipy_distributions.Choice(choice_list: List[T], probas: Optional[List[float]] = None, null_default_value=None)[source]

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.

_abc_impl = <_abc_data object>
_pmf(x)[source]

Calculate the choice probability mass function value at position x.

Parameters

x – value where the probability mass function is evaluated.

Returns

value of the probability mass function.

cdf(x, *args, **kwargs)[source]

Abstract method for cumulative distribution function value at x.

Parameters

x – value where the cumulative distribution function is evaluated.

Returns

The cumulative distribution function value.

max()[source]

Abstract method for obtaining maximal value that can sampled in distribution.

Returns

maximal value that can be sampled from distribution.

mean()[source]

Calculate mean value (also called esperance) of the random variable. :return: mean value of the random variable.

min()[source]

Abstract method for obtaining minimum value that can sampled in distribution.

Returns

minimal value that can be sampled from distribution.

pdf(x, *args, **kwargs)[source]

Abstract method for probability distribution function value at x.

Parameters

x – value where the probability distribution function is evaluated.

Returns

The probability distribution function value.

pmf(x)[source]

Calculate the choice probability mass function value at position x.

Parameters

x – value where the probability mass function is evaluated.

Returns

value of the probability mass function.

probabilities()[source]
rvs(*args, **kwargs)[source]

Sample the random variable.

Returns

The randomly sampled value.

std()[source]

Base method to calculate distribution std value by taking sqrt of variance value.

Returns

distribution std value.

values()[source]
var()[source]

Calculate variance value of the random variable. :return: variance value of the random variable.

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]
_pdf(x)[source]
class neuraxle.hyperparams.scipy_distributions.FixedHyperparameter(value, null_default_value=None)[source]

This is an hyperparameter that won’t change again, but that is still expressed as a distribution.

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

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

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

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

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

Get a normal distribution.

See also

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

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

Get a LogUniform distribution.

See also

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

_abc_impl = <_abc_data object>
_pdf(x) → float[source]

Calculate the logUniform probability distribution value at position x.

Parameters

x – value where the probability distribution function is evaluated.

Returns

value of the probability distribution function.

class neuraxle.hyperparams.scipy_distributions.Normal(mean: float, std: float, hard_clip_min: float = None, hard_clip_max: float = None, null_default_value: float = None)[source]

LogNormal distribution that wraps a continuous scipy distribution

Example usage :

distribution = LogNormal(
    min_included=0,
    max_included=10,
    null_default_value=0.0
)

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

See also

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

_abc_impl = <_abc_data object>
_pdf(x) → float[source]

Calculate the Normal probability distribution value at position x. :param x: value where the probability distribution function is evaluated. :return: value of the probability distribution function.

class neuraxle.hyperparams.scipy_distributions.Poisson(min_included: float, max_included: float, null_default_value: float = None, mu=0.6)[source]

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

_abc_impl = <_abc_data object>
_pmf(x)[source]
class neuraxle.hyperparams.scipy_distributions.Quantized(hd: neuraxle.hyperparams.distributions.HyperparameterDistribution = None, hds: List[neuraxle.hyperparams.distributions.HyperparameterDistribution] = None, null_default_value=None)[source]

A quantized wrapper for another distribution: will round() the rvs number.

_abc_impl = <_abc_data object>
_pdf(x)[source]

Calculate the Quantized probability mass function value at position x of a continuous distribution. :param x: value where the probability mass function is evaluated. :return: value of the probability mass function.

class neuraxle.hyperparams.scipy_distributions.RandInt(min_included: int, max_included: int, **kwargs)[source]

Rand int scipy distribution. Check out scipy.stats.randint for more info

_abc_impl = <_abc_data object>
max()[source]

Abstract method for obtaining maximal value that can sampled in distribution.

Returns

maximal value that can be sampled from distribution.

mean(*args, **kwargs)[source]

Abstract method for calculating distribution mean value.

Returns

distribution mean value.

median(*args, **kwargs)[source]
min()[source]

Abstract method for obtaining minimum value that can sampled in distribution.

Returns

minimal value that can be sampled from distribution.

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

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

_abc_impl = <_abc_data object>
_override_scipy_methods()[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]
max(**kwargs)[source]
mean(**kwargs)[source]
median(**kwargs)[source]
min(**kwargs)[source]
moment(**kwargs)[source]
nnlf(**kwargs)[source]
pdf(**kwargs)[source]
ppf(**kwargs)[source]
rvs(**kwargs)[source]
sf(**kwargs)[source]
stats(**kwargs)[source]
std(**kwargs)[source]
support(**kwargs)[source]
to_sk_learn()[source]
var(**kwargs)[source]
class neuraxle.hyperparams.scipy_distributions.Uniform(min_included: float, max_included: float, null_default_value=None)[source]

Get a uniform distribution.

See also

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

_abc_impl = <_abc_data object>
_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.

neuraxle.hyperparams.scipy_distributions.get_index_in_list_with_bool(choice_list: List[Any], value: Any) → int[source]
neuraxle.hyperparams.scipy_distributions.scipy_method(func)[source]