python K-Means implementation with partial distance strategy