Results 1 to 7 of 7
  1. #1
    aneuryzma is offline Member
    Join Date
    Aug 2008
    Posts
    46
    Rep Power
    0

    Default how can I compare HashMaps with different keys ?

    I have a clustering algorithm storing the clusters in HashMap<String, ArrayList<String>>.

    I need to compare it with the ground truth which is stored in another HashMap<String, ArrayList<String>>.

    The keys are not the same, because the array is created by incremental clustering, so I was wondering how can I compare the original clusters with the generated ones.

    I'm using NMI and BCUBED as clustering evaluation measures, but my problem is how to refer to the same cluster (ArrayList<String>) if they have different keys..

    any idea ?
    thanks

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,939
    Rep Power
    8

    Default

    Erm, I suppose you could get all of the values in each map and compare them?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    aneuryzma is offline Member
    Join Date
    Aug 2008
    Posts
    46
    Rep Power
    0

    Default

    Yeah but how do I compare the respective clusters ? You know what I mean ? How can I find the correct cluster and compare to the original one ?

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,939
    Rep Power
    8

    Default

    That's not really a question we can answer. We don't know any of the specifics you're working with. Is there a way to convert from one key to another? Are you just trying to compare for equality (as in, does on Map contain a certain value found in another Map)? Something else?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    aneuryzma is offline Member
    Join Date
    Aug 2008
    Posts
    46
    Rep Power
    0

    Default

    Yeah I'm comparing if each item in the map has the same content of the original map. My issue is that the items are not necessarily in the same order...

  6. #6
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,939
    Rep Power
    8

    Default

    So where exactly are you getting stuck? Do you know how to get the values of a Map? Do you know how to iterate over them? Do you know how to compare two collections?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  7. #7
    aneuryzma is offline Member
    Join Date
    Aug 2008
    Posts
    46
    Rep Power
    0

    Default

    I know how to get values of the map, I know how to iterate them. I don't know how to recognize the same cluster (HashMap value, that is an ArrayList<String>) since the keys are different between original HashMap and new generated HashMap.

    I need to compare the clusters to see how much they differ. I have a similarity measure for that, but I dunno how to compare them.

    In otherwords I need to compare the Hashmaps, which have the elements not in the same order, and with different keys.

Similar Threads

  1. Concerning HashMaps
    By hjensen in forum New To Java
    Replies: 7
    Last Post: 10-18-2010, 03:36 PM
  2. Add keys to arraylist
    By PhQ in forum New To Java
    Replies: 29
    Last Post: 07-20-2010, 01:37 PM
  3. Problems with HashMaps
    By li_bi in forum New To Java
    Replies: 13
    Last Post: 02-24-2010, 12:08 PM
  4. HashMaps get key for a specific value
    By andre1011 in forum Advanced Java
    Replies: 2
    Last Post: 03-11-2009, 02:30 AM
  5. Media Keys
    By tikigod in forum New To Java
    Replies: 0
    Last Post: 01-28-2009, 11:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •