You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Artem Barger <ar...@bargr.net> on 2016/04/25 14:52:03 UTC
[math]: [MATH-1330] - KMeans clustering algorithm, doesn't support
clustering of sparse input data.
Hi All,
I'd like to provide a solution for [MATH-1330] issue. Before starting I
have a concerns regarding the possible design and the actual implementation.
Currently all implementations of Clusterer interface expect to receive
instance of DistanceMeasure class, which used to compute distance or metric
between two points. Switching clustering algorithms to work with Vectors
will make this unnecessary, therefore there will be no need to provide
DistanceMeasure, since Vector class already provides methods to compute
vector norms.
The main drawback of this approach is that we will loose the ability to
control which metric to use during clustering, however the only classes
which make an implicit use of this parameters are: Clusterer and
KmeansPlusPlusClusterer all others assumes EucledianDistance by default.
One of the possible approaches is to extend DistanceMeasure interface to be
able to compute distance between two vectors? After all it's only sub first
vector from the second and compute desired norm on the result.
Another possible solution is to make vector to return it's coordinates,
hence it avail us to use DistanceMeasure as is. Personally I do not think
this is good approach, since it will make no sense with sparse vectors.
Last alternative this comes to my mind is to create a set of enums to
indicate which vector norm to use to compute distances, also do no think
this is very good solution, since sounds too intrusive and might break
backward compatibility.
What do you think? Am I missing something? Is there a better possible way
to achieve the goal?
Best regards,
Artem Barger.
Re: [math]: [MATH-1330] - KMeans clustering algorithm, doesn't
support clustering of sparse input data.
Posted by Artem Barger <ar...@bargr.net>.
Hi,
I'm working on providing a solution for MATH-1330 and facing several design
related issues which I'd like to share, since I'd like my solution to fit
with the project road map and integrity. So, I'm looking on Clusterable
interface and looks like automatically impose the way internal
representation of data should look like, since getPoint() method signature
indirectly assumes that it has to be an array of doubles. And this might
not be a true for certain cases. IMO replacing of getPoint() with
getDistanceTo(Clusterable a) could be a better solution, since it doesn't
assumes anything about internal representation. From other side that means
what Clusterable instances need to be aware which DistanceMeasure
implementation used for clustering.
Therefore I'm not completely sure how to move on with it. Moreover suppose
I'll replace getPoint to return RealVector, then next issue will be to
decide how should I define/create cluster centers. Whenever do I need to
use sparse or dense implementation?
One of the possible solutions I'm thinking of is to decouple the process of
seeding the initial cluster centers and the Lloyd's iterations. That way I
can actually seed initial centers, provide them as a parameter into
clustering algorithm, which will move centers during the iteration instead
of creating each time new centroid instance. While it will work for center
based clustering algorithm that will not be the case for others, hence not
sure how I can fit this solution into the current design.
Any thoughts or suggestions?
BR,
Artem.
Re: [math]: [MATH-1330] - KMeans clustering algorithm, doesn't
support clustering of sparse input data.
Posted by Gilles <gi...@harfang.homelinux.org>.
Hello.
On Sun, 1 May 2016 02:57:59 +0300, Artem Barger wrote:
> \u200bHi,\u200b
>
>
> On Sun, May 1, 2016 at 12:25 AM, Gilles
> <gi...@harfang.homelinux.org>
> wrote:
>
> Therefore I started to wonder why not to use RealVector
>>
>>> instead, since it has sparse implementation so I will be able to
>>> leverage
>>> it.
>>>
>>
>> The principle is fine; but I'm wary to use "RealVector" in new code
>> since it must be refactored...
>>
>>
> \u200bBy refactoring, do you mean MATH-765\u200b?
Yes.
>
>
>
>> Right now using kmeans++ clustering algorithm provided by
>> common.maths
>>> it's not doable to cluster entire wikipedia dataset or any other
>>> huge
>>> datasets.
>>>
>>
>> Could you expand on this application? What is the data?
>>
>>
> \u200bThe data is tf-idf matrix of wikipedia data set produced by gensim.
> I'm
> trying to run coreset algorithm with Spark streaming
> and I need kmeans++ for local computation.\u200b
>
>
>>
>> [One of the things to bear in mind while testing new implementations
>> is to not loose performance on the other classes of problems (or
>> you'll
>> take heat from some of this list's observers...).]
>>
>>
> \u200bIs there any performance tests or regression, so it could be used to
> validate whenever new implementation doesn't introduced
> significant regression?
Not really.
There is a class "PertTestUtils" (in the "test" part of the source code
repository) that could compare execution time between alternative
implementations of some functionality.
I think that it's reliable enough to detect significant performance
issues.
Otherwise, there is the (now "standard"?) JMH benchmarking tool.
Regards,
Gilles
>>>
>>> On Sat, Apr 30, 2016 at 11:41 PM, Gilles
>>> <gi...@harfang.homelinux.org>
>>> wrote:
>>>
>>> On Mon, 25 Apr 2016 15:52:03 +0300, Artem Barger wrote:
>>>>
>>>> Hi All,
>>>>>
>>>>> I'd like to provide a solution for [MATH-1330] issue. Before
>>>>> starting I
>>>>> have a concerns regarding the possible design and the actual
>>>>> implementation.
>>>>>
>>>>> Currently all implementations of Clusterer interface expect to
>>>>> receive
>>>>> instance of DistanceMeasure class, which used to compute distance
>>>>> or
>>>>> metric
>>>>> between two points. Switching clustering algorithms to work with
>>>>> Vectors
>>>>> will make this unnecessary, therefore there will be no need to
>>>>> provide
>>>>> DistanceMeasure, since Vector class already provides methods to
>>>>> compute
>>>>> vector norms.
>>>>>
>>>>>
>>>> I think that reasons for using "double[]" in the
>>>> "o.a.c.m.ml.clustering"
>>>> package were:
>>>> * simple and straightforward (fixed dimension Cartesian
>>>> coordinates)
>>>> * not couple it with the "o.a.c.m.linear" package whose
>>>> "RealVector" is
>>>> for variable size sequences of elements (and is also,
>>>> inconsistently,
>>>> used as a Cartesian vector, and also as column- and
>>>> row-matrix[1])
>>>>
>>>> It is arguable adapted for a family of problems which the
>>>> developer
>>>> probably had in mind when taking those design decisions.
>>>>
>>>> It would be interesting to know for which class of problems, the
>>>> design
>>>> is inappropriate, in order to clarify ideas.
>>>>
>>>> The main drawback of this approach is that we will loose the
>>>> ability to
>>>>
>>>>> control which metric to use during clustering, however the only
>>>>> classes
>>>>> which make an implicit use of this parameters are: Clusterer and
>>>>> KmeansPlusPlusClusterer all others assumes EucledianDistance by
>>>>> default.
>>>>>
>>>>>
>>>> There is a default indeed, but all "Clusterer" implementations use
>>>> whatever "DistanceMeasure" has been passed to the constructor.
>>>>
>>>> Assuming that "RealVector" knows how to compute the distance means
>>>> that
>>>> users will have to implement their own subclass of "RealVector"
>>>> and
>>>> override "getDistance(RealVector)" if they want another distance.
>>>> Alternatively, CM would have to define all these classes.
>>>>
>>>> At first sight, it does not seem the right way to go...
>>>>
>>>> One of the possible approaches is to extend DistanceMeasure
>>>> interface to
>>>> be
>>>>
>>>>> able to compute distance between two vectors? After all it's only
>>>>> sub
>>>>> first
>>>>> vector from the second and compute desired norm on the result.
>>>>>
>>>>>
>>>> Seems good (at first sight) but (IMHO) only if we implement a new
>>>> "CartesianVector" class unencumbered with all the cruft of
>>>> "RealVector".
>>>>
>>>> Another possible solution is to make vector to return it's
>>>> coordinates,
>>>>
>>>>> hence it avail us to use DistanceMeasure as is. Personally I do
>>>>> not
>>>>> think
>>>>> this is good approach, since it will make no sense with sparse
>>>>> vectors.
>>>>>
>>>>>
>>>> Ruled out indeed if it conflicts with your intended usage.
>>>>
>>>> Last alternative this comes to my mind is to create a set of enums
>>>> to
>>>>
>>>>> indicate which vector norm to use to compute distances, also do
>>>>> no think
>>>>> this is very good solution, since sounds too intrusive and might
>>>>> break
>>>>> backward compatibility.
>>>>>
>>>>>
>>>> And forward compatibility (clustering code will have to be adapted
>>>> if
>>>> another distance is added later).
>>>>
>>>> What do you think? Am I missing something? Is there a better
>>>> possible way
>>>>
>>>>> to achieve the goal?
>>>>>
>>>>>
>>>> As indicated above, a practical example might help visualize the
>>>> options.
>>>>
>>>>
>>>> Regards,
>>>> Gilles
>>>>
>>>> [1] Cf. https://issues.apache.org/jira/browse/MATH-765
>>>>
>>>>
>>>> Best regards,
>>>>> Artem Barger.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: [math]: [MATH-1330] - KMeans clustering algorithm, doesn't
support clustering of sparse input data.
Posted by Artem Barger <ar...@bargr.net>.
Hi,
On Sun, May 1, 2016 at 12:25 AM, Gilles <gi...@harfang.homelinux.org>
wrote:
Therefore I started to wonder why not to use RealVector
>
>> instead, since it has sparse implementation so I will be able to leverage
>> it.
>>
>
> The principle is fine; but I'm wary to use "RealVector" in new code
> since it must be refactored...
>
>
By refactoring, do you mean MATH-765?
> Right now using kmeans++ clustering algorithm provided by common.maths
>> it's not doable to cluster entire wikipedia dataset or any other huge
>> datasets.
>>
>
> Could you expand on this application? What is the data?
>
>
The data is tf-idf matrix of wikipedia data set produced by gensim. I'm
trying to run coreset algorithm with Spark streaming
and I need kmeans++ for local computation.
>
> [One of the things to bear in mind while testing new implementations
> is to not loose performance on the other classes of problems (or you'll
> take heat from some of this list's observers...).]
>
>
Is there any performance tests or regression, so it could be used to
validate whenever new implementation doesn't introduced
significant regression?
Best,
Artem.
>
> Best regards,
> Gilles
>
>
>
>>
>> Best regards,
>> Artem Barger.
>>
>> On Sat, Apr 30, 2016 at 11:41 PM, Gilles <gi...@harfang.homelinux.org>
>> wrote:
>>
>> On Mon, 25 Apr 2016 15:52:03 +0300, Artem Barger wrote:
>>>
>>> Hi All,
>>>>
>>>> I'd like to provide a solution for [MATH-1330] issue. Before starting I
>>>> have a concerns regarding the possible design and the actual
>>>> implementation.
>>>>
>>>> Currently all implementations of Clusterer interface expect to receive
>>>> instance of DistanceMeasure class, which used to compute distance or
>>>> metric
>>>> between two points. Switching clustering algorithms to work with Vectors
>>>> will make this unnecessary, therefore there will be no need to provide
>>>> DistanceMeasure, since Vector class already provides methods to compute
>>>> vector norms.
>>>>
>>>>
>>> I think that reasons for using "double[]" in the "o.a.c.m.ml.clustering"
>>> package were:
>>> * simple and straightforward (fixed dimension Cartesian coordinates)
>>> * not couple it with the "o.a.c.m.linear" package whose "RealVector" is
>>> for variable size sequences of elements (and is also, inconsistently,
>>> used as a Cartesian vector, and also as column- and row-matrix[1])
>>>
>>> It is arguable adapted for a family of problems which the developer
>>> probably had in mind when taking those design decisions.
>>>
>>> It would be interesting to know for which class of problems, the design
>>> is inappropriate, in order to clarify ideas.
>>>
>>> The main drawback of this approach is that we will loose the ability to
>>>
>>>> control which metric to use during clustering, however the only classes
>>>> which make an implicit use of this parameters are: Clusterer and
>>>> KmeansPlusPlusClusterer all others assumes EucledianDistance by default.
>>>>
>>>>
>>> There is a default indeed, but all "Clusterer" implementations use
>>> whatever "DistanceMeasure" has been passed to the constructor.
>>>
>>> Assuming that "RealVector" knows how to compute the distance means that
>>> users will have to implement their own subclass of "RealVector" and
>>> override "getDistance(RealVector)" if they want another distance.
>>> Alternatively, CM would have to define all these classes.
>>>
>>> At first sight, it does not seem the right way to go...
>>>
>>> One of the possible approaches is to extend DistanceMeasure interface to
>>> be
>>>
>>>> able to compute distance between two vectors? After all it's only sub
>>>> first
>>>> vector from the second and compute desired norm on the result.
>>>>
>>>>
>>> Seems good (at first sight) but (IMHO) only if we implement a new
>>> "CartesianVector" class unencumbered with all the cruft of "RealVector".
>>>
>>> Another possible solution is to make vector to return it's coordinates,
>>>
>>>> hence it avail us to use DistanceMeasure as is. Personally I do not
>>>> think
>>>> this is good approach, since it will make no sense with sparse vectors.
>>>>
>>>>
>>> Ruled out indeed if it conflicts with your intended usage.
>>>
>>> Last alternative this comes to my mind is to create a set of enums to
>>>
>>>> indicate which vector norm to use to compute distances, also do no think
>>>> this is very good solution, since sounds too intrusive and might break
>>>> backward compatibility.
>>>>
>>>>
>>> And forward compatibility (clustering code will have to be adapted if
>>> another distance is added later).
>>>
>>> What do you think? Am I missing something? Is there a better possible way
>>>
>>>> to achieve the goal?
>>>>
>>>>
>>> As indicated above, a practical example might help visualize the options.
>>>
>>>
>>> Regards,
>>> Gilles
>>>
>>> [1] Cf. https://issues.apache.org/jira/browse/MATH-765
>>>
>>>
>>> Best regards,
>>>> Artem Barger.
>>>>
>>>>
>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
Re: [math]: [MATH-1330] - KMeans clustering algorithm, doesn't
support clustering of sparse input data.
Posted by Gilles <gi...@harfang.homelinux.org>.
Hi.
[Please avoid top-posting.]
On Sat, 30 Apr 2016 23:56:13 +0300, Artem Barger wrote:
> Well, I do not have too much examples in my mind. Actually only one
> practical use case, which made me to think that using "double[]" is
> not
> very practical. I was trying to cluster Wikipedia dataset, which is
> very
> sparse (a lot of zero entries) and it looked like huge waste of RAM
> to
> store zeros.
We'll all agree on this, I expect. ;-)
> Therefore I started to wonder why not to use RealVector
> instead, since it has sparse implementation so I will be able to
> leverage
> it.
The principle is fine; but I'm wary to use "RealVector" in new code
since it must be refactored...
> Right now using kmeans++ clustering algorithm provided by
> common.maths
> it's not doable to cluster entire wikipedia dataset or any other huge
> datasets.
Could you expand on this application? What is the data?
>
> Another possible alternative is to implement SparseClusterable
> (inherits
> from Clusterable) and the sparse measure which will inherit from
> DistanceMeasure and will provide metric computation for such sparse
> representation.
IIUC it would require changing "Clusterable" anyways since its method
returns a "double[]".
But it may be OK if the final goal is worth it.
[One of the things to bear in mind while testing new implementations
is to not loose performance on the other classes of problems (or you'll
take heat from some of this list's observers...).]
Best regards,
Gilles
>
>
> Best regards,
> Artem Barger.
>
> On Sat, Apr 30, 2016 at 11:41 PM, Gilles
> <gi...@harfang.homelinux.org>
> wrote:
>
>> On Mon, 25 Apr 2016 15:52:03 +0300, Artem Barger wrote:
>>
>>> Hi All,
>>>
>>> I'd like to provide a solution for [MATH-1330] issue. Before
>>> starting I
>>> have a concerns regarding the possible design and the actual
>>> implementation.
>>>
>>> Currently all implementations of Clusterer interface expect to
>>> receive
>>> instance of DistanceMeasure class, which used to compute distance
>>> or
>>> metric
>>> between two points. Switching clustering algorithms to work with
>>> Vectors
>>> will make this unnecessary, therefore there will be no need to
>>> provide
>>> DistanceMeasure, since Vector class already provides methods to
>>> compute
>>> vector norms.
>>>
>>
>> I think that reasons for using "double[]" in the
>> "o.a.c.m.ml.clustering"
>> package were:
>> * simple and straightforward (fixed dimension Cartesian
>> coordinates)
>> * not couple it with the "o.a.c.m.linear" package whose
>> "RealVector" is
>> for variable size sequences of elements (and is also,
>> inconsistently,
>> used as a Cartesian vector, and also as column- and
>> row-matrix[1])
>>
>> It is arguable adapted for a family of problems which the developer
>> probably had in mind when taking those design decisions.
>>
>> It would be interesting to know for which class of problems, the
>> design
>> is inappropriate, in order to clarify ideas.
>>
>> The main drawback of this approach is that we will loose the ability
>> to
>>> control which metric to use during clustering, however the only
>>> classes
>>> which make an implicit use of this parameters are: Clusterer and
>>> KmeansPlusPlusClusterer all others assumes EucledianDistance by
>>> default.
>>>
>>
>> There is a default indeed, but all "Clusterer" implementations use
>> whatever "DistanceMeasure" has been passed to the constructor.
>>
>> Assuming that "RealVector" knows how to compute the distance means
>> that
>> users will have to implement their own subclass of "RealVector" and
>> override "getDistance(RealVector)" if they want another distance.
>> Alternatively, CM would have to define all these classes.
>>
>> At first sight, it does not seem the right way to go...
>>
>> One of the possible approaches is to extend DistanceMeasure
>> interface to be
>>> able to compute distance between two vectors? After all it's only
>>> sub
>>> first
>>> vector from the second and compute desired norm on the result.
>>>
>>
>> Seems good (at first sight) but (IMHO) only if we implement a new
>> "CartesianVector" class unencumbered with all the cruft of
>> "RealVector".
>>
>> Another possible solution is to make vector to return it's
>> coordinates,
>>> hence it avail us to use DistanceMeasure as is. Personally I do not
>>> think
>>> this is good approach, since it will make no sense with sparse
>>> vectors.
>>>
>>
>> Ruled out indeed if it conflicts with your intended usage.
>>
>> Last alternative this comes to my mind is to create a set of enums
>> to
>>> indicate which vector norm to use to compute distances, also do no
>>> think
>>> this is very good solution, since sounds too intrusive and might
>>> break
>>> backward compatibility.
>>>
>>
>> And forward compatibility (clustering code will have to be adapted
>> if
>> another distance is added later).
>>
>> What do you think? Am I missing something? Is there a better
>> possible way
>>> to achieve the goal?
>>>
>>
>> As indicated above, a practical example might help visualize the
>> options.
>>
>>
>> Regards,
>> Gilles
>>
>> [1] Cf. https://issues.apache.org/jira/browse/MATH-765
>>
>>
>>> Best regards,
>>> Artem Barger.
>>>
>>
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: [math]: [MATH-1330] - KMeans clustering algorithm, doesn't
support clustering of sparse input data.
Posted by Artem Barger <ar...@bargr.net>.
Well, I do not have too much examples in my mind. Actually only one
practical use case, which made me to think that using "double[]" is not
very practical. I was trying to cluster Wikipedia dataset, which is very
sparse (a lot of zero entries) and it looked like huge waste of RAM to
store zeros. Therefore I started to wonder why not to use RealVector
instead, since it has sparse implementation so I will be able to leverage
it. Right now using kmeans++ clustering algorithm provided by common.maths
it's not doable to cluster entire wikipedia dataset or any other huge
datasets.
Another possible alternative is to implement SparseClusterable (inherits
from Clusterable) and the sparse measure which will inherit from
DistanceMeasure and will provide metric computation for such sparse
representation.
Best regards,
Artem Barger.
On Sat, Apr 30, 2016 at 11:41 PM, Gilles <gi...@harfang.homelinux.org>
wrote:
> On Mon, 25 Apr 2016 15:52:03 +0300, Artem Barger wrote:
>
>> Hi All,
>>
>> I'd like to provide a solution for [MATH-1330] issue. Before starting I
>> have a concerns regarding the possible design and the actual
>> implementation.
>>
>> Currently all implementations of Clusterer interface expect to receive
>> instance of DistanceMeasure class, which used to compute distance or
>> metric
>> between two points. Switching clustering algorithms to work with Vectors
>> will make this unnecessary, therefore there will be no need to provide
>> DistanceMeasure, since Vector class already provides methods to compute
>> vector norms.
>>
>
> I think that reasons for using "double[]" in the "o.a.c.m.ml.clustering"
> package were:
> * simple and straightforward (fixed dimension Cartesian coordinates)
> * not couple it with the "o.a.c.m.linear" package whose "RealVector" is
> for variable size sequences of elements (and is also, inconsistently,
> used as a Cartesian vector, and also as column- and row-matrix[1])
>
> It is arguable adapted for a family of problems which the developer
> probably had in mind when taking those design decisions.
>
> It would be interesting to know for which class of problems, the design
> is inappropriate, in order to clarify ideas.
>
> The main drawback of this approach is that we will loose the ability to
>> control which metric to use during clustering, however the only classes
>> which make an implicit use of this parameters are: Clusterer and
>> KmeansPlusPlusClusterer all others assumes EucledianDistance by default.
>>
>
> There is a default indeed, but all "Clusterer" implementations use
> whatever "DistanceMeasure" has been passed to the constructor.
>
> Assuming that "RealVector" knows how to compute the distance means that
> users will have to implement their own subclass of "RealVector" and
> override "getDistance(RealVector)" if they want another distance.
> Alternatively, CM would have to define all these classes.
>
> At first sight, it does not seem the right way to go...
>
> One of the possible approaches is to extend DistanceMeasure interface to be
>> able to compute distance between two vectors? After all it's only sub
>> first
>> vector from the second and compute desired norm on the result.
>>
>
> Seems good (at first sight) but (IMHO) only if we implement a new
> "CartesianVector" class unencumbered with all the cruft of "RealVector".
>
> Another possible solution is to make vector to return it's coordinates,
>> hence it avail us to use DistanceMeasure as is. Personally I do not think
>> this is good approach, since it will make no sense with sparse vectors.
>>
>
> Ruled out indeed if it conflicts with your intended usage.
>
> Last alternative this comes to my mind is to create a set of enums to
>> indicate which vector norm to use to compute distances, also do no think
>> this is very good solution, since sounds too intrusive and might break
>> backward compatibility.
>>
>
> And forward compatibility (clustering code will have to be adapted if
> another distance is added later).
>
> What do you think? Am I missing something? Is there a better possible way
>> to achieve the goal?
>>
>
> As indicated above, a practical example might help visualize the options.
>
>
> Regards,
> Gilles
>
> [1] Cf. https://issues.apache.org/jira/browse/MATH-765
>
>
>> Best regards,
>> Artem Barger.
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
Re: [math]: [MATH-1330] - KMeans clustering algorithm, doesn't
support clustering of sparse input data.
Posted by Gilles <gi...@harfang.homelinux.org>.
On Mon, 25 Apr 2016 15:52:03 +0300, Artem Barger wrote:
> Hi All,
>
> I'd like to provide a solution for [MATH-1330] issue. Before starting
> I
> have a concerns regarding the possible design and the actual
> implementation.
>
> Currently all implementations of Clusterer interface expect to
> receive
> instance of DistanceMeasure class, which used to compute distance or
> metric
> between two points. Switching clustering algorithms to work with
> Vectors
> will make this unnecessary, therefore there will be no need to
> provide
> DistanceMeasure, since Vector class already provides methods to
> compute
> vector norms.
I think that reasons for using "double[]" in the
"o.a.c.m.ml.clustering"
package were:
* simple and straightforward (fixed dimension Cartesian coordinates)
* not couple it with the "o.a.c.m.linear" package whose "RealVector"
is
for variable size sequences of elements (and is also,
inconsistently,
used as a Cartesian vector, and also as column- and row-matrix[1])
It is arguable adapted for a family of problems which the developer
probably had in mind when taking those design decisions.
It would be interesting to know for which class of problems, the design
is inappropriate, in order to clarify ideas.
> The main drawback of this approach is that we will loose the ability
> to
> control which metric to use during clustering, however the only
> classes
> which make an implicit use of this parameters are: Clusterer and
> KmeansPlusPlusClusterer all others assumes EucledianDistance by
> default.
There is a default indeed, but all "Clusterer" implementations use
whatever "DistanceMeasure" has been passed to the constructor.
Assuming that "RealVector" knows how to compute the distance means that
users will have to implement their own subclass of "RealVector" and
override "getDistance(RealVector)" if they want another distance.
Alternatively, CM would have to define all these classes.
At first sight, it does not seem the right way to go...
> One of the possible approaches is to extend DistanceMeasure interface
> to be
> able to compute distance between two vectors? After all it's only sub
> first
> vector from the second and compute desired norm on the result.
Seems good (at first sight) but (IMHO) only if we implement a new
"CartesianVector" class unencumbered with all the cruft of
"RealVector".
> Another possible solution is to make vector to return it's
> coordinates,
> hence it avail us to use DistanceMeasure as is. Personally I do not
> think
> this is good approach, since it will make no sense with sparse
> vectors.
Ruled out indeed if it conflicts with your intended usage.
> Last alternative this comes to my mind is to create a set of enums to
> indicate which vector norm to use to compute distances, also do no
> think
> this is very good solution, since sounds too intrusive and might
> break
> backward compatibility.
And forward compatibility (clustering code will have to be adapted if
another distance is added later).
> What do you think? Am I missing something? Is there a better possible
> way
> to achieve the goal?
As indicated above, a practical example might help visualize the
options.
Regards,
Gilles
[1] Cf. https://issues.apache.org/jira/browse/MATH-765
>
> Best regards,
> Artem Barger.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org