Skip to content

Commit

Permalink
DOC KDE normalisation clarified (#11275)
Browse files Browse the repository at this point in the history
  • Loading branch information
haroldfox authored and jnothman committed Oct 15, 2018
1 parent 0444def commit 16dba4e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions sklearn/neighbors/kde.py
Expand Up @@ -159,7 +159,9 @@ def score_samples(self, X):
Returns
-------
density : ndarray, shape (n_samples,)
The array of log(density) evaluations.
The array of log(density) evaluations. These are normalized to be
probability densities, so values will be low for high-dimensional
data.
"""
# The returned density is normalized to the number of points.
# For it to be a probability, we must scale it. For this reason
Expand All @@ -177,7 +179,7 @@ def score_samples(self, X):
return log_density

def score(self, X, y=None):
"""Compute the total log probability under the model.
"""Compute the total log probability density under the model.
Parameters
----------
Expand All @@ -188,7 +190,9 @@ def score(self, X, y=None):
Returns
-------
logprob : float
Total log-likelihood of the data in X.
Total log-likelihood of the data in X. This is normalized to be a
probability density, so the value will be low for high-dimensional
data.
"""
return np.sum(self.score_samples(X))

Expand Down

0 comments on commit 16dba4e

Please sign in to comment.