#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    1
    Rep Power
    0

    Nested Dictionary Like Object


    I am making a recommendation system using Crab.
    The example data is like

    name movie rating and so code is like

    Code:
      for user_id, item_id, rating in data_m:
            if user_id not in user_ids:
                user_ids.append(user_id)
            if item_id not in item_ids:
                item_ids.append(item_id)
            u_ix = user_ids.index(user_id) + 1
            i_ix = item_ids.index(item_id) + 1
            data_songs.setdefault(u_ix, {})
            data_songs[u_ix][i_ix] = float(rating)
    but the one I want to make is more like

    name movie genre r1 r2 r3 r4 r5.

    can someone help me create a dictionary like object for such data thanks in advance
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,996
    Rep Power
    481
    Not enough information.
    Don't feel like looking up Crab.
    What is important for this program?
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo