public class gCenter
extends java.lang.Object
This class represents a group of centers (centroids) of a set of clusters
Constructor and Description |
---|
gCenter()
Creates a new instance of gCenter
|
gCenter(int k,
int ndatos,
int nvariables)
Creates a new instance of gCenter with provided number of centers, number of instances of the
data set and number of attributes
|
Modifier and Type | Method and Description |
---|---|
void |
copyCenter(Instance i,
int c)
this function initializes a center with the values of a given instance.
|
double |
distance(Instance i,
int k)
Computes the distance between a instances (without previous normalization) and
one clusters (i.e. its centroid).
|
int |
getClusterOf(int orderOf_i)
Returns the cluster to which the given instance belongs to
|
int |
nearestCenter(Instance inst)
Computes the nearest cluster to the given instance
|
void |
recalculateCenters(InstanceSet IS)
Recalculates all the centroids using a given InstanceSet, in order to reduce the
total sum of distances for each object to the centroid of the cluster, which the object belongs to
|
void |
setClusterOf(Instance i,
int orderOf_i)
Updates the cluster membership of the instance to the nearest cluster
|
java.lang.String |
valueAt(int cluster,
int position)
Get the value of an attribute of the indicated centroid
|
public gCenter()
public gCenter(int k, int ndatos, int nvariables)
Creates a new instance of gCenter with provided number of centers, number of instances of the data set and number of attributes
k
- Fixed number of centroidsndatos
- number of instances in the data set related to this objectnvariables
- number of attributespublic double distance(Instance i, int k)
Computes the distance between a instances (without previous normalization) and one clusters (i.e. its centroid).
i
- The reference instancek
- The cluster numberpublic int nearestCenter(Instance inst)
Computes the nearest cluster to the given instance
inst
- The instance we are interested to comparepublic void copyCenter(Instance i, int c)
this function initializes a center with the values of a given instance.
i
- the initialization instancec
- the index of the cluster to be initializedpublic void recalculateCenters(InstanceSet IS)
Recalculates all the centroids using a given InstanceSet, in order to reduce the total sum of distances for each object to the centroid of the cluster, which the object belongs to
IS
- The reference InstanceSetpublic void setClusterOf(Instance i, int orderOf_i)
Updates the cluster membership of the instance to the nearest cluster
i
- The considered instanceorderOf_i
- The index of the instance ipublic int getClusterOf(int orderOf_i)
Returns the cluster to which the given instance belongs to
orderOf_i
- The index of the instancepublic java.lang.String valueAt(int cluster, int position)
Get the value of an attribute of the indicated centroid
cluster
- The index of the cluster (centroid)position
- The attribute (dimension) to be obtained