adding kmeans to python code, this all needs much cleaning up