def assignment(): userPreferences = users.read_userpreferences() documents = docs.read() userProfiles = build_user_profiles_from(userPreferences, documents) userPredictions = build_user_predictions_from(userProfiles, documents) for username, predictions in userPredictions.iteritems(): sortedPredictions = sorted(predictions.items(), key=operator.itemgetter(1)) userPredictions[username] = sortedPredictions pprint.pprint(userPredictions)
def assignment(): userpreferences = users.read_userpreferences() documents = docs.read() documentsWithUnitWeight = np.zeros((20, 10)) for docIndex in range(len(documents)): document = documents[docIndex] documentsWithUnitWeight[docIndex] = scale_to_unit_length(document) userProfiles = build_user_profiles_from(userpreferences, documentsWithUnitWeight) userPredictions = build_user_predictions_from(userProfiles, documentsWithUnitWeight) for username, predictions in userPredictions.iteritems(): sortedPredictions = sorted(predictions.items(), key=operator.itemgetter(1)) userPredictions[username] = sortedPredictions pprint.pprint(userPredictions)