def predict(self, text, k=<NUM_LIT:1>, threshold=<NUM_LIT:0.0>, on_unicode_error='<STR_LIT:strict>'):
def check(entry):<EOL><INDENT>if entry.find('<STR_LIT:\n>') != -<NUM_LIT:1>:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>"<EOL>)<EOL><DEDENT>entry += "<STR_LIT:\n>"<EOL>return entry<EOL><DEDENT>if type(text) == list:<EOL><INDENT>text = [check(entry) for entry in text]<EOL>predictions = self.f.multilinePredict(text, k, threshold, on_unicode_error)<EOL>dt = np.dtype([('<STR_LIT>', '<STR_LIT>'), ('<STR_LIT:label>', '<STR_LIT:object>')])<EOL>result_as_pair = np.array(predictions, dtype=dt)<EOL>return result_as_pair['<STR_LIT:label>'].tolist(), result_as_pair['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>text = check(text)<EOL>predictions = self.f.predict(text, k, threshold, on_unicode_error)<EOL>probs, labels = zip(*predictions)<EOL>return labels, np.array(probs, copy=False)<EOL><DEDENT>
Given a string, get a list of labels and a list of
corresponding probabilities. k controls the number
of returned labels. A choice of 5, will return the 5
most probable labels. By default this returns only
the most likely label and probability. threshold filters
the returned labels by a threshold on probability. A
choice of 0.5 will return labels with at least 0.5
probability. k and threshold will be applied together to
determine the returned labels.

This function assumes to be given
a single line of text. We split words on whitespace (space,
newline, tab, vertical tab) and the control characters carriage
return, formfeed and the null character.

If the model is not supervised, this function will throw a ValueError.

If given a list of strings, it will return a list of results as usually
received for a single line of text.