Package org.encog.ml.kmeans

Examples of org.encog.ml.kmeans.KMeansClustering


    for (final double[] element : SimpleKMeans.DATA) {
      set.add(new BasicMLData(element));
    }

    final KMeansClustering kmeans = new KMeansClustering(2, set);

    kmeans.iteration(100);
    System.out.println("Final WCSS: " + kmeans.getWCSS());

    // Display the cluster
    int i = 1;
    for (final MLCluster cluster : kmeans.getClusters()) {
      System.out.println("*** Cluster " + (i++) + " ***");
      final MLDataSet ds = cluster.createDataSet();
      final MLDataPair pair = BasicMLDataPair.createPair(
          ds.getInputSize(), ds.getIdealSize());
      for (int j = 0; j < ds.getRecordCount(); j++) {
View Full Code Here


    final PrintWriter tw = this.prepareOutputFile(outputFile, analyst
        .getScript().getNormalize().countActiveFields() - 1, 1);

    resetStatus();

    final KMeansClustering cluster = new KMeansClustering(clusters,
        this.data);
    cluster.iteration(iterations);

    int clusterNum = 0;
    for (final MLCluster cl : cluster.getClusters()) {
      for (final MLData item : cl.getData()) {
        final ClusterRow row = (ClusterRow) item;
        final int clsIndex = row.getInput().size() - 1;
        final LoadedRow lr = row.getRow();
        lr.getData()[clsIndex] = "" + clusterNum;
View Full Code Here

    final PrintWriter tw = this.prepareOutputFile(outputFile, analyst
        .getScript().getNormalize().countActiveFields() - 1, 1);

    resetStatus();

    final KMeansClustering cluster = new KMeansClustering(clusters,
        this.data);
    cluster.iteration(iterations);

    int clusterNum = 0;
    for (final MLCluster cl : cluster.getClusters()) {
      for (final MLData item : cl.getData()) {
        final int clsIndex = item.size();
        final LoadedRow lr = new LoadedRow(this.getFormat(),item.getData(),1);
        lr.getData()[clsIndex] = "" + clusterNum;
        writeRow(tw, lr);
View Full Code Here

TOP

Related Classes of org.encog.ml.kmeans.KMeansClustering

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.