Codota Logo
ICodingAnnotationStudy.getRaterCount
Code IndexAdd Codota to your IDE (free)

How to use
getRaterCount
method
in
de.tudarmstadt.ukp.dkpro.statistics.agreement.coding.ICodingAnnotationStudy

Best Java code snippets using de.tudarmstadt.ukp.dkpro.statistics.agreement.coding.ICodingAnnotationStudy.getRaterCount (Showing top 13 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
OutputStreamWriter o =
  • Codota IconOutputStream out;new OutputStreamWriter(out)
  • Codota IconOutputStream out;String charsetName;new OutputStreamWriter(out, charsetName)
  • Codota IconHttpURLConnection connection;new OutputStreamWriter(connection.getOutputStream())
  • Smart code suggestions by Codota
}
origin: de.tudarmstadt.ukp.dkpro.statistics/dkpro-statistics-agreement

protected void ensureTwoRaters() {
  if (study.getRaterCount() != 2)
    throw new IllegalArgumentException("This agreement measure is only "
        + "applicable for annotation studies with two raters!");
}
origin: de.tudarmstadt.ukp.dkpro.statistics/dkpro-statistics-agreement

/** Calculates the expected inter-rater agreement that assumes the same
 *  distribution for all raters and annotations. 
 *  @throws NullPointerException if the annotation study is null. 
 *  @throws ArithmeticException if there are no items in the 
 *      annotation study. */
@Override
public double calculateExpectedAgreement() {
  Map<Object, int[]> annotationsPerCategory 
      = CodingAnnotationStudy.countAnnotationsPerCategory(study);
  BigDecimal result = new BigDecimal(0);
  for (Object category : study.getCategories()) {
    int[] annotationCounts = annotationsPerCategory.get(category);
    for (int m = 0; m < study.getRaterCount(); m++)
      for (int n = m + 1; n < study.getRaterCount(); n++)
        result = result.add(new BigDecimal(annotationCounts[m])
            .multiply(new BigDecimal(annotationCounts[n])));
  }
  result = result.multiply(new BigDecimal(2));
  result = result.divide(new BigDecimal(study.getRaterCount())
      .multiply(new BigDecimal(study.getRaterCount() - 1))
      .multiply(new BigDecimal(study.getItemCount()).pow(2)), 
      MathContext.DECIMAL128);
  return result.doubleValue();
}
origin: de.tudarmstadt.ukp.dkpro.statistics/dkpro-statistics-agreement

protected double calculateMaximumObservedAgreement() {
  Map<Object, int[]> annotationsPerCategory 
      = CodingAnnotationStudy.countAnnotationsPerCategory(study);
  BigDecimal result = new BigDecimal(0);
  for (Object category : study.getCategories()) {
    int[] annotations = annotationsPerCategory.get(category);
    int min = -1;
    for (int rater = 0; rater < study.getRaterCount(); rater++)
      if (annotations[rater] < min || min < 0)
        min = annotations[rater];
    if (min > 0)
      result = result.add(new BigDecimal(min));
  }
  result = result.divide(new BigDecimal(study.getItemCount()), MathContext.DECIMAL128);
  return result.doubleValue();
}
origin: de.tudarmstadt.ukp.dkpro.statistics/dkpro-statistics-agreement

/** Calculates the expected inter-rater agreement that assumes a 
 *  different probability distribution for all raters. 
 *  @throws NullPointerException if the annotation study is null. 
 *  @throws ArithmeticException if there are no items in the 
 *      annotation study. */
@Override
public double calculateExpectedAgreement() {
  Map<Object, int[]> annotationsPerCategory 
      = CodingAnnotationStudy.countAnnotationsPerCategory(study);
  
  BigDecimal result = new BigDecimal(0);
  for (Object category : study.getCategories()) {
    int[] annotations = annotationsPerCategory.get(category);
    BigDecimal prod = new BigDecimal(1);
    for (int rater = 0; rater < study.getRaterCount(); rater++)
      prod = prod.multiply(new BigDecimal(annotations[rater]));
    result = result.add(prod);
  }
  result = result.divide(new BigDecimal(study.getItemCount()).pow(2), MathContext.DECIMAL128);
  return result.doubleValue();
}
 
