View Javadoc

1   /*
2    * Copyright (C) 2003-2006 Christian Siefkes <christian@siefkes.net>.
3    * Development of this software is supported by the German Research Society,
4    * Berlin-Brandenburg Graduate School in Distributed Information Systems
5    * (DFG grant no. GRK 316).
6    *
7    * This program is free software; you can redistribute it and/or modify
8    * it under the terms of the GNU General Public License as published by
9    * the Free Software Foundation; either version 2 of the License, or
10   * (at your option) any later version.
11   *
12   * This program is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   * GNU General Public License for more details.
16   *
17   * You should have received a copy of the GNU General Public License
18   * along with this program; if not, visit
19   * http://www.gnu.org/licenses/gpl.html or write to the Free Software
20   * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21   */
22  package de.fu_berlin.ties.classify;
23  
24  import java.util.Set;
25  
26  import de.fu_berlin.ties.ProcessingException;
27  import de.fu_berlin.ties.classify.feature.FeatureVector;
28  
29  /***
30   * Classes implementing this interface must be able to classify items
31   * represented by feature vectors.
32   *
33   * @author Christian Siefkes
34   * @version $Revision: 1.12 $, $Date: 2006/10/21 16:03:54 $, $Author: siefkes $
35   */
36  public interface Classifier {
37  
38      /***
39       * Base configuration key for classifiers.
40       */
41      String CONFIG_CLASSIFIER = "classifier";
42  
43      /***
44       * Classifies an item that is represented by a feature vector by choosing
45       * the most probable class among a set of candidate classes.
46       *
47       * @param features the feature vector to consider
48       * @param candidateClasses an set of classes that are allowed for this item
49       * @return the result of the classification; you can call
50       * {@link PredictionDistribution#best()} to get the most probably class
51       * @throws ProcessingException if an error occurs during classification
52       */
53      PredictionDistribution classify(final FeatureVector features,
54              final Set candidateClasses) throws ProcessingException;
55  
56      /***
57       * Destroys the classifer. This method must be called only if the classifier
58       * will never be used again.
59       *
60       * @throws ProcessingException if an error occurs while the classifier is
61       * being destroyed
62       */
63      void destroy() throws ProcessingException;
64  
65  }