class KMeansClustering extends Clusterer with Error
The KMeansClustering
class cluster several vectors/points using k-means
clustering. Either (1) randomly assign points to 'k' clusters or (2) randomly
pick 'k' points as initial centroids (technique (1) to work better and is the
primary technique). Iteratively, reassign each point to the cluster containing
the closest centroid. Stop when there are no changes to the clusters.
- Alphabetic
- By Inheritance
- KMeansClustering
- Error
- Clusterer
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
-
new
KMeansClustering(x: MatrixD, k: Int, s: Int = 0, primary: Boolean = true)
- x
the vectors/points to be clustered stored as rows of a matrix
- k
the number of clusters to make
- s
the random number stream (to vary the clusters made)
- primary
true indicates use the primary technique for initiating the clustering
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
assign(): Unit
Assign each vector/point to a random cluster.
Assign each vector/point to a random cluster. Primary technique for initiating the clustering.
-
def
calcCentroids(): Unit
Calculate the centroids based on current assignment of points to clusters.
-
def
classify(y: VectorD): Int
Given a new point/vector 'y', determine which cluster it belongs to, i.e., the cluster whose centroid it is closest to.
Given a new point/vector 'y', determine which cluster it belongs to, i.e., the cluster whose centroid it is closest to.
- y
the vector to classify
- Definition Classes
- KMeansClustering → Clusterer
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
cluster(): Array[Int]
Iteratively recompute clusters until the assignment of points does not change, returning the final cluster assignment vector.
Iteratively recompute clusters until the assignment of points does not change, returning the final cluster assignment vector.
- Definition Classes
- KMeansClustering → Clusterer
-
def
distance(u: VectorD, v: VectorD): Double
Compute a distance metric between vectors/points u and v.
Compute a distance metric between vectors/points u and v.
- u
the first vector/point
- v
the second vector/point
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
flaw(method: String, message: String): Unit
Show the flaw by printing the error message.
Show the flaw by printing the error message.
- method
the method where the error occurred
- message
the error message
- Definition Classes
- Error
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
getName(i: Int): String
Get the name of the i-th cluster.
Get the name of the i-th cluster.
- Definition Classes
- Clusterer
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
name_(n: Array[String]): Unit
Set the names for the clusters.
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
def
pickCentroids(): Unit
Randomly pick vectors/points to serve as the initial k centroids (cent).
Randomly pick vectors/points to serve as the initial k centroids (cent). Secondary technique for initiating the clustering.
-
def
reassign(): Boolean
Reassign each vector/point to the cluster with the closest centroid.
Reassign each vector/point to the cluster with the closest centroid. Indicate done, if no points changed clusters (for stopping rule).
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )