Codota Logo
AssignKMeans_F64
Code IndexAdd Codota to your IDE (free)

How to use
AssignKMeans_F64
in
org.ddogleg.clustering.kmeans

Best Java code snippets using org.ddogleg.clustering.kmeans.AssignKMeans_F64 (Showing top 8 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Dictionary d =
  • Codota Iconnew Hashtable()
  • Codota IconBundle bundle;bundle.getHeaders()
  • Codota Iconnew Properties()
  • Smart code suggestions by Codota
}
origin: org.ddogleg/ddogleg

@Override
public AssignCluster<double[]> copy() {
  return new AssignKMeans_F64(this);
}
origin: lessthanoptimal/ddogleg

@Test
public void assign() {
  List<double[]> clusters = new ArrayList<double[]>();
  clusters.add( new double[]{10,0,0});
  clusters.add( new double[]{0,0,10});
  AssignKMeans_F64 alg = new AssignKMeans_F64(clusters);
  assertEquals(1,alg.assign(new double[]{0,0,9}));
  assertEquals(0, alg.assign(new double[]{12, 0, 0}));
}
origin: lessthanoptimal/ddogleg

  @Test
  public void copy() {
    List<double[]> clusters = new ArrayList<double[]>();

    clusters.add( new double[]{10,0,0});
    clusters.add( new double[]{0,0,10});

    AssignKMeans_F64 original = new AssignKMeans_F64(clusters);
    AssignKMeans_F64 copy = (AssignKMeans_F64)original.copy();

    assertEquals(original.clusters.size(),copy.clusters.size());

    for (int i = 0; i < original.clusters.size(); i++) {
      double[] o = original.clusters.get(i);
      double[] c = copy.clusters.get(i);

      assertTrue(o!=c);

      for (int j = 0; j < o.length; j++) {
        assertEquals(o[j],c[j],1e-8);
      }
    }

  }
}
origin: lessthanoptimal/ddogleg

@Test
public void assign_soft() {
  List<double[]> clusters = new ArrayList<double[]>();
  clusters.add( new double[]{10,0,0});
  clusters.add( new double[]{5,0,0});
  AssignKMeans_F64 alg = new AssignKMeans_F64(clusters);
  double histogram[] = new double[2];
  alg.assign(new double[]{10,0,0},histogram);
  assertEquals(1.0, histogram[0], 1e-8);
  assertEquals(0.0, histogram[1],1e-8);
  // see if much more weight is given to the second one
  alg.assign(new double[]{6, 0, 0}, histogram);
  assertTrue(histogram[0]*10 < histogram[1]);
  // this is actually a difficult case for using this type of distance metric
  // one cluster is much farther away and as a result the weight is equality split between the two closer points
  // which might not be desirable
  clusters.add( new double[]{5000,0,0});
  histogram = new double[3];
  alg.assign(new double[]{6,0,0},histogram);
  assertTrue(histogram[0]/30.0 > histogram[2]);
  assertEquals(histogram[0], histogram[1], 0.01);
}
origin: lessthanoptimal/ddogleg

@Override
public AssignCluster<double[]> copy() {
  return new AssignKMeans_F64(this);
}
origin: org.ddogleg/ddogleg

@Override
public AssignCluster<double[]> getAssignment() {
  // creating a new list here to make serialization easier
  List<double[]> list = new ArrayList<double[]>();
  list.addAll( bestClusters.toList() );
  return new AssignKMeans_F64(list);
}
origin: lessthanoptimal/ddogleg

@Override
public AssignCluster<double[]> getAssignment() {
  // creating a new list here to make serialization easier
  List<double[]> list = new ArrayList<double[]>();
  list.addAll( bestClusters.toList() );
  return new AssignKMeans_F64(list);
}
origin: lessthanoptimal/ddogleg

  @Test
  public void serialize() {

    List<double[]> clusters = new ArrayList<double[]>();

    clusters.add( new double[]{10,0,0});
    clusters.add( new double[]{0,0,10});

    AssignKMeans_F64 alg = new AssignKMeans_F64(clusters);

    byte[] encoded = save(alg);

//        AssignKMeans_F64 found = load( encoded );
  }

org.ddogleg.clustering.kmeansAssignKMeans_F64

Javadoc

Implementation of org.ddogleg.clustering.AssignCluster for K-Means. Euclidean distance squared is used to select the best fit clusters to a point. This distance metric works well for hard assignment but can produce undesirable results for soft assignment, see JavaDoc.

Most used methods

  • <init>
  • assign
    Soft assignment is done by summing the total distance of the point from each cluster. Then for each
  • copy

Popular in Java

  • Start an intent from android
  • getSupportFragmentManager (FragmentActivity)
  • getExternalFilesDir (Context)
  • getResourceAsStream (ClassLoader)
    Returns a stream for the resource with the specified name. See #getResource(String) for a descriptio
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement.A servlet is a small Java program that runs within
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • JList (javax.swing)
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registery of org.quartz
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now