class_docstr: Represents an annotation task, i.e. people assign labels to items.
  
  Notation tries to match notation in Artstein and Poesio (2007).
  
  In general, coders and items can be represented as any hashable object.
  Integers, for example, are fine, though strings are more readable.
  Labels must support the distance functions applied to them, so e.g.
  a string-edit-distance makes no sense if your labels are integers,
  whereas interval distance needs numeric values.  A notable case of this
  is the MASI metric, which requires Python sets.
class_docstr_tok: ["Represents","an","annotation","task",",","i.e",".","people","assign","labels","to","items",".","Notation","tries","to","match","notation","in","Artstein","and","Poesio","(","2007",")",".","In","general",",","coders","and","items","can","be","represented","as","any","hashable","object",".","Integers",",","for","example",",","are","fine",",","though","strings","are","more","readable",".","Labels","must","support","the","distance","functions","applied","to","them",",","so","e.g",".","a","string-edit-distance","makes","no","sense","if","your","labels","are","integers",",","whereas","interval","distance","needs","numeric","values",".","A","notable","case","of","this","is","the","MASI","metric",",","which","requires","Python","sets","."]
docstr: Krippendorff 1980
docstr_tok: ["Krippendorff","1980"]
code: def alpha(self):
      """Krippendorff 1980"""
      # check for degenerate cases
      if len(self.K) == 0:
          raise ValueError("Cannot calculate alpha, no data present!")
      if len(self.K) == 1:
          log.debug("Only one annotation value, alpha returning 1.")
          return 1
      if len(self.C) == 1 and len(self.I) == 1:
          raise ValueError(
              "Cannot calculate alpha, only one coder and item present!"
          )
  
      total_disagreement = 0.0
      total_ratings = 0
      all_valid_labels_freq = FreqDist([])
  
      total_do = 0.0  # Total observed disagreement for all items.
      for i, itemdata in self._grouped_data("item"):
          label_freqs = FreqDist(x["labels"] for x in itemdata)
          labels_count = sum(label_freqs.values())
          if labels_count < 2:
              # Ignore the item.
              continue
          all_valid_labels_freq += label_freqs
          total_do += self.Disagreement(label_freqs) * labels_count
  
      do = total_do / sum(all_valid_labels_freq.values())
  
      de = self.Disagreement(
          all_valid_labels_freq
      )  # Expected disagreement.
      k_alpha = 1.0 - do / de
  
      return k_alpha
  
imports: import logging
  from itertools import groupby
  from operator import itemgetter
  from nltk.internals import deprecated
  from nltk.metrics.distance import binary_distance
  from nltk.probability import ConditionalFreqDist, FreqDist
label_desc: Use image node_id 22 for calling the AnnotationTask obj's underlying member method code with example usage: obj.alpha() and returns: k_alpha, int