@@ -0,0 +1,2703 @@
+/*%0A * This file is part of ELKI:%0A * Environment for Developing KDD-Applications Supported by Index-Structures%0A * %0A * Copyright (C) 2020%0A * ELKI Development Team%0A * %0A * This program is free software: you can redistribute it and/or modify%0A * it under the terms of the GNU Affero General Public License as published by%0A * the Free Software Foundation, either version 3 of the License, or%0A * (at your option) any later version.%0A * %0A * This program is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the%0A * GNU Affero General Public License for more details.%0A * %0A * You should have received a copy of the GNU Affero General Public License%0A * along with this program. If not, see %3Chttp://www.gnu.org/licenses/%3E.%0A */%0Apackage elki.evaluation.clustering;%0A%0Aimport elki.utilities.datastructures.KuhnMunkresStern;%0Aimport elki.utilities.documentation.Reference;%0A%0A/**%0A * Calculates the accuracy of a clustering based on the maximum set matching%0A * found by the Hungarian algorithm. The resulting runtime is O(k%C2%B3) for k%0A * clusters due to the matching algorithm.%0A * %3Cp%3E%0A * Reference:%0A * %3Cp%3E%0A * M. J. Zaki and W. Meira Jr.%3Cbr%3E%0A * Data Mining and Analysis: Fundamental Concepts and Algorithms%3Cbr%3E%0A * %0A * @author Robert Gehde%0A */%0A@Reference(authors = %22M. J. Zaki and W. Meira Jr.%22, //%0A    title = %22Data Mining and Analysis: Fundamental Concepts and Algorithms%22, //%0A    booktitle = %22%22, //%0A    url = %22http://www.dataminingbook.info/%22, //%0A    bibkey = %22DBLP:books/cu/ZM2014%22)%0Apublic class MaximumMatchingAccuracy %7B%0A  /**%0A   * Accuracy calculated with maximum matching%0A   */%0A  protected double accuracy;%0A%0A  /**%0A   * Calculate the maximum matching accuracy.%0A   *%0A   * @param table cluster contingency table%0A   */%0A  public MaximumMatchingAccuracy(ClusterContingencyTable table) %7B%0A    int%5B%5D%5B%5D cont = table.contingency;%0A    final int rowlen = table.size1, collen = table.size2;%0A    final int maxlen = Math.max(rowlen, collen);%0A    // convert to costs for minimum matching:%0A    double%5B%5D%5B%5D costs = new double%5Bmaxlen%5D%5Bmaxlen%5D;%0A    for(int i = 0; i %3C rowlen; i++) %7B%0A      for(int j = 0; j %3C collen; j++) %7B%0A        costs%5Bi%5D%5Bj%5D = -cont%5Bi%5D%5Bj%5D;%0A      %7D%0A    %7D%0A    int%5B%5D chosen = new KuhnMunkresStern().run(costs);%0A    // read off maximum matching%0A    double correctAssociations = 0;%0A    for(int i = 0; i %3C maxlen; i++) %7B%0A      correctAssociations += chosen%5Bi%5D %3C collen ? cont%5Bi%5D%5Bchosen%5Bi%5D%5D : 0;%0A    %7D%0A    accuracy = correctAssociations / cont%5Browlen%5D%5Bcollen%5D;%0A  %7D%0A%0A  /**%0A   * Get the maximum matching cluster accuracy.%0A   * %0A   * @return accuracy%0A   */%0A  public double getAccuracy() %7B%0A    return accuracy;%0A  %7D%0A%7D%0A

Add maximum matching cluster accuracy