Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Sklearn Agglomerative Hierarchical Clustering - help with array set up
I am working with sklearn's Agglomerative Hierarchical Clustering and I have a simple issue with how to set up the input array. I am following the example here:

I have a basic understanding of the numpy array but having difficulty setting this up to a rather simple use case (I have searched extensively for examples and all use randomly generated data to create array values). I would simply like to take one column of account numbers and cluster them by the dollar value (an integer, rounded to nearest dollar) in another column. I am using a CSV DictReader so you can assume I will know how to pull data from the data source and load into the array. I just need to know if creating an array with the account number in one column and the dollar amount in the other is sufficient (assuming the distance metric chosen will be used to calculate the distances between dollar values between account numbers). I believe I know how to set the label values (so that the leaves show up as corresponding account numbers) but any help there is also appreciated. Thank you!
There are some demo's here:
Larz60, thank you very much for the link. I will try to digest this but there is a lot going on in areas where I have no background (I did see this example actually and passed on it given how involved it is). My need is very simple and my hope is to find a simple approach to loading one column with integer data that clusters on the label. Thank you!
Simple example :
account_numbers = np.array(['A10', 'A20', 'A30', 'A40', 'A50', 'A60', 'A70'])
values = np.array([1234, 432, 342, 1130, 1000, 400, 700]).reshape((-1,1))

Z = hierarchy.linkage(values)
dn = hierarchy.dendrogram(Z, labels=account_numbers)
zivoni, thank you very much. I will give that a try!

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Predicting an output variable with sklearn Ccross1 1 155 Jun-04-2019, 03:11 PM
Last Post: michalmonday
  text clustering evaluation ?? khalidreemy 1 183 May-29-2019, 03:10 AM
Last Post: heiner55
  sklearn regression to excel punksnotdead 1 211 Apr-14-2019, 12:32 PM
Last Post: punksnotdead
  How convert multidimensional array to two dimensional array tkkhan44 1 300 Feb-20-2019, 05:00 AM
Last Post: scidam
  Clustering based on a variable and on a distance matrix flucoe 2 571 Dec-16-2018, 09:57 PM
Last Post: flucoe
  hierarchical MultIndex Python newpyguy 0 611 Jan-01-2018, 09:59 PM
Last Post: newpyguy
  error in script "Expected 2D array, got 1D array instead:" drogontargaryen 0 11,863 Aug-07-2017, 04:32 PM
Last Post: drogontargaryen
  sklearn imported but not recognized kerberg 6 5,981 Jun-18-2017, 12:32 PM
Last Post: snippsat

Forum Jump:

Users browsing this thread: 1 Guest(s)