class_docstr: The label model by `FlyingSquid <https://github.com/HazyResearch/flyingsquid>`__.
  
  .. note:: It is not suited for multi-label classification and does not support it!
  
  Args:
      weak_labels: A `WeakLabels` object containing the weak labels and records.
      **kwargs: Passed on to the init of the FlyingSquid's
          `LabelModel <https://github.com/HazyResearch/flyingsquid/blob/master/flyingsquid/label_model.py#L18>`__.
  
  Examples:
      >>> from argilla.labeling.text_classification import WeakLabels
      >>> weak_labels = WeakLabels(dataset="my_dataset")
      >>> label_model = FlyingSquid(weak_labels)
      >>> label_model.fit()
      >>> records = label_model.predict()
class_docstr_tok: ["The","label","model","by","`","FlyingSquid","<","https",":","\/\/github.com\/HazyResearch\/flyingsquid",">","`","__",".","..","note",":",":","It","is","not","suited","for","multi-label","classification","and","does","not","support","it","!","Args",":","weak_labels",":","A","`","WeakLabels","`","object","containing","the","weak","labels","and","records",".","*","*","kwargs",":","Passed","on","to","the","init","of","the","FlyingSquid's","`","LabelModel","<","https",":","\/\/github.com\/HazyResearch\/flyingsquid\/blob\/master\/flyingsquid\/label_model.py","#","L18",">","`","__",".","Examples",":",">",">",">","from","argilla.labeling.text_classification","import","WeakLabels",">",">",">","weak_labels","=","WeakLabels","(","dataset=","''","my_dataset","''",")",">",">",">","label_model","=","FlyingSquid","(","weak_labels",")",">",">",">","label_model.fit","(",")",">",">",">","records","=","label_model.predict","(",")"]
docstr: Returns some scores/metrics of the label model with respect to the annotated records.
  
  The metrics are:
  
  - accuracy
  - micro/macro averages for precision, recall and f1
  - precision, recall, f1 and support for each label
  
  For more details about the metrics, check out the
  `sklearn docs <https://scikit-learn.org/stable/modules/generated/sklearn.metrics.precision_recall_fscore_support.html#sklearn-metrics-precision-recall-fscore-support>`__.
  
  .. note:: Metrics are only calculated over non-abstained predictions!
  
  Args:
      tie_break_policy: Policy to break ties. You can choose among two policies:
  
          - `abstain`: Do not provide any prediction
          - `random`: randomly choose among tied option using deterministic hash
  
          The last policy can introduce quite a bit of noise, especially when the tie is among many labels,
          as is the case when all the labeling functions (rules) abstained.
      verbose: If True, print out messages of the progress to stderr.
      output_str: If True, return output as nicely formatted string.
  
  Returns:
      The scores/metrics in a dictionary or as a nicely formatted str.
  
  Raises:
      NotFittedError: If the label model was still not fitted.
      MissingAnnotationError: If the ``weak_labels`` do not contain annotated records.
