source: src/main/java/weka/classifiers/misc/monotone/AbsoluteLossFunction.java @ 26

Last change on this file since 26 was 4, checked in by gnappo, 14 years ago

Import di weka.

File size: 2.2 KB
Line 
1/*
2 *    This program is free software; you can redistribute it and/or modify
3 *    it under the terms of the GNU General Public License as published by
4 *    the Free Software Foundation; either version 2 of the License, or
5 *    (at your option) any later version.
6 *
7 *    This program is distributed in the hope that it will be useful,
8 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
9 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10 *    GNU General Public License for more details.
11 *
12 *    You should have received a copy of the GNU General Public License
13 *    along with this program; if not, write to the Free Software
14 *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
15 */
16
17/*
18 *    AbsoluteLossFunction.java
19 *    Copyright (C) 2004 Stijn Lievens
20 *
21 */
22
23package weka.classifiers.misc.monotone;
24
25import weka.core.RevisionHandler;
26import weka.core.RevisionUtils;
27
28/**
29 * Class implementing the absolute loss function, this means
30 * the returned loss is the abolute value of the difference
31 * between the predicted and actual value.
32 *
33 * <p>
34 * This implementation is done as part of the master's thesis: "Studie
35 * en implementatie van instantie-gebaseerde algoritmen voor gesuperviseerd
36 * rangschikken", Stijn Lievens, Ghent University, 2004.
37 * </p>
38 *
39 * @author Stijn Lievens (stijn.lievens@ugent.be)
40 * @version $Revision: 5922 $
41 */
42public class AbsoluteLossFunction
43  implements NominalLossFunction, RevisionHandler {
44
45  /**
46   * Returns the absolute loss function between two class values.
47   *
48   * @param actual the actual class value
49   * @param predicted the predicted class value
50   * @return the absolute value of the difference between the actual
51   * and predicted value
52   */
53  public final double loss(double actual, double predicted) {
54    return Math.abs(actual - predicted);
55  }
56
57  /**
58   * Returns a string with the name of the loss function.
59   *
60   * @return a string with the name of the loss function
61   */
62  public String toString() {
63    return "AbsoluteLossFunction";
64  }
65 
66  /**
67   * Returns the revision string.
68   *
69   * @return            the revision
70   */
71  public String getRevision() {
72    return RevisionUtils.extract("$Revision: 5922 $");
73  }
74}
Note: See TracBrowser for help on using the repository browser.