0

I'm refactoring a C++ code doing kmean clustering. There are two version of the code:

  1. Normal kmean
  2. Feature aligned clustering: use slightly different distance metric and update rule.

How should I implement this effectively? Method overloading (this doesn't depend on input though)

OK so this is the pseudocode doing kmean clustering. I need to implement two versions of distance and update function.

int* kmean_clustering(vector<double[10]> data)
// each row of data hold one data point
// so we have M data points of 10 dimension
{
    // Split codebook
    // Assignment step
    Find the closest codebook based on distance(distance here can be Euclidean, Mahalanobis, .....)
    //Update step
}
2
  • 2
    Can you post some code, oterwise how can we suggest how to refector it? Commented Feb 26, 2013 at 23:48
  • Is function pointer a good idea? I don't want to have Kmean_Euclidean, Kmean_Mahalanobis, Kmean_blah_blah functions Commented Feb 27, 2013 at 23:20

1 Answer 1

2

A well written code is like reading a good novel. That's why Knuth calls it as an art of programming. This book might teach you bottom-up approach of refactoring.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.