source: src/main/java/weka/classifiers/Classifier.java @ 6

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

Import di weka.

File size: 3.7 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 *    Classifier.java
19 *    Copyright (C) 1999 University of Waikato, Hamilton, New Zealand
20 *
21 */
22
23package weka.classifiers;
24
25import weka.core.Attribute;
26import weka.core.Capabilities;
27import weka.core.CapabilitiesHandler;
28import weka.core.Instance;
29import weka.core.Instances;
30import weka.core.Option;
31import weka.core.OptionHandler;
32import weka.core.RevisionHandler;
33import weka.core.RevisionUtils;
34import weka.core.SerializedObject;
35import weka.core.Utils;
36
37import java.io.Serializable;
38import java.util.Enumeration;
39import java.util.Set;
40import java.util.Vector;
41
42/**
43 * Classifier interface. All schemes for numeric or nominal prediction in
44 * Weka implement this interface. Note that a classifier MUST either implement
45 * distributionForInstance() or classifyInstance().
46 *
47 * @author Eibe Frank (eibe@cs.waikato.ac.nz)
48 * @author Len Trigg (trigg@cs.waikato.ac.nz)
49 * @version $Revision: 6041 $
50 */
51public interface Classifier {
52
53  /**
54   * Generates a classifier. Must initialize all fields of the classifier
55   * that are not being set via options (ie. multiple calls of buildClassifier
56   * must always lead to the same result). Must not change the dataset
57   * in any way.
58   *
59   * @param data set of instances serving as training data
60   * @exception Exception if the classifier has not been
61   * generated successfully
62   */
63  public abstract void buildClassifier(Instances data) throws Exception;
64
65  /**
66   * Classifies the given test instance. The instance has to belong to a
67   * dataset when it's being classified. Note that a classifier MUST
68   * implement either this or distributionForInstance().
69   *
70   * @param instance the instance to be classified
71   * @return the predicted most likely class for the instance or
72   * Utils.missingValue() if no prediction is made
73   * @exception Exception if an error occurred during the prediction
74   */
75  public double classifyInstance(Instance instance) throws Exception;
76
77  /**
78   * Predicts the class memberships for a given instance. If
79   * an instance is unclassified, the returned array elements
80   * must be all zero. If the class is numeric, the array
81   * must consist of only one element, which contains the
82   * predicted value. Note that a classifier MUST implement
83   * either this or classifyInstance().
84   *
85   * @param instance the instance to be classified
86   * @return an array containing the estimated membership
87   * probabilities of the test instance in each class
88   * or the numeric prediction
89   * @exception Exception if distribution could not be
90   * computed successfully
91   */
92  public double[] distributionForInstance(Instance instance) throws Exception;
93
94  /**
95   * Returns the Capabilities of this classifier. Maximally permissive
96   * capabilities are allowed by default. Derived classifiers should
97   * override this method and first disable all capabilities and then
98   * enable just those capabilities that make sense for the scheme.
99   *
100   * @return            the capabilities of this object
101   * @see               Capabilities
102   */
103  public Capabilities getCapabilities();
104}
105
Note: See TracBrowser for help on using the repository browser.