Package edu.ucla.sspace.clustering.criterion

Examples of edu.ucla.sspace.clustering.criterion.CriterionFunction


                                  Matrix matrix, Matrix[] gapMatrices,
                                  double[] gapResults, double[] gapStds,
                                  Assignments[] gapAssignments) {
        int k = i+startSize;
        double numGaps = gapMatrices.length;
        CriterionFunction function =
            ReflectionUtil.getObjectInstance(methodName);
        verbose("Clustering reference data for %d clusters\n", k);

        // Compute the score for the reference data sets with k
        // clusters.
        double referenceScore = 0;
        double[] referenceScores = new double[gapMatrices.length];
        for (int j = 0; j < gapMatrices.length; ++j) {
            verbose("Clustering reference data %d \n", j);
            Assignments result = DirectClustering.cluster(
                    gapMatrices[j], k, 1, function);
            referenceScores[j] = Math.log(function.score());
            referenceScore += referenceScores[j];
        }
        referenceScore /= numGaps;

        // Compute the standard deviation for the reference scores.
        double referenceStdev = 0;
        for (double score : referenceScores)
            referenceStdev += Math.pow(score - referenceScore, 2);
        referenceStdev /= numGaps;
        referenceStdev = Math.sqrt(referenceStdev) * Math.sqrt(1 + 1/numGaps);

        verbose("Clustering original data for %d clusters\n", k);
        // Compute the score for the original data set with k
        // clusters.
        Assignments result = DirectClustering.cluster(
                matrix, k, 1, function);

        // Compute the difference between the two scores.  If the
        // current score is less than the previous score, then the
        // previous assignment is considered best.
        double gap = Math.log(function.score());
        verbose("Completed iteration with referenceScore: %f, gap:%f\n",
                referenceScore, gap);
        gap = referenceScore - gap;

        System.out.printf("k: %d gap: %f std: %f\n", i, gap, referenceStdev);
View Full Code Here


        // Get an instance of the seed generator.
        KMeansSeed seedType = ReflectionUtil.getObjectInstance(
                properties.getProperty(SEED_PROPERTY, DEFAULT_SEED));

        // Create the criterion function.
        CriterionFunction criterion = ReflectionUtil.getObjectInstance(
                properties.getProperty(CRITERIA_PROPERTY, DEFAULT_CRITERION));

        return cluster(matrix, numClusters, numRepetitions,
                       seedType, criterion);
    }
View Full Code Here

TOP

Related Classes of edu.ucla.sspace.clustering.criterion.CriterionFunction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.