item_id is not read as a parameter in recommend.create

User 597 | 8/30/2014, 2:45:38 AM

So I updated the module to 0.9.1 version, and I got the following error after adjusting the changes.

File "recommender.py", line 158, in graphlabrecommendations model = gl.recommender.create(observationdata = train, userid = userid, itemid = productid, target_id = values, method = aMethod)

File "/Users/chlee021690/anaconda/lib/python2.7/site-packages/graphlab/toolkits/recommender/util.py", line 363, in create ax.plot(list(prcurve['recall']), list(prcurve['precision']),

File "/Users/chlee021690/anaconda/lib/python2.7/site-packages/graphlab/toolkits/main.py", line 102, in run raise ToolkitError(str(message))

ToolkitError: Requested option item_id not declared in model.

Comments

User 19 | 8/30/2014, 6:30:04 AM

Can you provide a small, reproducible example? What is the value of 'aMethod' in your code?


User 597 | 8/30/2014, 2:31:45 PM

Thank you for your help. Below is the code snippet.

import preprocessing
aData = gl.SFrame(aData)
train, test= preprocessing.graphlab_split_data(aData, cv_ratio)
user = gl.SArray([user])

myuser_id = needed_param['user_id']
print myuser_id
myitem_id = needed_param['item_id']
print myitem_id
my_values = needed_param['ratings']
print my_values

print train.column_names()
print test.column_names()

# make models
methods = ['matrix_factorization', 'linear_model', 'item_similarity', 'popularity', 'item_means']
sim_type = ['jaccard', 'cosine', 'pearson']
models = []
for aMethod in methods:
    	print aMethod
    	if(aMethod != 'item_similarity'):
        		model = gl.recommender.create(observation_data = train, user_id = myuser_id, item_id = myitem_id, target = my_values, method = aMethod)
       		models.append(model)
    	else:
        		for aSim in sim_type:
            		sim_model = gl.recommender.create(observation_data = train, user_id = myuser_id, target = my_values, method = aMethod, similarity_type = aSim)
            		models.append(sim_model)

User 597 | 8/30/2014, 2:32:54 PM

I tried to make indentation in wherever it was necessary, but it failed :. But to answer your question, aMethod is the name of the models I am using for the system (matrixfactorization, itemsimilarity, etc)


User 19 | 8/30/2014, 4:51:48 PM

In your second call to gl.recommender.create, you are missing the item_id argument. It should be:

simmodel = gl.recommender.create(observationdata = train, userid = myuserid, itemid=myitemid, target = myvalues, method = aMethod, similaritytype = aSim)

Let us know if that fixes things.