weka.classifiers.neural.lvq.vectordistance.NumericDistance Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of wekaclassalgos Show documentation
Show all versions of wekaclassalgos Show documentation
Fork of the following defunct sourceforge.net project: https://sourceforge.net/projects/wekaclassalgos/
The newest version!
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
package weka.classifiers.neural.lvq.vectordistance;
/**
* Description: Distance between numberic attribute values, lower the
* distance the closer the values.
*
*
* Copyright (c) Jason Brownlee 2004
*
*
* @author Jason Brownlee
*/
public class NumericDistance implements AttributeDistance {
/**
* Distance between numberic attribute values, lower the distance the closer the values.
* The square of the delta is returned. These can be summed to produce an approximation
* of the eucliden distance (with or without the square root at the end).
*
* @param instanceValue
* @param codebookValue
* @return
*/
public double distance(double instanceValue, double codebookValue) {
// calculate the difference
double delta = (instanceValue - codebookValue);
// square the difference
return (delta * delta);
}
} © 2015 - 2025 Weber Informatics LLC | Privacy Policy