Main Content

compact

Compact clustering evaluation object

    Description

    example

    compactEvaluation = compact(evaluation) returns a compact clustering evaluation object compactEvaluation, which contains a subset of the information about the clustering solution in the clustering evaluation object evaluation. Compacting a clustering evaluation object reduces the memory requirements of the object, which is useful when clustering a large data set.

    Examples

    collapse all

    Create a compact clustering evaluation object from a full clustering evaluation object.

    Load the fisheriris data set. The data contains length and width measurements from the sepals and petals of three species of iris flowers.

    load fisheriris

    Create a clustering evaluation object. Cluster the data using kmeans, and evaluate the optimal number of clusters using the gap criterion.

    rng("default") % For reproducibility
    evaluation = evalclusters(meas,"kmeans","gap","KList",1:6)
    evaluation = 
      GapEvaluation with properties:
    
        NumObservations: 150
             InspectedK: [1 2 3 4 5 6]
        CriterionValues: [0.0720 0.5928 0.8762 1.0114 1.0534 1.0720]
               OptimalK: 5
    
    
    

    Create a compact clustering evaluation object from evaluation.

    compactEvaluation = compact(evaluation)
    compactEvaluation = 
      GapEvaluation with properties:
    
        NumObservations: 150
             InspectedK: [1 2 3 4 5 6]
        CriterionValues: [0.0720 0.5928 0.8762 1.0114 1.0534 1.0720]
               OptimalK: 5
    
    
    

    The displayed output of the compact object compactEvaluation is the same as the original object evaluation, but some properties not shown in the display are different. For example, in the compact object, the properties X, OptimalY, and Missing are empty.

    Compare the optimal clustering solution property OptimalY of evaluation and compactEvaluation.

    evaluation.OptimalY
    ans = 150×1
    
         4
         4
         4
         4
         4
         4
         4
         4
         4
         4
          ⋮
    
    
    compactEvaluation.OptimalY
    ans =
    
         []
    

    Input Arguments

    collapse all

    Clustering evaluation data, specified as a CalinskiHarabaszEvaluation, DaviesBouldinEvaluation, GapEvaluation, or SilhouetteEvaluation clustering evaluation object. Create a clustering evaluation object by using evalclusters.

    Output Arguments

    collapse all

    Compact clustering evaluation object, returned as a CalinskiHarabaszEvaluation, DaviesBouldinEvaluation, GapEvaluation, or SilhouetteEvaluation clustering evaluation object. The compact object includes the clustering evaluation results. In the compact object, the properties are empty for the sample data X, the optimal clustering solution OptimalY, and the list of excluded observations Missing.

    Version History

    Introduced in R2013b