docstr_tok: ["Returns","some","scores\/metrics","of","the","label","model","with","respect","to","the","annotated","records",".","The","metrics","are",":","-","accuracy","-","micro\/macro","averages","for","precision",",","recall","and","f1","-","precision",",","recall",",","f1","and","support","for","each","label","For","more","details","about","the","metrics",",","check","out","the","`","sklearn","docs","<","https",":","\/\/scikit-learn.org\/stable\/modules\/generated\/sklearn.metrics.precision_recall_fscore_support.html","#","sklearn-metrics-precision-recall-fscore-support",">","`","__",".","..","note",":",":","Metrics","are","only","calculated","over","non-abstained","predictions","!","Args",":","tie_break_policy",":","Policy","to","break","ties",".","You","can","choose","among","two","policies",":","-","`","abstain","`",":","Do","not","provide","any","prediction","-","`","random","`",":","randomly","choose","among","tied","option","using","deterministic","hash","The","last","policy","can","introduce","quite","a","bit","of","noise",",","especially","when","the","tie","is","among","many","labels",",","as","is","the","case","when","all","the","labeling","functions","(","rules",")","abstained",".","verbose",":","If","True",",","print","out","messages","of","the","progress","to","stderr",".","output_str",":","If","True",",","return","output","as","nicely","formatted","string",".","Returns",":","The","scores\/metrics","in","a","dictionary","or","as","a","nicely","formatted","str",".","Raises",":","NotFittedError",":","If","the","label","model","was","still","not","fitted",".","MissingAnnotationError",":","If","the","``","weak_labels","``","do","not","contain","annotated","records","."]
code: def score(
      self,
      tie_break_policy: Union[TieBreakPolicy, str] = "abstain",
      verbose: bool = False,
      output_str: bool = False,
  ) -> Union[Dict[str, float], str]:
      """Returns some scores/metrics of the label model with respect to the annotated records.
  
      The metrics are:
  
      - accuracy
      - micro/macro averages for precision, recall and f1
      - precision, recall, f1 and support for each label
  
      For more details about the metrics, check out the
      `sklearn docs <https://scikit-learn.org/stable/modules/generated/sklearn.metrics.precision_recall_fscore_support.html#sklearn-metrics-precision-recall-fscore-support>`__.
  
      .. note:: Metrics are only calculated over non-abstained predictions!
  
      Args:
          tie_break_policy: Policy to break ties. You can choose among two policies:
  
              - `abstain`: Do not provide any prediction
              - `random`: randomly choose among tied option using deterministic hash
  
              The last policy can introduce quite a bit of noise, especially when the tie is among many labels,
              as is the case when all the labeling functions (rules) abstained.
          verbose: If True, print out messages of the progress to stderr.
          output_str: If True, return output as nicely formatted string.
  
      Returns:
          The scores/metrics in a dictionary or as a nicely formatted str.
  
      Raises:
          NotFittedError: If the label model was still not fitted.
          MissingAnnotationError: If the ``weak_labels`` do not contain annotated records.
      """
      from sklearn.metrics import classification_report
  
      if isinstance(tie_break_policy, str):
          tie_break_policy = TieBreakPolicy(tie_break_policy)
  
      wl_matrix = self._weak_labels.matrix(has_annotation=True)
      probabilities = self._predict(wl_matrix, verbose)
  
      # 1.e-8 is taken from the abs tolerance of np.isclose
      is_max = (
          np.abs(
              probabilities.max(axis=1, keepdims=True) - probabilities
          )
          < 1.0e-8
      )
      is_tie = is_max.sum(axis=1) > 1
  
      prediction = np.argmax(is_max, axis=1)
      # we need to transform the indexes!
      annotation = np.array(
          [
              self._weak_labels.labels.index(
                  self._weak_labels.int2label[i]
              )
              for i in self._weak_labels.annotation()
          ],
          dtype=np.short,
      )
  
      if not is_tie.any():
          pass
      # resolve ties
      elif tie_break_policy is TieBreakPolicy.ABSTAIN:
          prediction, annotation = (
              prediction[~is_tie],
              annotation[~is_tie],
          )
      elif tie_break_policy is TieBreakPolicy.RANDOM:
          for i in np.nonzero(is_tie)[0]:
              equal_prob_idx = np.nonzero(is_max[i])[0]
              random_idx = int(
                  hashlib.sha1(f"{i}".encode()).hexdigest(), 16
              ) % len(equal_prob_idx)
              prediction[i] = equal_prob_idx[random_idx]
      else:
          raise NotImplementedError(
              f"The tie break policy '{tie_break_policy.value}' is not implemented for FlyingSquid!"
          )
  
      return classification_report(
          annotation,
          prediction,
          target_names=self._weak_labels.labels[: annotation.max() + 1],
          output_dict=not output_str,
      )
  
imports: import hashlib
  import logging
  from enum import Enum
  from typing import Dict, List, Tuple, Union
  import numpy
  from argilla import DatasetForTextClassification, TextClassificationRecord
  from argilla.labeling.text_classification.weak_labels import WeakLabels, WeakMultiLabels
  from argilla.utils.dependency import requires_dependencies
label_desc: Use image node_id 6 for calling the FlyingSquid obj's underlying member method code with example usage: obj.score(tie_break_policy, verbose, output_str) and returns: classification_report