All Downloads are FREE. Search and download functionalities are using the official Maven repository.

tech.tablesaw.api.ml.clustering.LinkageFactory Maven / Gradle / Ivy

There is a newer version: 0.32.1
Show newest version
package tech.tablesaw.api.ml.clustering;

import smile.clustering.linkage.CompleteLinkage;
import smile.clustering.linkage.Linkage;
import smile.clustering.linkage.SingleLinkage;
import smile.clustering.linkage.UPGMALinkage;
import smile.clustering.linkage.UPGMCLinkage;
import smile.clustering.linkage.WPGMALinkage;
import smile.clustering.linkage.WPGMCLinkage;
import smile.clustering.linkage.WardLinkage;

/**
 * Cluster dissimilarity measures. An agglomerative hierarchical clustering
 * builds the hierarchy from the individual elements by progressively merging
 * clusters. The linkage criteria determines the distance between clusters
 * (i.e. sets of observations) based on as a pairwise distance function between
 * observations. Some commonly used linkage criteria are:
 * 
    *
  • Maximum or complete linkage clustering (COMPLETE)
  • *
  • Minimum or single-linkage clustering (SINGLE)
  • *
  • Mean or average linkage clustering (UPGMA)
  • *
  • Unweighted Pair Group Method using Centroids (UPCMA). Also known as centroid linkage.
  • *
  • Weighted Pair Group Method with Arithmetic mean (WPGMA)
  • *
  • Weighted Pair Group Method using Centroids (WPGMC). Also known as median linkage.
  • *
  • Ward's linkage (WARD)
  • *
* * @author Haifeng Li (docs) and Chris Baker (code) * * @see linkage/package-info.java */ public class LinkageFactory { /** * Cluster dissimilarity measure */ public enum type { COMPLETE, SINGLE, UPGMA, UPGMC, WARD, WPGMA, WPGMC } /** * Create a Linkage object. * * @param proximity the proximity matrix to store the measures of * dissimilarity between each pair of observations/rows * @param linkageType the type of dissimilarity measure you would like * to use when determining which clusters to merge * * @return a measure of dissimilarity between clusters * * @see Linkage.java */ public Linkage createLinkage(double[][] proximity, type linkageType) { Linkage link; switch (linkageType) { case WARD: link = new WardLinkage(proximity); break; case COMPLETE: link = new CompleteLinkage(proximity); break; case SINGLE: link = new SingleLinkage(proximity); break; case UPGMA: link = new UPGMALinkage(proximity); break; case UPGMC: link = new UPGMCLinkage(proximity); break; case WPGMA: link = new WPGMALinkage(proximity); break; case WPGMC: link = new WPGMCLinkage(proximity); break; default: link = new SingleLinkage(proximity); break; } return link; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy