class_docstr: Learner for Sequence Taggers.
class_docstr_tok: ["Learner","for","Sequence","Taggers","."]
docstr: Validate text sequence taggers
docstr_tok: ["Validate","text","sequence","taggers"]
code: def validate(self, val_data=None, print_report=True, class_names=[]):
      """
      Validate text sequence taggers
      """
      val = self._check_val(val_data)
  
      if not val.prepare_called:
          val.prepare()
  
      if not U.is_ner(model=self.model, data=val):
          warnings.warn(
              "learner.validate_ner is only for sequence taggers."
          )
          return
  
      label_true = []
      label_pred = []
      for i in range(len(val)):
          x_true, y_true = val[i]
          # lengths = self.ner_lengths(y_true)
          lengths = val.get_lengths(i)
          y_pred = self.model.predict_on_batch(x_true)
  
          y_true = val.p.inverse_transform(y_true, lengths)
          y_pred = val.p.inverse_transform(y_pred, lengths)
  
          label_true.extend(y_true)
          label_pred.extend(y_pred)
  
      score = metrics.f1_score(label_true, label_pred)
      # acc = metrics.accuracy_score(label_true, label_pred)
      if print_report:
          print("   F1:  {:04.2f}".format(score * 100))
          # print('   ACC: {:04.2f}'.format(acc * 100))
          print(metrics.classification_report(label_true, label_pred))
  
      return score
  
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 2 for calling the NERLearner obj's underlying member method code with example usage: obj.validate(val_data, print_report, class_names) and returns: score