com.davidbracewell.apollo.stat.measure.Agreement Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of apollo Show documentation
Show all versions of apollo Show documentation
A machine learning library for Java.
The newest version!
package com.davidbracewell.apollo.stat.measure;
import com.davidbracewell.guava.common.base.Preconditions;
import lombok.NonNull;
/**
* @author David B. Bracewell
*/
public enum Agreement implements ContingencyTableCalculator {
Cohen_Kappa {
@Override
public double calculate(@NonNull ContingencyTable table) {
Preconditions.checkArgument(table.columnCount() == 2
&& table.rowCount() == 2,
"Only 2x2 tables supported");
double sum = table.getSum();
double sumSq = sum * sum;
double Po = (table.get(0, 0) + table.get(1, 1)) / sum;
double Pe = ((table.columnSum(0) * table.rowSum(0)) / sumSq)
+ ((table.columnSum(1) * table.rowSum(1)) / sumSq);
return (Po - Pe) / (1.0 - Pe);
}
};
}// END OF Agreement
© 2015 - 2025 Weber Informatics LLC | Privacy Policy