origin: de.tudarmstadt.ukp.dkpro.statistics/dkpro-statistics-agreement

/** Calculates the observed inter-rater agreement for the annotation 
 *  study that was passed to the class constructor and the currently
 *  assigned distance function.
 *  @throws NullPointerException if the study is null.
 *  @throws ArithmeticException if the study does not contain any item or
 *      the number of raters is smaller than 2. */
public double calculateObservedDisagreement() {
  ensureDistanceFunction();
  
  double result = 0.0;
  for (ICodingAnnotationItem item : study.getItems()) {
    Map<Object, Integer> annotationsPerCategory 
        = CodingAnnotationStudy.countTotalAnnotationsPerCategory(item);
          
    for (Entry<Object, Integer> category1 : annotationsPerCategory.entrySet())
      for (Entry<Object, Integer> category2 : annotationsPerCategory.entrySet()) {
        if (category1.getValue() == null)
          continue;
        if (category2.getValue() == null)
          continue;
        
        result += category1.getValue() * category2.getValue()
            * distanceFunction.measureDistance(study, 
                category1.getKey(), category2.getKey());
      }
  }
  result /= (double) (study.getItemCount() * study.getRaterCount() 
      * (study.getRaterCount() - 1));
  return result;
}
origin: de.tudarmstadt.ukp.dkpro.statistics/dkpro-statistics-agreement

/** Returns a two-dimensional map of categories and raters and the
 *  corresponding usage frequencies in the given annotation study 
 *  (i.e., how often a certain rater used a certain category for
 *  coding an annotation unit). */
// Category x Rater -> #
public static Map<Object, int[]> countAnnotationsPerCategory(
    final ICodingAnnotationStudy study) {
  Map<Object, int[]> result = new HashMap<Object, int[]>();
  for (ICodingAnnotationItem item : study.getItems())
    for (IAnnotationUnit unit : item.getUnits()) {
      Object category = unit.getCategory();
      if (category == null)
        continue;
      
      int[] counts = result.get(category);
      if (counts == null)
        counts = new int[study.getRaterCount()];
      counts[unit.getRaterIdx()]++;
      result.put(category, counts);
    }
  return result;
}
origin: de.tudarmstadt.ukp.dkpro.statistics/dkpro-statistics-agreement

if (study.getRaterCount() > 2)
  throw new IllegalArgumentException("Contingency tables are only applicable for two rater studies.");
origin: de.tudarmstadt.ukp.dkpro.statistics/dkpro-statistics-agreement

/** Calculates the expected inter-rater agreement using the defined 
 *  distance function to infer the assumed probability distribution. 
 *  @throws NullPointerException if the annotation study is null. 
 *  @throws ArithmeticException if there are no items or raters in the 
 *      annotation study. */
public double calculateExpectedDisagreement() {
  ensureDistanceFunction();
  
  double result = 0.0;
  Map<Object, Integer> annotationsPerCategory 
      = CodingAnnotationStudy.countTotalAnnotationsPerCategory(study);
  
  for (Object category1 : study.getCategories())
    for (Object category2 : study.getCategories())
      result += annotationsPerCategory.get(category1)
          * annotationsPerCategory.get(category2)
          * distanceFunction.measureDistance(study, category1, category2);
    
  result /= (double) (study.getItemCount() * study.getRaterCount() 
      * (study.getItemCount() * study.getRaterCount() - 1));
  return result;
}

origin: de.tudarmstadt.ukp.dkpro.statistics/dkpro-statistics-agreement

* study.getRaterCount() * (study.getRaterCount() - 1));
origin: de.tudarmstadt.ukp.dkpro.statistics/dkpro-statistics-agreement

