AffinityPropagation is an unsupervised machine learning model that predicts which cluster that the input belongs to using a similarity matrix that measures the similarity between each data point.
Contains a table.
ModelParameters[1]: Contains previously stored feature matrix.
ModelParameters[2]: Contains the cluster number array that has a length of m, where m is the number of data from previous feature matrix and its values contains the cluster numbers indicating which of the clusters that each feature vector belongs to.
ModelParameters[3]: Contains the responsibility matrix of (m x m) size, where m is the number of data.
ModelParameters[4]: Contains the availability matrix of (m x m) size, where m is the number of data.
Create new model object. If any of the arguments are nil, default argument values for that argument will be used.
AffinityPropagation.new(maximumNumberOfIterations: integer, distanceFunction: string, preferenceType: string, damping: number, preferenceValueArray: {number}): ModelObject
maximumNumberOfIterations: How many times should the model needed to be trained.
distanceFunction: The distance function to be used. Available options are:
Euclidean (Default)
Manhattan
Cosine
preferenceType: Determines how preferences are calculated. Available options are:
Median (Default)
Average
Minimum
Maximum
Precomputed
damping: A high value leads to fewer changes, while a low value leads to more exploration. The value can be set between 0 and 1.
preferenceValueArray: An array containing preference values. The index determines the preference value for number of data for that index. Can only be used with “Precomputed” preferenceType.
Set model’s parameters. When any of the arguments are nil, previous argument values for that argument will be used.
AffinityPropagation:setParameters(maximumNumberOfIterations: integer, distanceFunction: string, preferenceType: string, damping: number, preferenceValueArray: {number})
maximumNumberOfIterations: How many times should the model needed to be trained.
distanceFunction: The distance function to be used. Available options are:
Euclidean
Manhattan
Cosine
preferenceType: Determines how preferences are calculated. Available options are:
Median
Average
Minimum
Maximum
Precomputed
damping: A high value leads to fewer changes, while a low value leads to more exploration. The value can be set between 0 and 1.
preferenceValueArray: An array containing preference values. The index determines the preference value for number of data for that index. Can only be used with “Precomputed” preferenceType.
Train the model.
AffinityPropagation:train(featureMatrix: Matrix)
Predict which cluster does it belong to for a given data.
AffinityPropagation:predict(featureMatrix: Matrix): Matrix, Matrix
clusterNumberVector: The cluster which the data belongs to.
shortestDistanceVector: The distance between the datapoint and the center of the cluster (centroids).