Hi Ariel.
Sorry, custom metrics for K means are not possible at the moment.
If you wanted to tweak the sklearn implementation, you would have to look into this file:
https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/cluster/k_means_.py#L413
In particular the function _labels_inertia_precompute_dense, but there might be other places (in the accompanying cython file)

You you don't have large amounts of data and efficiency is not that big a problem, you might rather want to implement kmeans from scratch. I think you can do it in <10 lines of numpy.
That might be easier than trying to adjust the sklearn implementation.

Btw, do you think that the distance will make a big difference on a sphere? Locally it is approximately Euclidean, right? Only if you have very few points and very few centers I would expect a real difference.
But maybe my intuition is not right.

Cheers,
Andy


On 01/23/2013 11:51 PM, Ariel Rokem wrote:
Hi everyone,

I am interested in using the sklearn implementation of k means to estimate clusters of unit vectors on the surface of a sphere.

This requires that the distance metric be changed from the current Euclidean distance metric to angles.

Is there any easy way to achieve that with the current implementation? If not, where would be a good place to start digging in the code to make that possible?

Thanks in advance,

Ariel


------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d


_______________________________________________
Scikit-learn-general mailing list
Scikit-learn-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
_______________________________________________
Scikit-learn-general mailing list
Scikit-learn-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

Reply via email to