Package com.heatonresearch.aifh.general.data

Examples of com.heatonresearch.aifh.general.data.BasicData


*/
public class TestKMeans {

    public static List<BasicData> getDataSet() {
        final List<BasicData> result = new ArrayList<BasicData>();
        result.add(new BasicData(new double[]{0, 0}, "a"));
        result.add(new BasicData(new double[]{0, 1}, "a"));
        result.add(new BasicData(new double[]{1, 0}, "a"));
        result.add(new BasicData(new double[]{100, 100}, "b"));
        result.add(new BasicData(new double[]{99, 100}, "b"));
        result.add(new BasicData(new double[]{100, 99}, "b"));
        result.add(new BasicData(new double[]{0, 100}, "c"));
        result.add(new BasicData(new double[]{1, 100}, "c"));
        result.add(new BasicData(new double[]{0, 99}, "c"));
        result.add(new BasicData(new double[]{100, 0}, "d"));
        result.add(new BasicData(new double[]{100, 1}, "d"));
        result.add(new BasicData(new double[]{99, 0}, "d"));


        return result;
    }
View Full Code Here


    }

    @Test(expected = AIFHError.class)
    public void testNoDimension() {
        final List<BasicData> list = new ArrayList<BasicData>();
        list.add(new BasicData(0));
        final KMeans kmeans = new KMeans(3);
        kmeans.initForgy(list);
    }
View Full Code Here

        final Cluster cluster = new Cluster(3);
        final double[] ob1 = {2.0, 10.0, 100.0};
        final double[] ob2 = {4.0, 20.0, 200.0};
        final double[] ob3 = {6.0, 30.0, 300.0};

        cluster.getObservations().add(new BasicData(ob1));
        cluster.getObservations().add(new BasicData(ob2));
        cluster.getObservations().add(new BasicData(ob3));

        assertEquals(3, cluster.getObservations().size());

        cluster.calculateCenter();
View Full Code Here

        final int dimensions = getHeaderCount() - 1;

        for (int rowIndex = 0; rowIndex < size(); rowIndex++) {
            final Object[] raw = this.data.get(rowIndex);
            final BasicData row = new BasicData(dimensions, 0, raw[labelIndex].toString());

            int colIndex = 0;
            for (int rawColIndex = 0; rawColIndex < getHeaderCount(); rawColIndex++) {
                if (rawColIndex != labelIndex) {
                    row.getInput()[colIndex++] = convertNumeric(raw, rawColIndex);
                }
            }

            result.add(row);
        }
View Full Code Here

    public List<BasicData> extractSupervised(final int inputBegin, final int inputCount, final int idealBegin, final int idealCount) {
        final List<BasicData> result = new ArrayList<BasicData>();

        for (int rowIndex = 0; rowIndex < size(); rowIndex++) {
            final Object[] raw = this.data.get(rowIndex);
            final BasicData row = new BasicData(inputCount, idealCount);

            for (int i = 0; i < inputCount; i++) {
                row.getInput()[i] = convertNumeric(raw, inputBegin + i);
            }

            for (int i = 0; i < idealCount; i++) {
                row.getIdeal()[i] = convertNumeric(raw, idealBegin + i);
            }

            result.add(row);
        }
View Full Code Here

        final int dimensions = getHeaderCount() - 1;

        for (int rowIndex = 0; rowIndex < size(); rowIndex++) {
            final Object[] raw = this.data.get(rowIndex);
            final BasicData row = new BasicData(dimensions, 0, raw[labelIndex].toString());

            int colIndex = 0;
            for (int rawColIndex = 0; rawColIndex < getHeaderCount(); rawColIndex++) {
                if (rawColIndex != labelIndex) {
                    row.getInput()[colIndex++] = convertNumeric(raw, rawColIndex);
                }
            }

            result.add(row);
        }
View Full Code Here

    public List<BasicData> extractSupervised(final int inputBegin, final int inputCount, final int idealBegin, final int idealCount) {
        final List<BasicData> result = new ArrayList<BasicData>();

        for (int rowIndex = 0; rowIndex < size(); rowIndex++) {
            final Object[] raw = this.data.get(rowIndex);
            final BasicData row = new BasicData(inputCount, idealCount);

            for (int i = 0; i < inputCount; i++) {
                row.getInput()[i] = convertNumeric(raw, inputBegin + i);
            }

            for (int i = 0; i < idealCount; i++) {
                row.getIdeal()[i] = convertNumeric(raw, idealBegin + i);
            }

            result.add(row);
        }
View Full Code Here

    public List<BasicData> generateTrainingData() {
        final List<BasicData> result = new ArrayList<BasicData>();

        for (double x = -50; x < 50; x++) {
            final double y = (2 * Math.pow(x, 2)) + (4 * x) + 6;
            final BasicData pair = new BasicData(1, 1);
            pair.getInput()[0] = x;
            pair.getIdeal()[0] = y;
            result.add(pair);
        }

        return result;
    }
View Full Code Here

                while (!done) {
                    final int sourceIndex = this.randomGeneration.nextInt(this.k);
                    final Cluster source = this.clusters.get(sourceIndex);
                    if (source != cluster && source.getObservations().size() > 1) {
                        final int sourceObservationIndex = this.randomGeneration.nextInt(source.getObservations().size());
                        final BasicData sourceObservation = source.getObservations().get(sourceObservationIndex);
                        source.getObservations().remove(sourceObservationIndex);
                        cluster.getObservations().add(sourceObservation);
                        done = true;
                    }
                }
View Full Code Here

            int observationIndex = 0;
            int observationCount = cluster.getObservations().size();

            if (observationCount > 1) {
                while (observationIndex < observationCount) {
                    final BasicData observation = cluster.getObservations().get(observationIndex++);

                    final Cluster targetCluster = findNearestCluster(observation.getInput());
                    if (targetCluster != cluster) {
                        cluster.getObservations().remove(observation);
                        targetCluster.getObservations().add(observation);
                        observationCount--;
                        done = false;
View Full Code Here

TOP

Related Classes of com.heatonresearch.aifh.general.data.BasicData

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.