NlpTools API
Class

NlpTools\Clustering\CentroidFactories\MeanAngle

class MeanAngle extends Euclidean

MeanAngle computes the unit vector with angle the average of all the given vectors.

The purpose is to compute a vector M such that
sum(cosine_similarity(M,x_i)) is maximized

Methods

mixed getCentroid(array $docs, array $choose = array())

Parse the provided docs and create a doc that given a metric of distance is the centroid of the provided docs.

Details

at line 30
public mixed getCentroid(array $docs, array $choose = array())

Parse the provided docs and create a doc that given a metric of distance is the centroid of the provided docs.

The second array is to choose some of the provided docs to
compute the centroid.

Parameters

array $docs The docs from which the centroid will be computed
array $choose The indexes from which the centroid will be computed (if empty all the docs will be used)

Return Value

mixed The centroid. It could be any form of data a number, a vector (it will be the same as the data provided in docs)