[4] | 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 | * Clusterer.java |
---|
| 19 | * Copyright (C) 1999 University of Waikato, Hamilton, New Zealand |
---|
| 20 | * |
---|
| 21 | */ |
---|
| 22 | |
---|
| 23 | package weka.clusterers; |
---|
| 24 | |
---|
| 25 | import weka.core.Capabilities; |
---|
| 26 | import weka.core.Instance; |
---|
| 27 | import weka.core.Instances; |
---|
| 28 | |
---|
| 29 | /** |
---|
| 30 | * Interface for clusterers. Clients will typically extend either |
---|
| 31 | * AbstractClusterer or AbstractDensityBasedClusterer. |
---|
| 32 | * |
---|
| 33 | * @author Mark Hall (mhall@cs.waikato.ac.nz) |
---|
| 34 | * @version $Revision: 5987 $ |
---|
| 35 | */ |
---|
| 36 | public interface Clusterer { |
---|
| 37 | |
---|
| 38 | /** |
---|
| 39 | * Generates a clusterer. Has to initialize all fields of the clusterer |
---|
| 40 | * that are not being set via options. |
---|
| 41 | * |
---|
| 42 | * @param data set of instances serving as training data |
---|
| 43 | * @exception Exception if the clusterer has not been |
---|
| 44 | * generated successfully |
---|
| 45 | */ |
---|
| 46 | void buildClusterer(Instances data) throws Exception; |
---|
| 47 | |
---|
| 48 | /** |
---|
| 49 | * Classifies a given instance. Either this or distributionForInstance() |
---|
| 50 | * needs to be implemented by subclasses. |
---|
| 51 | * |
---|
| 52 | * @param instance the instance to be assigned to a cluster |
---|
| 53 | * @return the number of the assigned cluster as an integer |
---|
| 54 | * @exception Exception if instance could not be clustered |
---|
| 55 | * successfully |
---|
| 56 | */ |
---|
| 57 | int clusterInstance(Instance instance) throws Exception; |
---|
| 58 | |
---|
| 59 | /** |
---|
| 60 | * Predicts the cluster memberships for a given instance. Either |
---|
| 61 | * this or clusterInstance() needs to be implemented by subclasses. |
---|
| 62 | * |
---|
| 63 | * @param instance the instance to be assigned a cluster. |
---|
| 64 | * @return an array containing the estimated membership |
---|
| 65 | * probabilities of the test instance in each cluster (this |
---|
| 66 | * should sum to at most 1) |
---|
| 67 | * @exception Exception if distribution could not be |
---|
| 68 | * computed successfully |
---|
| 69 | */ |
---|
| 70 | public double[] distributionForInstance(Instance instance) throws Exception; |
---|
| 71 | |
---|
| 72 | /** |
---|
| 73 | * Returns the number of clusters. |
---|
| 74 | * |
---|
| 75 | * @return the number of clusters generated for a training dataset. |
---|
| 76 | * @exception Exception if number of clusters could not be returned |
---|
| 77 | * successfully |
---|
| 78 | */ |
---|
| 79 | int numberOfClusters() throws Exception; |
---|
| 80 | |
---|
| 81 | /** |
---|
| 82 | * Returns the Capabilities of this clusterer. Derived classifiers have to |
---|
| 83 | * override this method to enable capabilities. |
---|
| 84 | * |
---|
| 85 | * @return the capabilities of this object |
---|
| 86 | * @see Capabilities |
---|
| 87 | */ |
---|
| 88 | public Capabilities getCapabilities(); |
---|
| 89 | |
---|
| 90 | } |
---|