nikrao commented on issue #7390: adding ranking metrics (precision/recall) at 
position K. 
URL: https://github.com/apache/incubator-mxnet/pull/7390#issuecomment-327367226
 
 
   hmm, maybe. since they are basically one-liners, does it make sense to have
   a separate class just for those? Free function sounds better.
   
   On Tue, Sep 5, 2017 at 10:27 AM, Haibin Lin <notificati...@github.com>
   wrote:
   
   > *@eric-haibin-lin* requested changes on this pull request.
   > ------------------------------
   >
   > In python/mxnet/metric.py
   > <https://github.com/apache/incubator-mxnet/pull/7390#discussion_r137061206>
   > :
   >
   > > +
   > +        Returns:
   > +        --------
   > +        The precision at K (float)
   > +        """
   > +        check_label_shapes(labels, preds)
   > +
   > +        for label, pred_label in zip(labels, preds):
   > +            assert(len(pred_label.shape) <= 2), 'Predictions should be no 
more than 2 dims'
   > +            pred_label = 
numpy.argsort(-pred_label.asnumpy().astype('float32'), axis=1)
   > +            label = label.asnumpy().astype('int32')
   > +            check_label_shapes(label, pred_label)
   > +            num_samples = pred_label.shape[0]
   > +            local_precision = 0.0
   > +            for s in range(num_samples):
   > +                truepos = set(numpy.ravel(numpy.argwhere(label[s, :] == 
1)))
   >
   > The logics to compute truepos and predpos are redundant in the two
   > classes. Could you refactor it as a free function so that the two classes
   > can call, or let the two classes inherit from an abstract class that has
   > such a method?
   >
   > ?
   > You are receiving this because you were mentioned.
   > Reply to this email directly, view it on GitHub
   > 
<https://github.com/apache/incubator-mxnet/pull/7390#pullrequestreview-60680759>,
   > or mute the thread
   > 
<https://github.com/notifications/unsubscribe-auth/ASlOLPZ4RUO0SuZFkSi_BC7aWkx3Og9hks5sfYSZgaJpZM4OxWiq>
   > .
   >
   
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to