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

weka.core.ManhattanDistance Maven / Gradle / Ivy

Go to download

The Waikato Environment for Knowledge Analysis (WEKA), a machine learning workbench. This is the stable version. Apart from bugfixes, this version does not receive any other updates.

There is a newer version: 3.8.6
Show 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 .
 */

/*
 *    ManhattanDistance.java
 *    Copyright (C) 2007-2012 University of Waikato, Hamilton, New Zealand
 *
 */

package weka.core;

import weka.core.TechnicalInformation.Field;
import weka.core.TechnicalInformation.Type;

/**
 
 * Implements the Manhattan distance (or Taxicab geometry). The distance between two points is the sum of the (absolute) differences of their coordinates.
*
* For more information, see:
*
* Wikipedia. Taxicab geometry. URL http://en.wikipedia.org/wiki/Taxicab_geometry. *

* * BibTeX: *

 * @misc{missing_id,
 *    author = {Wikipedia},
 *    title = {Taxicab geometry},
 *    URL = {http://en.wikipedia.org/wiki/Taxicab_geometry}
 * }
 * 
*

* * Valid options are:

* *

 -D
 *  Turns off the normalization of attribute 
 *  values in distance calculation.
* *
 -R <col1,col2-col4,...>
 *  Specifies list of columns to used in the calculation of the 
 *  distance. 'first' and 'last' are valid indices.
 *  (default: first-last)
* *
 -V
 *  Invert matching sense of column indices.
* * * @author Fracpete (fracpete at waikato dot ac dot nz) * @version $Revision: 8034 $ */ public class ManhattanDistance extends NormalizableDistance implements TechnicalInformationHandler { /** for serialization. */ private static final long serialVersionUID = 6783782554224000243L; /** * Constructs an Manhattan Distance object, Instances must be still set. */ public ManhattanDistance() { super(); } /** * Constructs an Manhattan Distance object and automatically initializes the * ranges. * * @param data the instances the distance function should work on */ public ManhattanDistance(Instances data) { super(data); } /** * Returns a string describing this object. * * @return a description of the evaluator suitable for * displaying in the explorer/experimenter gui */ public String globalInfo() { return "Implements the Manhattan distance (or Taxicab geometry). The distance " + "between two points is the sum of the (absolute) differences of their " + "coordinates.\n\n" + "For more information, see:\n\n" + getTechnicalInformation().toString(); } /** * Returns an instance of a TechnicalInformation object, containing * detailed information about the technical background of this class, * e.g., paper reference or book this class is based on. * * @return the technical information about this class */ public TechnicalInformation getTechnicalInformation() { TechnicalInformation result; result = new TechnicalInformation(Type.MISC); result.setValue(Field.AUTHOR, "Wikipedia"); result.setValue(Field.TITLE, "Taxicab geometry"); result.setValue(Field.URL, "http://en.wikipedia.org/wiki/Taxicab_geometry"); return result; } /** * Updates the current distance calculated so far with the new difference * between two attributes. The difference between the attributes was * calculated with the difference(int,double,double) method. * * @param currDist the current distance calculated so far * @param diff the difference between two new attributes * @return the update distance * @see #difference(int, double, double) */ protected double updateDistance(double currDist, double diff) { double result; result = currDist; result += Math.abs(diff); return result; } /** * Returns the revision string. * * @return the revision */ public String getRevision() { return RevisionUtils.extract("$Revision: 8034 $"); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy