title: kmeans with custom distance function or pre-calculated distance matrix
body: <p>I am using Python 2.7 and need to create k means plot for some data. </p>
  
  <p>The data is not trivial and I need to calculate the distance between the data samples with some custom distance function that I have (this is complex genetic data) and then run k means on it.</p>
  
  <p>I have managed to do this with <code>h.clustering</code> in scipy, when calculating the distance function in advance and then passing it instead of the data. </p>
  
  <p>I found <a href="http://scikit-learn.org/stable/modules/generated/sklearn.cluster.KMeans.html" rel="nofollow noreferrer">how to run the k-means with sklearn</a>, but I can not find how to use my own distance function.</p>
  
  <p>I don't have any preference for sklearn, other packages are welcome too.</p>