KMedoids is an unsupervised machine learning model that assigns data points to clusters by selecting representative points, called medoids, as cluster centers. It then predicts the cluster membership of new data points based on their distances to the medoids.
Contains a matrix.
Create new model object. If any of the arguments are nil, default argument values for that argument will be used.
KMedoids.new(maximumNumberOfIterations: integer, numberOfClusters: integer, distanceFunction: string, setTheCentroidsDistanceFarthest: boolean): ModelObject
maximumNumberOfIterations: How many times should the model needed to be trained.
numberOfClusters: Number of clusters for model to train and predict on.
distanceFunction: The function that the model will use to train. distanceFunction available are:
Euclidean
Manhattan
Cosine
setTheCentroidsDistanceFarthest: Set whether or not the model to create centroids that are furthest from each other.
Set model’s parameters. When any of the arguments are nil, previous argument values for that argument will be used.
KMedoids:setParameters(maximumNumberOfIterations: integer, numberOfClusters: integer, distanceFunction: string, setTheCentroidsDistanceFarthest: boolean)
maximumNumberOfIterations: How many times should the model needed to be trained.
numberOfClusters: Number of clusters for model to train and predict on.
distanceFunction: The function that the model will use to train. distanceFunction available are:
Euclidean
Manhattan
Cosine
setTheCentroidsDistanceFarthest: Set whether or not the model to create centroids that are furthest from each other.
Train the model.
KMedoids:train(featureMatrix: Matrix)
Predict which clusters does it belong to for a given data.
KMedoids:predict(featureMatrix: Matrix, returnOriginalOutput: boolean): integer, number -OR-
clusterNumber: The cluster which the data belongs to.
shortestDistance: The distance between the datapoint and the center of the cluster (centroids).