out.println();
for (int r = 0; r < study.getRaterCount(); r++) {
  out.print(r + 1);
  for (ICodingAnnotationItem item : study.getItems())
origin: de.tudarmstadt.ukp.dkpro.statistics/dkpro-statistics-agreement

@Override
public double calculateCategoryAgreement(final Object category) {
  // N = # subjects = #items -> index i
  // n = # ratings/subject = #raters
  // k = # categories -> index j
  // n_ij = # raters that annotated item i as category j
  // 		
  // k_j = (P_j - p_j) / (1 - p_j)
  // P_j = (sum( n_ij^2 ) - N n p_j) / (N n (n-1) p_j )
  // p_j = 1/Nn sum n_ij  
  int N = study.getItemCount();
  int n = study.getRaterCount();
  int sum_nij = 0;
  int sum_nij_2 = 0;
  for (ICodingAnnotationItem item : study.getItems()) {
    int nij = 0;
    for (IAnnotationUnit unit : item.getUnits())
      if (unit.getCategory().equals(category))
        nij++;
    sum_nij += nij;
    sum_nij_2 += (nij * nij);
  }
    
  double pj = 1 / (double) (N * n) * sum_nij;
  double Pj = (sum_nij_2 - N * n * pj) / (double) (N * n * (n - 1) * pj);
  double kappaj = (Pj - pj) / (double) (1 - pj);
  return kappaj;
}
 
origin: de.tudarmstadt.ukp.dkpro.statistics/dkpro-statistics-agreement

public double calculateCategoryAgreement(final Object category) {
  // N = # subjects = #items -> index i
  // n = # ratings/subject = #raters
  // k = # categories -> index j
  // n_ij = # raters that annotated item i as category j
  // 		
  // k_j = (P_j - p_j) / (1 - p_j)
  // P_j = (sum( n_ij^2 ) - N n p_j) / (N n (n-1) p_j )
  // p_j = 1/Nn sum n_ij  
  int N = study.getItemCount();
  int n = study.getRaterCount();
  int sum_nij = 0;
  int sum_nij_2 = 0;
  for (ICodingAnnotationItem item : study.getItems()) {
    int nij = 0;
    for (IAnnotationUnit annotation : item.getUnits())
      if (annotation.getCategory().equals(category))
        nij++;
    sum_nij += nij;
    sum_nij_2 += (nij * nij);
  }
    
  double pj = 1 / (double) (N * n) * sum_nij;
  double Pj = (sum_nij_2 - N * n * pj) / (double) (N * n * (n - 1) * pj);
  double kappaj = (Pj - pj) / (double) (1 - pj);
  return kappaj;
}
 
origin: de.tudarmstadt.ukp.dkpro.statistics/dkpro-statistics-agreement

    * study.getRaterCount() * (study.getRaterCount() - 1);
    + nNullCategorySum * nKeepCategorySum * distanceFunction.measureDistance(study, NULL_CATEGORY, category)
    + nNullCategorySum * nNullCategorySum * distanceFunction.measureDistance(study, NULL_CATEGORY, NULL_CATEGORY);
expectedDisagreement /= (double) study.getItemCount() * study.getRaterCount() 
    * (study.getItemCount() * study.getRaterCount() - 1);
de.tudarmstadt.ukp.dkpro.statistics.agreement.codingICodingAnnotationStudygetRaterCount

Popular methods of ICodingAnnotationStudy

  • getCategoryCount
  • getItemCount
    Returns the number of annotation items defined by the study.
  • getItems
    Allows iterating all annotation items of this study.
  • getCategories
  • getItem
    Returns the annotation item with the given index. The first item has index 0.
  • hasMissingValues
    Returns true if, and only if, the annotation study contains at least one item with a missing value (

Popular in Java

  • Finding current android device location
  • onRequestPermissionsResult (Fragment)
  • runOnUiThread (Activity)
  • findViewById (Activity)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • KeyStore (java.security)
    This class represents an in-memory collection of keys and certificates. It manages two types of entr
  • Stack (java.util)
    The Stack class represents a last-in-first-out (LIFO) stack of objects. It extends class Vector with
  • ImageIO (javax.imageio)
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now