-
Notifications
You must be signed in to change notification settings - Fork 1
User_defined_models
Answerable allows you to specify which recommendation model to use to make the recommendations with the -m|--model option.
-
Create a new
.pyfile in themodelsfolder (for example,your_model.py). -
Define the
recommendfunction in it (details below). -
a) Use the
-mor--modelwith your model's filename without extension.python answerable.py recommend -m your_model
-
b) Optionally, set it as default adding a
"model": "your_model"field to the.configfile, so you don't have to use the console option anymore.
Answerable will pass to the function the following arguments:
-
user_qa: List with the questions answered by the user.Format:
[(Question1, UserAnswer1), (Question2, UserAnswer2), ...]-
Questions:
{ "tags": [ str ], "answers": [ { "owner": { "user_id": int } } ], "score": int, "creation_date": int (timestamp), "question_id": int, "link": str, "title": str, "body": str (html) } -
Answers:
{ "is_accepted": bool, "score": int, "questions_id": int, "link": str, "title": str,/MiguelMJ/Answerable/wiki/save "body": str (html), }
-
-
feed: List with the newest questions retrieved.Format:
[Question1, Question2, ...]-
Questions:
{ "link": str, "title": str, "body": str (html), "tags": [ str ] }
-
- The format of the questions in both arguments are different because the first ones come from the API and the second ones, from the RSS feed.
- If the user includes questions that they have not answered, the
user_qapairs will have the corresponding answers asNone.
Answerable will require the function to return a pair of lists.
- The first one with the indexes of
feedsorted by the recommendation system. - The second one with the information about the recommendation for each question in
feedin their initial order.
Here's some pseudo-code to illustrate how the values should be returned:
user_qa = [ ... ]
feed = [
InterestingQuestion,
BoringQuestion,
VeryInterestingQuestion,
VeryBoringQuestion
]
indices, info = your_model.recommend(user_qa, feed)
print(indices)
# [2, 0, 1, 3]
print(info)
# [
# InterestingQuestionInfo,
# BoringQuestionInfo,
# VeryInterestingQuestionInfo,
# VeryBoringQuestionInfo
# ]If your project won't return additional information about the recommendations, then the second value returned should be None. You can compare the return values of the recommend functions in content_based_0 and content_based_1 as an example.
Home | Contributing | License | Changelog | Code