[MRG+1] Add sample_weight support to Dummy Regressor

sample_weight should be a numpy array

On Sun, Oct 19, 2014 at 12:26 PM, Saurabh Jha <notifications@github.com>
wrote:

> In sklearn/utils/stats.py:
>
> > @@ -44,3 +44,16 @@ def _rankdata(a, method="average"):
> >
> >  except TypeError as e:
> >      rankdata = _rankdata
> > +
> > +
> > +def _weighted_percentile(array, sample_weight, percentile=50):
> > +    """Compute the weighted ``percentile`` of ``array`` with ``sample_weight``. """
> > +    sorted_idx = np.argsort(array)
> > +
> > +    # Find index of median prediction for each sample
> > +    weight_cdf = sample_weight[sorted_idx].cumsum()
> > +    percentile_or_above = weight_cdf >= (percentile / 100.0) * weight_cdf[-1]
>
> Sorry for being stupid, but I am not able to get this to work. My
> arguments are [3, 2, 4] and [1, 2, 3] for array and sample_weight
> respectively. The sorted_idx is an array and thus throwing a TypeError. I
> wonder what are the expected arguments here.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/scikit-learn/scikit-learn/pull/3779/files#r19059282>.
>



-- 
Godspeed,
Manoj Kumar,
Intern, Telecom ParisTech
Mech Undergrad
http://manojbits.wordpress.com