Skip to content
This repository has been archived by the owner on Nov 19, 2020. It is now read-only.

Dimension compare of weights to data, during kmeans and like #647

Closed
justinths opened this issue Jun 14, 2017 · 6 comments
Closed

Dimension compare of weights to data, during kmeans and like #647

justinths opened this issue Jun 14, 2017 · 6 comments

Comments

@justinths
Copy link

I tried to add pull request ...

Currently it is
if (x.Length != weights.Length)
throw new DimensionMismatchException("weights", "Data w....

I believe it should be
if (x**# [0]**.Length != weights.Length)
throw new DimensionMismatchException("weights", "Data w....

the weighting should be apply to each element in the array of arrays, not to each element in the array.

@cesarsouza
Copy link
Member

cesarsouza commented Jun 14, 2017

Hi there,

Many thanks for opening the issue! However, I have to say that the check is as intended. The vector of weights passed to the .Learn method should have the same length as the number of training instances. They are indeed per-sample weights, not per-dimension, so the check should be correct. Please, may I ask if you found a case where it doesn't work as intended?

If yes please let me know and I will investigate.

Thanks!

@justinths
Copy link
Author

Cool, thanks for taking the time to reply. So I assume if I want to increase the importance of a dimension in relation to another I need to apply that weighting myself?

I was under the impression that is what it was, but now I see the use of applying the weight across the sample.

@cesarsouza
Copy link
Member

Yes, unfortunately if you would like to increase the importance of a column you might need to apply a weighting scaling before calling K-Means. You can also try to implement a weighted Euclidean distance as well, by taking the Euclidean.cs class as a base but multiplying a weight vector before doing the sum of squares.

I might add support for this in the next release, thanks for the idea!

@cesarsouza
Copy link
Member

@justinths
Copy link
Author

Wow thanks, thats awesome.

@cesarsouza
Copy link
Member

Added in release 3.6.0.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants