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

aima.core.learning.neural.NNExample Maven / Gradle / Ivy

Go to download

AIMA-Java Core Algorithms from the book Artificial Intelligence a Modern Approach 3rd Ed.

The newest version!
package aima.core.learning.neural;

import java.util.ArrayList;
import java.util.List;

import aima.core.util.math.Vector;

/**
 * @author Ravi Mohan
 * 
 */
public class NNExample {
	private final List normalizedInput, normalizedTarget;

	public NNExample(List normalizedInput, List normalizedTarget) {
		this.normalizedInput = normalizedInput;
		this.normalizedTarget = normalizedTarget;
	}

	public NNExample copyExample() {
		List newInput = new ArrayList();
		List newTarget = new ArrayList();
		for (Double d : normalizedInput) {
			newInput.add(new Double(d.doubleValue()));
		}
		for (Double d : normalizedTarget) {
			newTarget.add(new Double(d.doubleValue()));
		}
		return new NNExample(newInput, newTarget);
	}

	public Vector getInput() {
		Vector v = new Vector(normalizedInput);
		return v;

	}

	public Vector getTarget() {
		Vector v = new Vector(normalizedTarget);
		return v;

	}

	public boolean isCorrect(Vector prediction) {
		/*
		 * compares the index having greatest value in target to indec having
		 * greatest value in prediction. Ifidentical, correct
		 */
		return getTarget().indexHavingMaxValue() == prediction
				.indexHavingMaxValue();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy