jpt.distributions.univariate.integer ==================================== .. py:module:: jpt.distributions.univariate.integer .. autoapi-nested-parse:: © Copyright 2021, Mareike Picklum, Daniel Nyga. Classes ------- .. autoapisummary:: jpt.distributions.univariate.integer.IntegerMap jpt.distributions.univariate.integer.IntegerLabelToValueMap jpt.distributions.univariate.integer.IntegerValueToLabelMap jpt.distributions.univariate.integer.Integer Functions --------- .. autoapisummary:: jpt.distributions.univariate.integer.IntegerType Module Contents --------------- .. py:class:: IntegerMap(lmin: Optional[int] = None, lmax: Optional[int] = None) Bases: :py:obj:`jpt.distributions.univariate.distribution.ValueMap` A mapping of external integers to their internal representation and vice versa. .. py:attribute:: _min .. py:attribute:: _max .. py:method:: __eq__(other: IntegerMap) -> bool .. py:method:: __len__() .. py:method:: __hash__() .. py:method:: __contains__(item) .. py:method:: __iter__() .. py:method:: as_set() -> jpt.base.intervals.IntSet :abstractmethod: .. py:class:: IntegerLabelToValueMap(lmin: Optional[int] = None, lmax: Optional[int] = None) Bases: :py:obj:`IntegerMap` Maps integer labels to their internal values .. py:property:: min .. py:property:: max .. py:method:: __getitem__(label: int) -> int .. py:method:: as_set() -> jpt.base.intervals.IntSet .. py:class:: IntegerValueToLabelMap(lmin: Optional[int] = None, lmax: Optional[int] = None) Bases: :py:obj:`IntegerMap` Maps internal integer values to integer labels. .. py:property:: min .. py:property:: max .. py:method:: __getitem__(value: int) -> int .. py:method:: as_set() -> jpt.base.intervals.IntSet .. py:class:: Integer(**settings) Bases: :py:obj:`jpt.distributions.univariate.Distribution` Abstract supertype of all domains and distributions .. py:attribute:: values :type: Optional[IntegerLabelToValueMap] .. py:attribute:: labels .. py:attribute:: OPEN_DOMAIN :value: 'open_domain' .. py:attribute:: AUTO_DOMAIN :value: 'auto_domain' .. py:attribute:: SETTINGS .. py:method:: min() -> Optional[int] .. py:method:: max() -> Optional[int] .. py:method:: _min() -> Optional[int] .. py:method:: _max() -> Optional[int] .. py:attribute:: _params :type: Optional[Dict[int, float]] :value: None .. py:attribute:: to_json :type: types.FunctionType .. py:method:: hash() :classmethod: .. py:method:: __add__(other: Integer) -> Integer .. py:method:: __neg__() -> Integer .. py:property:: cdf :type: jpt.base.functions.PiecewiseFunction .. py:method:: add(other: Integer, name: Optional[str] = None) -> Integer .. py:method:: equiv(other: Type[jpt.distributions.univariate.Distribution]) -> bool :classmethod: .. py:method:: type_to_json() -> Dict[str, Any] :classmethod: .. py:method:: inst_to_json() -> Dict[str, Any] .. py:method:: type_from_json(data) :staticmethod: .. py:method:: from_json(data: Dict[str, Any]) -> Integer :classmethod: .. py:method:: copy() .. py:property:: probabilities :type: Dict[int, float] .. py:method:: n_values() -> Optional[int] .. py:method:: value2label(value: Union[int, Iterable[int], jpt.base.intervals.IntSet, jpt.base.intervals.UnionSet]) -> Union[int, Iterable[int], jpt.base.intervals.IntSet, jpt.base.intervals.UnionSet] :classmethod: .. py:method:: label2value(label: Union[int, Iterable[int], jpt.base.intervals.IntSet, jpt.base.intervals.UnionSet]) -> Union[int, Iterable[int], jpt.base.intervals.IntSet, jpt.base.intervals.UnionSet] :classmethod: .. py:method:: _sample(n: int) -> Iterable[int] .. py:method:: _sample_one() -> int .. py:method:: sample(n: int) -> Iterable[int] .. py:method:: sample_one() -> int .. py:property:: _pdf :type: types.FunctionType .. py:property:: pdf :type: types.FunctionType .. py:method:: p(labels: Union[int, Iterable[int]]) -> float .. py:method:: _p(values: Union[int, Iterable[int]]) -> float .. py:method:: expectation() -> float .. py:method:: _expectation() -> float .. py:method:: variance() -> float .. py:method:: _variance() -> float .. py:method:: _k_mpe(k: Optional[int] = None) -> Iterable[Tuple[jpt.base.intervals.NumberSet, float]] Calculate the ``k`` most probable explanation states. :param k: The number of solutions to generate :return: An list containing a tuple containing the likelihood and state in descending order. .. py:method:: k_mpe(k: int = None) -> Iterable[Tuple[jpt.base.intervals.NumberSet, float]] .. py:method:: mpe() -> (jpt.base.intervals.NumberSet, float) .. py:method:: _mpe() -> (Set[int], float) .. py:method:: mode() .. py:method:: _mode() .. py:method:: crop(restriction: Union[jpt.base.intervals.NumberSet, int]) -> Integer .. py:method:: _crop(restriction: Union[jpt.base.intervals.NumberSet, int]) -> Integer .. py:method:: merge(distributions: Iterable[Integer], weights: Iterable[numbers.Real]) -> Integer :staticmethod: .. py:method:: update(dist: Integer, weight: int) -> Integer .. py:method:: fit(data: numpy.ndarray, rows: numpy.ndarray = None, col: int = None) -> Integer .. py:method:: _fit(data: numpy.ndarray, rows: numpy.ndarray = None, col: int = None) -> Integer .. py:method:: _set(params: Dict[int, float] or Iterable[float]) -> Integer .. py:method:: set(params: Dict[int, float] or Iterable[float]) -> Integer .. py:method:: __eq__(other) -> bool .. py:method:: __str__() .. py:method:: __repr__() .. py:method:: infinite() -> bool .. py:method:: finite() -> bool .. py:method:: _sorted(exhaustive: bool = True, reverse: bool = False, max_items: int = None) -> Iterable[Tuple[int, float]] .. py:method:: sorted(exhaustive: bool = True, reverse: bool = False, max_items: int = None) -> Iterable[Tuple[int, float]] .. py:method:: _items(exhaustive: bool = False, max_items: int = None) -> Iterable[Tuple[int, float]] Return a list of (probability, value) pairs representing this distribution. .. py:method:: items(exhaustive: bool = True, max_items: int = None) -> Iterable[Tuple[int, float]] Return a list of (probability, label) pairs representing this distribution. .. py:method:: kl_divergence(other: Integer) -> float .. py:method:: number_of_parameters() -> int .. py:method:: moment(order: int = 1, center: float = 0) -> float Calculate the central moment of the r-th order almost everywhere. .. math:: \int (x-c)^{r} p(x) :param order: The order of the moment to calculate :param center: The constant to subtract in the basis of the exponent .. py:method:: wasserstein_distance(d1: Integer, d2: Integer) -> float :staticmethod: .. py:method:: distance(other: Integer) -> float .. py:method:: jaccard_similarity(d1: Integer, d2: Integer) -> float :staticmethod: .. py:method:: similarity(other: Integer) -> float .. py:method:: plot(engine=None, **kwargs) -> Any Plots the distribution using the given engine. :param engine: Can be either one of ``["plotly", "matplotlib"]``, or an instance of a rendering engine subclassing ``DistributionRendering``. :param kwargs: The keyword arguments to pass to the engine as defined in the ``.plot_integer()`` function of ``DistributionRendering`` or its respective subclass defined by ``engine``. :return: the figure object of the plotting engine .. py:function:: IntegerType(name: str, lmin: Optional[int] = None, lmax: Optional[int] = None) -> Type[Integer]