class_docstr: Learner for Sequence Taggers.
class_docstr_tok: ["Learner","for","Sequence","Taggers","."]
docstr: Views observations with top losses in validation set.
  Args:
   n(int or tuple): a range to select in form of int or tuple
                    e.g., n=8 is treated as n=(0,8)
   preproc (Preprocessor): A TextPreprocessor or ImagePreprocessor.
                           For some data like text data, a preprocessor
                           is required to undo the pre-processing
                           to correctly view raw data.
    val_data:  optional val_data to use instead of self.val_data
  Returns:
      list of n tuples where first element is either
      filepath or id of validation example and second element
      is loss.
docstr_tok: ["Views","observations","with","top","losses","in","validation","set",".","Args",":","n","(","int","or","tuple",")",":","a","range","to","select","in","form","of","int","or","tuple","e.g.",",","n=8","is","treated","as","n=","(","0,8",")","preproc","(","Preprocessor",")",":","A","TextPreprocessor","or","ImagePreprocessor",".","For","some","data","like","text","data",",","a","preprocessor","is","required","to","undo","the","pre-processing","to","correctly","view","raw","data",".","val_data",":","optional","val_data","to","use","instead","of","self.val_data","Returns",":","list","of","n","tuples","where","first","element","is","either","filepath","or","id","of","validation","example","and","second","element","is","loss","."]
code: def view_top_losses(self, n=4, preproc=None, val_data=None):
      """
      Views observations with top losses in validation set.
      Args:
       n(int or tuple): a range to select in form of int or tuple
                        e.g., n=8 is treated as n=(0,8)
       preproc (Preprocessor): A TextPreprocessor or ImagePreprocessor.
                               For some data like text data, a preprocessor
                               is required to undo the pre-processing
                               to correctly view raw data.
        val_data:  optional val_data to use instead of self.val_data
      Returns:
          list of n tuples where first element is either
          filepath or id of validation example and second element
          is loss.
  
      """
  
      # check validation data and arguments
      val = self._check_val(val_data)
  
      tups = self.top_losses(n=n, val_data=val)
  
      # get multilabel status and class names
      classes = preproc.get_classes() if preproc is not None else None
  
      # iterate through losses
      for tup in tups:
          # get data
          idx = tup[0]
          loss = tup[1]
          truth = tup[2]
          pred = tup[3]
  
          seq = val.x[idx]
          print("total incorrect: %s" % (loss))
          print("{:15} {:5}: ({})".format("Word", "True", "Pred"))
          print("=" * 30)
          for w, true_tag, pred_tag in zip(seq, truth, pred):
              print("{:15}:{:5} ({})".format(w, true_tag, pred_tag))
          print("\n")
      return
  
file_path: ktrain/ktrain/text/ner/learner.py
imports: from ...None import utils
  from ...core import GenLearner
  from ...imports import *
  from .None import metrics
label_desc: Use image node_id 4 for calling the NERLearner obj's underlying member method code with example usage: obj.view_top_losses(n, preproc, val_data) without return types