Giter Club home page Giter Club logo

Comments (4)

jasonlaska avatar jasonlaska commented on May 24, 2024

Hi @marcosterland,

In your example, ang is of shape ang.reshape((-1, 1)).shape = (300, 1) so it is a single vector there is not much to cluster.

The scipy.stats.vonmises routine only samples from a univariate vMF distribution. If you are trying to sample from a higher dimension mixture of vMF distribution, I recommend starting from this example: https://github.com/clara-labs/spherecluster/blob/develop/examples/small_mix_3d.py#L19-L36 and working with something like https://github.com/clara-labs/spherecluster/blob/develop/spherecluster/util.py .

cheers,
Jason

from spherecluster.

jasonlaska avatar jasonlaska commented on May 24, 2024

Actually I guess it's 300 vectors of length 1. In this case, normalizing each length-1 vector will result in the value 1 for each vector, making the exercise uneventful (which is why you get

[[ 1.]
 [ 1.]
 [ 1.]]

as output).

from spherecluster.

marcosterland avatar marcosterland commented on May 24, 2024

Thanks for your quick reply @jasonlaska .
It does make sense to cluster 1-D data. And in fact, the KMeans from scikit-learn finds the correct centers [[1.] [3.] [5.]] on the generated data.
But the scikit-learn KMeans uses standard Euclidean distance instead of the circular, so it's not applicable on e.g. angles.

from spherecluster.

jasonlaska avatar jasonlaska commented on May 24, 2024

I refer you to https://en.wikipedia.org/wiki/Cosine_similarity, the cosine between any two scalars is going to be same (as they all lie on the same axis, the angle between all of them is 0); similarly the inner product between then (just multiplication) normalized by their abs values (just multiplication) will always result in 1 or -1. Since the cosine distance/similarity does not take into account scale (as the euclidean distance does), it doesn't make sense to cluster scalars in this way unless they are complex scalars of the form a + b * i (and I'm not sure this package will handle that case).

I believe there might be a way to use the cosine distance in scikit-learn's k-means, you might want to give that a try.

from spherecluster.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.