Modify the python code for the hierarchical clustering