Runtime error when using item_data with factorization_recommender - any tips?

User 2070 | 6/27/2015, 8:47:52 PM

I'm using the gl.factorizationrecommender.create() module, and when I pass in side data (=itemdata), I get one of two errors: (a) Runtime Exception. boost::badget: failed value get using boost::get (b) Cannot convert python object of type <type 'tuple'> to flexibletype

I get error (a) when my side data = itemdata is a single SF column of categorical items, e.g. ` iteminfo = (cuisinetype1)

cuisinetype1 = ["u'Mediterranean'", "u'Mediterranean'", "u'Mediterranean'", "u'Mediterranean'", "u'Mediterranean'", "u'Mediterranean'", "u'Mediterranean'", "u'Mediterranean'", "u'Mediterranean'", "u'Mediterranean'", "u'Basque'", "u'Basque'", "u'Basque'", "u'Basque'", "u'Basque'", "u'American (New)'", "u'American (New)'", "u'American (New)'", "u'American (New)'", "u'American (New)'", "u'American (New)'", "u'American (New)'", "u'American (New)'", ... ]

m1 = gl.factorizationrecommender.create(data,target='rating',itemid='restoid',itemdata=iteminfo) error: Runtime Exception. boost::badget: failed value get using boost::get and I get error (b) when my side data = item_data has >1 SF columns of categorical items,, e.g. iteminfo = (cuisinetype1, neighborhood1)

cuisinetype1 = ["u'Mediterranean'", "u'Mediterranean'", "u'Mediterranean'", "u'Mediterranean'", "u'Mediterranean'", "u'Mediterranean'", "u'Mediterranean'", "u'Mediterranean'", "u'Mediterranean'", "u'Mediterranean'", "u'Basque'", "u'Basque'", "u'Basque'", "u'Basque'", "u'Basque'", "u'American (New)'", "u'American (New)'", "u'American (New)'", "u'American (New)'", "u'American (New)'", "u'American (New)'", "u'American (New)'", "u'American (New)'", ... ] neighborhood_1 = ["u'North End'", "u'North End'", "u'North End'", "u'North End'", "u'North End'", "u'North End'", "u'North End'", "u'North End'", "u'North End'", "u'North End'", "u'North End'", "u'North End'", "u'North End'", "u'North End'", "u'North End'", "u'North End'", "u'North End'", "u'Roslindale Village'", "u'Roslindale Village'", "u'Roslindale Village'", "u'Roslindale Village'", "u'Roslindale Village'", '',...]

m2 = gl.factorizationrecommender.create(data,target='rating',itemid='restoid',itemdata=iteminfo) error: Cannot convert python object of type <type 'tuple'> to flexibletype ` Any idea how to address this?

Comments

User 1207 | 6/28/2015, 4:35:37 AM

Hello pniessen,

This appears to be a bug in how these types are handled in the recommender, which I will look in to tomorrow. Normally, item_data needs to be an SFrame with one of the columns being the item info and having the same name as the item. In your case, there should be an error message as the function doesn't know which column is the item column to use to match up the side info and which is the side info itself.

Try first creating an SFrame using:

item_info = gl.SFrame({"resto_id" : restaurants, "cuisine" : cuisine_type_1,
                       "neighborhood" : neighborhood_1})

Hopefully that helps! -- Hoyt


User 2070 | 7/1/2015, 3:26:59 PM

This worked perfectly, thanks!