sklearn.utils.extmath.weighted_mode(a, w, axis=0)
[source]
Returns an array of the weighted modal (most common) value in a
If there is more than one such value, only the first is returned. The bincount for the modal bins is also returned.
This is an extension of the algorithm in scipy.stats.mode.
Parameters: 


Returns: 

See also
>>> from sklearn.utils.extmath import weighted_mode >>> x = [4, 1, 4, 2, 4, 2] >>> weights = [1, 1, 1, 1, 1, 1] >>> weighted_mode(x, weights) (array([4.]), array([3.]))
The value 4 appears three times: with uniform weights, the result is simply the mode of the distribution.
>>> weights = [1, 3, 0.5, 1.5, 1, 2] # deweight the 4's >>> weighted_mode(x, weights) (array([2.]), array([3.5]))
The value 2 has the highest score: it appears twice with weights of 1.5 and 2: the sum of these is 3.
© 2007–2018 The scikitlearn developers
Licensed under the 3clause BSD License.
http://scikitlearn.org/stable/modules/generated/sklearn.utils.extmath.weighted_mode.html