title: Unsupported Operand Types for /: 'str' and 'float'
body: <p>I'm having a bit of trouble with understanding this error message here...</p>
  
  <p>I have been using the sklearn machine learning tools on some of my data recently. I've tried outputting the Silhouette coefficient for my data, using the following code below:</p>
  
  <pre><code>distmat = []
  for row in distmat_csv:
      distmat.append(row[1:])
  in_distmat.close()
  
  distmat_array = np.array(distmat, dtype=object)
  print distmat_array
  
  
  out_metricsfile = open('Influenza A All Subtypes Human Strains %s in %s Clustering Metrics.txt' % (name1, name2), 'w+') 
  out_metricsfile.write('%s in %s Clustering Metrics \n' % (name1, name2))
  out_metricsfile.write('Estimated number of clusters: %d \n' % n_clusters)
  out_metricsfile.write("Silhouette Coefficient: %0.3f \n"
        % metrics.silhouette_score(distmat_array, labels, metric='precomputed'))
  out_metricsfile.close()
  </code></pre>
  
  <p>The distmat array is just a series of numbers which I read from a CSV file. It looks something like this:</p>
  
  <pre><code>[[0.000000 0.614841 0.613074 ..., 0.007067 0.007067 0.010601]
   [0.614841 0.000000 0.012367 ..., 0.616608 0.613074 0.611307]
   [0.613074 0.012367 0.000000 ..., 0.614841 0.611307 0.609541]
   ..., 
   [0.007067 0.616608 0.614841 ..., 0.000000 0.010601 0.014134]
   [0.007067 0.613074 0.611307 ..., 0.010601 0.000000 0.010601]
   [0.010601 0.611307 0.609541 ..., 0.014134 0.010601 0.000000]]
  </code></pre>
  
  <p>The error message that gets returned looks as such:</p>
  
  <pre><code>Traceback (most recent call last):
    File "script9-perform-affinity-propagation-and-display.py", line 92, in &lt;module&gt;
      % metrics.silhouette_score(distmat_array, labels, metric='precomputed'))
    File "/Library/Python/2.7/site-packages/scikit_learn-0.13.1-py2.7-macosx-10.8-intel.egg/sklearn/metrics/cluster/unsupervised.py", line 84, in silhouette_score
      return np.mean(silhouette_samples(X, labels, metric=metric, **kwds))
    File "/Library/Python/2.7/site-packages/scikit_learn-0.13.1-py2.7-macosx-10.8-intel.egg/sklearn/metrics/cluster/unsupervised.py", line 146, in silhouette_samples
      for i in range(n)])
    File "/Library/Python/2.7/site-packages/scikit_learn-0.13.1-py2.7-macosx-10.8-intel.egg/sklearn/metrics/cluster/unsupervised.py", line 176, in _intra_cluster_distance
      a = np.mean(distances_row[mask])
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/fromnumeric.py", line 2374, in mean
      return mean(axis, dtype, out)
  TypeError: unsupported operand type(s) for /: 'str' and 'float'
  </code></pre>
  
  <p>I'm stuck at understanding the error message. How do I know where I've gone wrong? And if anybody is kind enough, where did I go wrong here?</p>