{"action":"created","comment":{"url":"https://api.github.com/repos/Microsoft/Recommenders/pulls/comments/244918997","pull_request_review_id":188908673,"id":244918997,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0NDkxODk5Nw==","diff_hunk":"@@ -0,0 +1,207 @@\n+# Copyright (c) Microsoft Corporation. All rights reserved.\r\n+# Licensed under the MIT License.\r\n+\r\n+'''\r\n+Generate the user/item affinity matrix from a pandas dataframe and vice versa\r\n+'''\r\n+\r\n+import pandas as pd\r\n+\r\n+import numpy as np\r\n+import random\r\n+import math\r\n+\r\n+import itertools\r\n+\r\n+from scipy.sparse import coo_matrix\r\n+import logging\r\n+\r\n+#import default parameters\r\n+from reco_utils.common.constants import (\r\n+    DEFAULT_USER_COL,\r\n+    DEFAULT_ITEM_COL,\r\n+    DEFAULT_RATING_COL,\r\n+    DEFAULT_TIMESTAMP_COL,\r\n+    PREDICTION_COL,\r\n+)\r\n+\r\n+#for logging\r\n+log = logging.getLogger(__name__)\r\n+\r\n+\r\n+class affinity_matrix:\r\n+    '''\r\n+\r\n+    Args:\r\n+        DF (pandas.DataFrame): a dataframe containing the data\r\n+        col_user: default name for user column\r\n+        col_item: default name for item column\r\n+        col_rating: default name for rating columns\r\n+        col_time: default name for timestamp columns\r\n+        save_model: if True it saves the item/user maps\r\n+        save_path: default path to save item/user maps\r\n+\r\n+    '''\r\n+\r\n+    #initialize class parameters\r\n+    def __init__(\r\n+        self,\r\n+        DF,\r\n+        col_user = DEFAULT_USER_COL,\r\n+        col_item = DEFAULT_ITEM_COL,\r\n+        col_rating = DEFAULT_RATING_COL,\r\n+        col_time = DEFAULT_TIMESTAMP_COL,\r\n+        save_model = False,\r\n+        save_path = 'saver',\r\n+        debug = False,\r\n+    ):\r\n+\r\n+        self.df = DF #dataframe\r\n+\r\n+        #pandas DF parameters\r\n+        self.col_rating = col_rating\r\n+        self.col_item = col_item\r\n+        self.col_user = col_user\r\n+\r\n+        #Options to save the model for future use\r\n+        self.save_model_ = save_model\r\n+        self.save_path_ = save_path\r\n+\r\n+    def gen_index(self):\r\n+\r\n+        '''\r\n+        Generate the user/item index\r\n+\r\n+        Returns:\r\n+            map_users, map_items: dictionaries mapping the original user/item index to matrix indices\r\n+            map_back_users, map_back_items: dictionaries to map back the matrix elements to the original\r\n+            dataframe indices\r\n+\r\n+        Basic mechanics:\r","path":"reco_utils/dataset/sparse.py","position":80,"original_position":80,"commit_id":"dde76120e777e5a2cad245d2b1b1b06dd145ea53","original_commit_id":"dde76120e777e5a2cad245d2b1b1b06dd145ea53","user":{"login":"WessZumino","id":25653652,"node_id":"MDQ6VXNlcjI1NjUzNjUy","avatar_url":"https://avatars3.githubusercontent.com/u/25653652?v=4","gravatar_id":"","url":"https://api.github.com/users/WessZumino","html_url":"https://github.com/WessZumino","followers_url":"https://api.github.com/users/WessZumino/followers","following_url":"https://api.github.com/users/WessZumino/following{/other_user}","gists_url":"https://api.github.com/users/WessZumino/gists{/gist_id}","starred_url":"https://api.github.com/users/WessZumino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WessZumino/subscriptions","organizations_url":"https://api.github.com/users/WessZumino/orgs","repos_url":"https://api.github.com/users/WessZumino/repos","events_url":"https://api.github.com/users/WessZumino/events{/privacy}","received_events_url":"https://api.github.com/users/WessZumino/received_events","type":"User","site_admin":false},"body":"you mean that `basic mechanics` should go before `Returns`? If this is the case, I need to change this everywhere. Let me know if this is what you meant.  ","created_at":"2019-01-03T06:32:29Z","updated_at":"2019-01-03T06:32:29Z","html_url":"https://github.com/Microsoft/Recommenders/pull/390#discussion_r244918997","pull_request_url":"https://api.github.com/repos/Microsoft/Recommenders/pulls/390","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/Microsoft/Recommenders/pulls/comments/244918997"},"html":{"href":"https://github.com/Microsoft/Recommenders/pull/390#discussion_r244918997"},"pull_request":{"href":"https://api.github.com/repos/Microsoft/Recommenders/pulls/390"}},"in_reply_to_id":244732750},"pull_request":{"url":"https://api.github.com/repos/Microsoft/Recommenders/pulls/390","id":241256978,"node_id":"MDExOlB1bGxSZXF1ZXN0MjQxMjU2OTc4","html_url":"https://github.com/Microsoft/Recommenders/pull/390","diff_url":"https://github.com/Microsoft/Recommenders/pull/390.diff","patch_url":"https://github.com/Microsoft/Recommenders/pull/390.patch","issue_url":"https://api.github.com/repos/Microsoft/Recommenders/issues/390","number":390,"state":"open","locked":false,"title":"Restricted Boltzmann Machine implementation in Tensorflow","user":{"login":"WessZumino","id":25653652,"node_id":"MDQ6VXNlcjI1NjUzNjUy","avatar_url":"https://avatars3.githubusercontent.com/u/25653652?v=4","gravatar_id":"","url":"https://api.github.com/users/WessZumino","html_url":"https://github.com/WessZumino","followers_url":"https://api.github.com/users/WessZumino/followers","following_url":"https://api.github.com/users/WessZumino/following{/other_user}","gists_url":"https://api.github.com/users/WessZumino/gists{/gist_id}","starred_url":"https://api.github.com/users/WessZumino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WessZumino/subscriptions","organizations_url":"https://api.github.com/users/WessZumino/orgs","repos_url":"https://api.github.com/users/WessZumino/repos","events_url":"https://api.github.com/users/WessZumino/events{/privacy}","received_events_url":"https://api.github.com/users/WessZumino/received_events","type":"User","site_admin":false},"body":"### Description\r\nRBM implementation of collaborative filtering in TF. Although the code runs on a CPU in reasonable times (few minutes), it is advised to use a GPU enabled DSVM. All time metrics reported in the notebooks have been obtained on a single GPU DSVM. \r\n\r\n### Motivation and Context\r\nIt adds neural network based,  probabilistic CF capabilities. \r\n\r\n### Checklist:\r\n- [x] My code follows the code style of this project, as detailed in our [contribution guidelines](../CONTRIBUTING).\r\n- [x] I have added tests.\r\n- [ ] I have updated the documentation accordingly.\r\n\r\n### Remarks \r\n\r\nAdditional unit tests to be added \r\n\r\n","created_at":"2018-12-28T03:18:55Z","updated_at":"2019-01-03T06:32:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9849c3b65083aa22ef221a40210a2deb466e2bf2","assignee":null,"assignees":[],"requested_reviewers":[{"login":"anargyri","id":20682858,"node_id":"MDQ6VXNlcjIwNjgyODU4","avatar_url":"https://avatars0.githubusercontent.com/u/20682858?v=4","gravatar_id":"","url":"https://api.github.com/users/anargyri","html_url":"https://github.com/anargyri","followers_url":"https://api.github.com/users/anargyri/followers","following_url":"https://api.github.com/users/anargyri/following{/other_user}","gists_url":"https://api.github.com/users/anargyri/gists{/gist_id}","starred_url":"https://api.github.com/users/anargyri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anargyri/subscriptions","organizations_url":"https://api.github.com/users/anargyri/orgs","repos_url":"https://api.github.com/users/anargyri/repos","events_url":"https://api.github.com/users/anargyri/events{/privacy}","received_events_url":"https://api.github.com/users/anargyri/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":1110003938,"node_id":"MDU6TGFiZWwxMTEwMDAzOTM4","url":"https://api.github.com/repos/Microsoft/Recommenders/labels/algorithm","name":"algorithm","color":"cc863d","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/Microsoft/Recommenders/pulls/390/commits","review_comments_url":"https://api.github.com/repos/Microsoft/Recommenders/pulls/390/comments","review_comment_url":"https://api.github.com/repos/Microsoft/Recommenders/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Microsoft/Recommenders/issues/390/comments","statuses_url":"https://api.github.com/repos/Microsoft/Recommenders/statuses/dde76120e777e5a2cad245d2b1b1b06dd145ea53","head":{"label":"Microsoft:Mrbm","ref":"Mrbm","sha":"dde76120e777e5a2cad245d2b1b1b06dd145ea53","user":{"login":"Microsoft","id":6154722,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYxNTQ3MjI=","avatar_url":"https://avatars2.githubusercontent.com/u/6154722?v=4","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":149430917,"node_id":"MDEwOlJlcG9zaXRvcnkxNDk0MzA5MTc=","name":"Recommenders","full_name":"Microsoft/Recommenders","private":false,"owner":{"login":"Microsoft","id":6154722,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYxNTQ3MjI=","avatar_url":"https://avatars2.githubusercontent.com/u/6154722?v=4","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Microsoft/Recommenders","description":"Recommender Systems","fork":false,"url":"https://api.github.com/repos/Microsoft/Recommenders","forks_url":"https://api.github.com/repos/Microsoft/Recommenders/forks","keys_url":"https://api.github.com/repos/Microsoft/Recommenders/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/Recommenders/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/Recommenders/teams","hooks_url":"https://api.github.com/repos/Microsoft/Recommenders/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/Recommenders/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/Recommenders/events","assignees_url":"https://api.github.com/repos/Microsoft/Recommenders/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/Recommenders/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/Recommenders/tags","blobs_url":"https://api.github.com/repos/Microsoft/Recommenders/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/Recommenders/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/Recommenders/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/Recommenders/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/Recommenders/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/Recommenders/languages","stargazers_url":"https://api.github.com/repos/Microsoft/Recommenders/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/Recommenders/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/Recommenders/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/Recommenders/subscription","commits_url":"https://api.github.com/repos/Microsoft/Recommenders/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/Recommenders/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/Recommenders/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/Recommenders/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/Recommenders/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/Recommenders/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/Recommenders/merges","archive_url":"https://api.github.com/repos/Microsoft/Recommenders/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/Recommenders/downloads","issues_url":"https://api.github.com/repos/Microsoft/Recommenders/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/Recommenders/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/Recommenders/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/Recommenders/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/Recommenders/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/Recommenders/releases{/id}","deployments_url":"https://api.github.com/repos/Microsoft/Recommenders/deployments","created_at":"2018-09-19T10:06:07Z","updated_at":"2019-01-03T06:15:23Z","pushed_at":"2019-01-02T15:35:32Z","git_url":"git://github.com/Microsoft/Recommenders.git","ssh_url":"git@github.com:Microsoft/Recommenders.git","clone_url":"https://github.com/Microsoft/Recommenders.git","svn_url":"https://github.com/Microsoft/Recommenders","homepage":null,"size":2916,"stargazers_count":118,"watchers_count":118,"language":"Jupyter Notebook","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":18,"mirror_url":null,"archived":false,"open_issues_count":61,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":18,"open_issues":61,"watchers":118,"default_branch":"master"}},"base":{"label":"Microsoft:staging","ref":"staging","sha":"83adfba7488c8b2e700db1bfc5133793424b2c1b","user":{"login":"Microsoft","id":6154722,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYxNTQ3MjI=","avatar_url":"https://avatars2.githubusercontent.com/u/6154722?v=4","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":149430917,"node_id":"MDEwOlJlcG9zaXRvcnkxNDk0MzA5MTc=","name":"Recommenders","full_name":"Microsoft/Recommenders","private":false,"owner":{"login":"Microsoft","id":6154722,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYxNTQ3MjI=","avatar_url":"https://avatars2.githubusercontent.com/u/6154722?v=4","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Microsoft/Recommenders","description":"Recommender Systems","fork":false,"url":"https://api.github.com/repos/Microsoft/Recommenders","forks_url":"https://api.github.com/repos/Microsoft/Recommenders/forks","keys_url":"https://api.github.com/repos/Microsoft/Recommenders/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/Recommenders/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/Recommenders/teams","hooks_url":"https://api.github.com/repos/Microsoft/Recommenders/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/Recommenders/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/Recommenders/events","assignees_url":"https://api.github.com/repos/Microsoft/Recommenders/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/Recommenders/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/Recommenders/tags","blobs_url":"https://api.github.com/repos/Microsoft/Recommenders/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/Recommenders/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/Recommenders/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/Recommenders/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/Recommenders/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/Recommenders/languages","stargazers_url":"https://api.github.com/repos/Microsoft/Recommenders/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/Recommenders/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/Recommenders/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/Recommenders/subscription","commits_url":"https://api.github.com/repos/Microsoft/Recommenders/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/Recommenders/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/Recommenders/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/Recommenders/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/Recommenders/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/Recommenders/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/Recommenders/merges","archive_url":"https://api.github.com/repos/Microsoft/Recommenders/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/Recommenders/downloads","issues_url":"https://api.github.com/repos/Microsoft/Recommenders/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/Recommenders/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/Recommenders/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/Recommenders/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/Recommenders/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/Recommenders/releases{/id}","deployments_url":"https://api.github.com/repos/Microsoft/Recommenders/deployments","created_at":"2018-09-19T10:06:07Z","updated_at":"2019-01-03T06:15:23Z","pushed_at":"2019-01-02T15:35:32Z","git_url":"git://github.com/Microsoft/Recommenders.git","ssh_url":"git@github.com:Microsoft/Recommenders.git","clone_url":"https://github.com/Microsoft/Recommenders.git","svn_url":"https://github.com/Microsoft/Recommenders","homepage":null,"size":2916,"stargazers_count":118,"watchers_count":118,"language":"Jupyter Notebook","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":18,"mirror_url":null,"archived":false,"open_issues_count":61,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":18,"open_issues":61,"watchers":118,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Microsoft/Recommenders/pulls/390"},"html":{"href":"https://github.com/Microsoft/Recommenders/pull/390"},"issue":{"href":"https://api.github.com/repos/Microsoft/Recommenders/issues/390"},"comments":{"href":"https://api.github.com/repos/Microsoft/Recommenders/issues/390/comments"},"review_comments":{"href":"https://api.github.com/repos/Microsoft/Recommenders/pulls/390/comments"},"review_comment":{"href":"https://api.github.com/repos/Microsoft/Recommenders/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Microsoft/Recommenders/pulls/390/commits"},"statuses":{"href":"https://api.github.com/repos/Microsoft/Recommenders/statuses/dde76120e777e5a2cad245d2b1b1b06dd145ea53"}},"author_association":"NONE"}}
{"actor":{"display_login":"WessZumino"}}