public class FarthestFirst extends RandomizableClusterer implements TechnicalInformationHandler
@article{Hochbaum1985, author = {Hochbaum and Shmoys}, journal = {Mathematics of Operations Research}, number = {2}, pages = {180-184}, title = {A best possible heuristic for the k-center problem}, volume = {10}, year = {1985} } @inproceedings{Dasgupta2002, author = {Sanjoy Dasgupta}, booktitle = {15th Annual Conference on Computational Learning Theory}, pages = {351-363}, publisher = {Springer}, title = {Performance Guarantees for Hierarchical Clustering}, year = {2002} }Valid options are:
-N <num> number of clusters. (default = 2).
-S <num> Random number seed. (default 1)
RandomizableClusterer
,
Serialized FormModifier and Type | Field and Description |
---|---|
protected Instances |
m_ClusterCentroids
holds the cluster centroids
|
protected Instances |
m_instances
training instances, not necessary to keep,
could be replaced by m_ClusterCentroids where needed for header info
|
protected int |
m_NumClusters
number of clusters to generate
|
protected ReplaceMissingValues |
m_ReplaceMissingFilter
replace missing values in training instances
|
m_Seed, m_SeedDefault
Constructor and Description |
---|
FarthestFirst() |
Modifier and Type | Method and Description |
---|---|
void |
buildClusterer(Instances data)
Generates a clusterer.
|
int |
clusterInstance(Instance instance)
Classifies a given instance.
|
protected int |
clusterProcessedInstance(Instance instance)
clusters an instance that has been through the filters
|
protected double |
difference(int index,
double val1,
double val2)
Computes the difference between two given attribute
values.
|
protected double |
distance(Instance first,
Instance second)
Calculates the distance between two instances
|
protected int |
farthestAway(double[] minDistance,
boolean[] selected) |
Capabilities |
getCapabilities()
Returns default capabilities of the clusterer.
|
int |
getNumClusters()
gets the number of clusters to generate
|
String[] |
getOptions()
Gets the current settings of FarthestFirst
|
String |
getRevision()
Returns the revision string.
|
TechnicalInformation |
getTechnicalInformation()
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.
|
String |
globalInfo()
Returns a string describing this clusterer
|
protected void |
initMinMax(Instances data) |
Enumeration |
listOptions()
Returns an enumeration describing the available options.
|
static void |
main(String[] argv)
Main method for testing this class.
|
protected double |
norm(double x,
int i)
Normalizes a given value of a numeric attribute.
|
int |
numberOfClusters()
Returns the number of clusters.
|
String |
numClustersTipText()
Returns the tip text for this property
|
void |
setNumClusters(int n)
set the number of clusters to generate
|
void |
setOptions(String[] options)
Parses a given list of options.
|
String |
toString()
return a string describing this clusterer
|
protected void |
updateMinDistance(double[] minDistance,
boolean[] selected,
Instances data,
Instance center) |
getSeed, seedTipText, setSeed
distributionForInstance, forName, makeCopies, makeCopy, runClusterer
protected Instances m_instances
protected ReplaceMissingValues m_ReplaceMissingFilter
protected int m_NumClusters
protected Instances m_ClusterCentroids
public String globalInfo()
public TechnicalInformation getTechnicalInformation()
getTechnicalInformation
in interface TechnicalInformationHandler
public Capabilities getCapabilities()
getCapabilities
in interface Clusterer
getCapabilities
in interface CapabilitiesHandler
getCapabilities
in class AbstractClusterer
Capabilities
public void buildClusterer(Instances data) throws Exception
buildClusterer
in interface Clusterer
buildClusterer
in class AbstractClusterer
data
- set of instances serving as training dataException
- if the clusterer has not been
generated successfullyprotected void updateMinDistance(double[] minDistance, boolean[] selected, Instances data, Instance center)
protected int farthestAway(double[] minDistance, boolean[] selected)
protected void initMinMax(Instances data)
protected int clusterProcessedInstance(Instance instance)
instance
- the instance to assign a cluster topublic int clusterInstance(Instance instance) throws Exception
clusterInstance
in interface Clusterer
clusterInstance
in class AbstractClusterer
instance
- the instance to be assigned to a clusterException
- if instance could not be classified
successfullyprotected double distance(Instance first, Instance second)
first
- the first instancesecond
- the second instanceprotected double difference(int index, double val1, double val2)
protected double norm(double x, int i)
x
- the value to be normalizedi
- the attribute's indexpublic int numberOfClusters() throws Exception
numberOfClusters
in interface Clusterer
numberOfClusters
in class AbstractClusterer
Exception
- if number of clusters could not be returned
successfullypublic Enumeration listOptions()
listOptions
in interface OptionHandler
listOptions
in class RandomizableClusterer
public String numClustersTipText()
public void setNumClusters(int n) throws Exception
n
- the number of clusters to generateException
- if number of clusters is negativepublic int getNumClusters()
public void setOptions(String[] options) throws Exception
-N <num> number of clusters. (default = 2).
-S <num> Random number seed. (default 1)
setOptions
in interface OptionHandler
setOptions
in class RandomizableClusterer
options
- the list of options as an array of stringsException
- if an option is not supportedpublic String[] getOptions()
getOptions
in interface OptionHandler
getOptions
in class RandomizableClusterer
public String toString()
public String getRevision()
getRevision
in interface RevisionHandler
getRevision
in class AbstractClusterer
public static void main(String[] argv)
argv
- should contain the following arguments: -t training file [-N number of clusters]
Copyright © 2015 University of Waikato, Hamilton, NZ. All rights reserved.