This is the right place to ask. However, it’s hard to diagnose the problem like this. There are several things you can do to help:
-
Try to isolate a proper self-contained example of the problem - something that’s directly runnable and shows the problem right away.
-
Show the specific errors you’re getting - i.e. a complete stack trace, that corresponds to such an example.
-
Provide the code as properly formatted text, rather than an image - so that we can copy and paste it to test it out, and copy and paste parts to refer to them for discussion. Please read the pinned thread to understand how.
-
Give more context for the code, and relate it more directly to your description of the problem. For example, I can’t understand what part of your code is intended to correspond to “the euclidean distance formula” or “the new distance formula”, or whether they’re actually shown. I also don’t understand what “altered distance formula” you want to use, so I can’t possibly assess whether it’s mathematically sound to attempt k-means analysis with that formula. (Did you mean that the theta you compute after normalizing to a unit sphere, should be used as the “distance” between the points for clustering purposes? It would help to be a bit more explicit about this.)