/usr/lib/python3/dist-packages/bimdp/biclassifier.py is in python3-mdp 3.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | import mdp
from . import binode
class BiClassifier(binode.BiNode, mdp.ClassifierNode):
"""BiMDP version of the ClassifierNode base class.
It enables that the classification results are returned by execute in the
message.
"""
def _execute(self, x, return_labels=None, return_probs=None,
return_ranks=None):
"""Return the unaltered x and classification results when requested.
return_labels -- If True then the 'label' method is called on the x
and the result is returned in the dict, with the key 'labels'. If
return_labels is a string then this is used as a prefix for the
'labels' key of the result.
return_probs, return_ranks -- Work like return_labels, but the results
are stored under the key 'probs' and 'ranks'.
"""
msg = {}
if return_labels:
if not isinstance(return_labels, str):
msg["labels"] = self.label(x)
else:
msg[return_labels + "labels"] = self.label(x)
if return_probs:
if not isinstance(return_probs, str):
msg["probs"] = self.prob(x)
else:
msg[return_probs + "probs"] = self.prob(x)
if return_ranks:
if not isinstance(return_ranks, str):
msg["ranks"] = self.rank(x)
else:
msg[return_ranks + "ranks"] = self.rank(x)
if msg:
return x, msg
else:
return x
|