Examples of KMeansClustering


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

Examples of org.encog.ml.kmeans.KMeansClustering

    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

Examples of org.encog.ml.kmeans.KMeansClustering

    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

Examples of stallone.cluster.KMeansClustering

        clustering.setMetric(metric);
    }

    public IClustering kmeans(IMetric<IDoubleArray> metric, int k, int maxIter)
    {
        KMeansClustering clustering = new KMeansClustering();
        kmeans(clustering, metric, k, maxIter);
        return (clustering);
    }
View Full Code Here

Examples of stallone.cluster.KMeansClustering

        return (clustering);
    }

    public IClustering kmeans(int k, int maxIter)
    {
        KMeansClustering clustering = new KMeansClustering();
        kmeans(clustering, new EuclideanDistance(), k, maxIter);
        return (clustering);
    }
View Full Code Here

Examples of stallone.cluster.KMeansClustering

        return (clustering);
    }

    public IClustering kmeans(int k)
    {
        KMeansClustering clustering = new KMeansClustering();
        kmeans(clustering, new EuclideanDistance(), k, 1000);
        return (clustering);
    }
View Full Code Here

Examples of stallone.cluster.KMeansClustering

        return kmeans(data, metric, k, maxIter);
    }

    public IClustering kmeans(IDataInput data, IMetric<IDoubleArray> metric, int k, int maxIter)
    {
        KMeansClustering clustering = new KMeansClustering();
        kmeans(clustering, data, metric, k, maxIter);
        return (clustering);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.