Skip to content

Commit

Permalink
stopped override of public methods
Browse files Browse the repository at this point in the history
  • Loading branch information
ShreeshaM07 committed Jun 13, 2024
1 parent 0ea5255 commit bfac335
Showing 1 changed file with 0 additions and 221 deletions.
221 changes: 0 additions & 221 deletions skpro/distributions/base/_base_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,224 +244,3 @@ def _get_bc_params_dict(
# print(kwargs_as_np,shape,is_scalar)
return kwargs_as_np, shape, is_scalar
return kwargs_as_np

def pdf(self, x):
r"""Probability density function.
Let :math:`X` be a random variables with the distribution of ``self``,
taking values in ``(N, n)`` ``DataFrame``-s
Let :math:`x\in \mathbb{R}^{N\times n}`.
By :math:`p_{X_{ij}}`, denote the marginal pdf of :math:`X` at the
:math:`(i,j)`-th entry.
The output of this method, for input ``x`` representing :math:`x`,
is a ``DataFrame`` with same columns and indices as ``self``,
and entries :math:`p_{X_{ij}}(x_{ij})`.
If ``self`` has a mixed or discrete distribution, this returns
the weighted continuous part of `self`'s distribution instead of the pdf,
i.e., the marginal pdf integrate to the weight of the continuous part.
Parameters
----------
x : ``pandas.DataFrame`` or 2D ``np.ndarray``
representing :math:`x`, as above
Returns
-------
``pd.DataFrame`` with same columns and index as ``self``
containing :math:`p_{X_{ij}}(x_{ij})`, as above
"""
distr_type = self.get_tag("distr:measuretype", "mixed", raise_error=False)
x = np.array(x)
if distr_type == "discrete":
return self._coerce_to_self_index_df(0, flatten=False)

return self._boilerplate("_pdf", x=x)

def log_pdf(self, x):
r"""Logarithmic probability density function.
Numerically more stable than calling pdf and then taking logartihms.
Let :math:`X` be a random variables with the distribution of ``self``,
taking values in `(N, n)` ``DataFrame``-s
Let :math:`x\in \mathbb{R}^{N\times n}`.
By :math:`p_{X_{ij}}`, denote the marginal pdf of :math:`X` at the
:math:`(i,j)`-th entry.
The output of this method, for input ``x`` representing :math:`x`,
is a ``DataFrame`` with same columns and indices as ``self``,
and entries :math:`\log p_{X_{ij}}(x_{ij})`.
If ``self`` has a mixed or discrete distribution, this returns
the weighted continuous part of `self`'s distribution instead of the pdf,
i.e., the marginal pdf integrate to the weight of the continuous part.
Parameters
----------
x : ``pandas.DataFrame`` or 2D ``np.ndarray``
representing :math:`x`, as above
Returns
-------
``pd.DataFrame`` with same columns and index as ``self``
containing :math:`\log p_{X_{ij}}(x_{ij})`, as above
"""
distr_type = self.get_tag("distr:measuretype", "mixed", raise_error=False)
x = np.array(x)
if distr_type == "discrete":
return self._coerce_to_self_index_df(-np.inf, flatten=False)

return self._boilerplate("_log_pdf", x=x)

def pmf(self, x):
r"""Probability mass function.
Let :math:`X` be a random variables with the distribution of ``self``,
taking values in ``(N, n)`` ``DataFrame``-s
Let :math:`x\in \mathbb{R}^{N\times n}`.
By :math:`m_{X_{ij}}`, denote the marginal mass of :math:`X` at the
:math:`(i,j)`-th entry, i.e.,
:math:`m_{X_{ij}}(x_{ij}) = \mathbb{P}(X_{ij} = x_{ij})`.
The output of this method, for input ``x`` representing :math:`x`,
is a ``DataFrame`` with same columns and indices as ``self``,
and entries :math:`m_{X_{ij}}(x_{ij})`.
If ``self`` has a mixed or discrete distribution, this returns
the weighted continuous part of `self`'s distribution instead of the pdf,
i.e., the marginal pdf integrate to the weight of the continuous part.
Parameters
----------
x : ``pandas.DataFrame`` or 2D ``np.ndarray``
representing :math:`x`, as above
Returns
-------
``pd.DataFrame`` with same columns and index as ``self``
containing :math:`p_{X_{ij}}(x_{ij})`, as above
"""
distr_type = self.get_tag("distr:measuretype", "mixed", raise_error=False)
if distr_type == "continuous":
return self._coerce_to_self_index_df(0, flatten=False)

return self._boilerplate("_pmf", x=x)

def log_pmf(self, x):
r"""Logarithmic probability mass function.
Numerically more stable than calling pmf and then taking logartihms.
Let :math:`X` be a random variables with the distribution of ``self``,
taking values in `(N, n)` ``DataFrame``-s
Let :math:`x\in \mathbb{R}^{N\times n}`.
By :math:`m_{X_{ij}}`, denote the marginal pdf of :math:`X` at the
:math:`(i,j)`-th entry, i.e.,
:math:`m_{X_{ij}}(x_{ij}) = \mathbb{P}(X_{ij} = x_{ij})`.
The output of this method, for input ``x`` representing :math:`x`,
is a ``DataFrame`` with same columns and indices as ``self``,
and entries :math:`\log m_{X_{ij}}(x_{ij})`.
If ``self`` has a mixed or discrete distribution, this returns
the weighted continuous part of `self`'s distribution instead of the pdf,
i.e., the marginal pdf integrate to the weight of the continuous part.
Parameters
----------
x : ``pandas.DataFrame`` or 2D ``np.ndarray``
representing :math:`x`, as above
Returns
-------
``pd.DataFrame`` with same columns and index as ``self``
containing :math:`\log m_{X_{ij}}(x_{ij})`, as above
"""
distr_type = self.get_tag("distr:measuretype", "mixed", raise_error=False)
if distr_type == "continuous":
return self._coerce_to_self_index_df(-np.inf, flatten=False)

return self._boilerplate("_log_pmf", x=x)

def cdf(self, x):
r"""Cumulative distribution function.
Let :math:`X` be a random variables with the distribution of ``self``,
taking values in ``(N, n)`` ``DataFrame``-s
Let :math:`x\in \mathbb{R}^{N\times n}`.
By :math:`F_{X_{ij}}`, denote the marginal cdf of :math:`X` at the
:math:`(i,j)`-th entry,
i.e., :math:`F_{X_{ij}}(t) = \mathbb{P}(X_{ij} \leq t)`.
The output of this method, for input ``x`` representing :math:`x`,
is a ``DataFrame`` with same columns and indices as ``self``,
and entries :math:`F_{X_{ij}}(x_{ij})`.
Parameters
----------
x : ``pandas.DataFrame`` or 2D ``np.ndarray``
representing :math:`x`, as above
Returns
-------
``pd.DataFrame`` with same columns and index as ``self``
containing :math:`F_{X_{ij}}(x_{ij})`, as above
"""
x = np.array(x)
return self._boilerplate("_cdf", x=x)

def ppf(self, p):
r"""Quantile function = percent point function = inverse cdf.
Let :math:`X` be a random variables with the distribution of ``self``,
taking values in ``(N, n)`` ``DataFrame``-s
Let :math:`x\in \mathbb{R}^{N\times n}`.
By :math:`F_{X_{ij}}`, denote the marginal cdf of :math:`X` at the
:math:`(i,j)`-th entry.
The output of this method, for input ``p`` representing :math:`p`,
is a ``DataFrame`` with same columns and indices as ``self``,
and entries :math:`F^{-1}_{X_{ij}}(p_{ij})`.
Parameters
----------
p : ``pandas.DataFrame`` or 2D np.ndarray
representing :math:`p`, as above
Returns
-------
``pd.DataFrame`` with same columns and index as ``self``
containing :math:`F_{X_{ij}}(x_{ij})`, as above
"""
p = np.array(p)
return self._boilerplate("_ppf", p=p)

def energy(self, x=None):
r"""Energy of self, w.r.t. self or a constant frame x.
Let :math:`X, Y` be i.i.d. random variables with the distribution of ``self``.
If ``x`` is ``None``, returns :math:`\mathbb{E}[|X-Y|]` (per row),
"self-energy".
If ``x`` is passed, returns :math:`\mathbb{E}[|X-x|]` (per row), "energy wrt x".
The CRPS is related to energy:
it holds that
:math:`\mbox{CRPS}(\mbox{self}, y)` = `self.energy(y) - 0.5 * self.energy()`.
Parameters
----------
x : None or pd.DataFrame, optional, default=None
if ``pd.DataFrame``, must have same rows and columns as ``self``
Returns
-------
``pd.DataFrame`` with same rows as ``self``, single column ``"energy"``
each row contains one float, self-energy/energy as described above.
"""
if x is None:
return self._boilerplate("_energy_self", columns=["energy"])
x = np.array(x)
return self._boilerplate("_energy_x", x=x, columns=["energy"])

0 comments on commit bfac335

Please sign in to comment.