title: How would one use Kernel Density Estimation as a 1D clustering method in scikit learn?
body: <p>I need to cluster a simple univariate data set into a preset number of clusters. Technically it would be closer to binning or sorting the data since it is only 1D, but my boss is calling it clustering, so I'm going to stick to that name. 
  The current method used by the system I'm on is K-means, but that seems like overkill.</p>
  
  <p>Is there a better way of performing this task?</p>
  
  <p>Answers to some other posts are mentioning KDE (Kernel Density Estimation), but that is a density estimation method, how would that work? </p>
  
  <p>I see how KDE returns a density, but how do I tell it to split the data into bins? </p>
  
  <p>How do I have a fixed number of bins independent of the data (that's one of my requirements) ? </p>
  
  <p>More specifically, how would one pull this off using scikit learn? </p>
  
  <p>My input file looks like: </p>
  
  <pre><code> str ID     sls
   1           10
   2           11 
   3            9
   4           23
   5           21
   6           11  
   7           45
   8           20
   9           11
   10          12
  </code></pre>
  
  <p>I want to group the sls number into clusters or bins, such that:</p>
  
  <pre><code>Cluster 1: [10 11 9 11 11 12] 
  Cluster 2: [23 21 20] 
  Cluster 3: [45] 
  </code></pre>
  
  <p>And my output file will look like: </p>
  
  <pre><code> str ID     sls    Cluster ID  Cluster centroid
      1        10       1               10.66
      2        11       1               10.66
      3         9       1               10.66 
      4        23       2               21.33   
      5        21       2               21.33
      6        11       1               10.66
      7        45       3               45
      8        20       2               21.33
      9        11       1               10.66 
      10       12       1               10.66
  </code></pre>