{"action":"created","issue":{"url":"https://api.github.com/repos/iit-cs579/main/issues/236","repository_url":"https://api.github.com/repos/iit-cs579/main","labels_url":"https://api.github.com/repos/iit-cs579/main/issues/236/labels{/name}","comments_url":"https://api.github.com/repos/iit-cs579/main/issues/236/comments","events_url":"https://api.github.com/repos/iit-cs579/main/issues/236/events","html_url":"https://github.com/iit-cs579/main/issues/236","id":182945475,"number":236,"title":"Issues in vectorize ","user":{"login":"vmanikes","id":16039325,"avatar_url":"https://avatars.githubusercontent.com/u/16039325?v=3","gravatar_id":"","url":"https://api.github.com/users/vmanikes","html_url":"https://github.com/vmanikes","followers_url":"https://api.github.com/users/vmanikes/followers","following_url":"https://api.github.com/users/vmanikes/following{/other_user}","gists_url":"https://api.github.com/users/vmanikes/gists{/gist_id}","starred_url":"https://api.github.com/users/vmanikes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmanikes/subscriptions","organizations_url":"https://api.github.com/users/vmanikes/orgs","repos_url":"https://api.github.com/users/vmanikes/repos","events_url":"https://api.github.com/users/vmanikes/events{/privacy}","received_events_url":"https://api.github.com/users/vmanikes/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-10-14T01:50:33Z","updated_at":"2016-10-14T02:35:17Z","closed_at":null,"body":"Hello professor \r\nCan you give me some links how the vectorize method works. I know it was discussed in clss but i am having a hard time understanding it how the matrix is getting generated. Can u provide me some links where i can i read through. Scikit documentation has a example but not a explanation."},"comment":{"url":"https://api.github.com/repos/iit-cs579/main/issues/comments/253694824","html_url":"https://github.com/iit-cs579/main/issues/236#issuecomment-253694824","issue_url":"https://api.github.com/repos/iit-cs579/main/issues/236","id":253694824,"user":{"login":"aronwc","id":3931781,"avatar_url":"https://avatars.githubusercontent.com/u/3931781?v=3","gravatar_id":"","url":"https://api.github.com/users/aronwc","html_url":"https://github.com/aronwc","followers_url":"https://api.github.com/users/aronwc/followers","following_url":"https://api.github.com/users/aronwc/following{/other_user}","gists_url":"https://api.github.com/users/aronwc/gists{/gist_id}","starred_url":"https://api.github.com/users/aronwc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aronwc/subscriptions","organizations_url":"https://api.github.com/users/aronwc/orgs","repos_url":"https://api.github.com/users/aronwc/repos","events_url":"https://api.github.com/users/aronwc/events{/privacy}","received_events_url":"https://api.github.com/users/aronwc/received_events","type":"User","site_admin":false},"created_at":"2016-10-14T02:35:17Z","updated_at":"2016-10-14T02:35:17Z","body":"See the documentation on csr_matrix: https://goo.gl/f5TiF1 . There are examples of constructing and using these sparse matrices.\r\n\r\nWhen constructing a csr_matrix, it's usually best to first create the data/rows/cols variables, then pass them to the constructor csr_matrix((data, (row_ind, col_ind)). \r\n\r\nThe example they give is:\r\n\r\n```python\r\n>>> row = np.array([0, 0, 1, 2, 2, 2])\r\n>>> col = np.array([0, 2, 2, 0, 1, 2])\r\n>>> data = np.array([1, 2, 3, 4, 5, 6])\r\n>>> csr_matrix((data, (row, col)), shape=(3, 3)).toarray()\r\narray([[1, 0, 2],\r\n       [0, 0, 3],\r\n       [4, 5, 6]])\r\n```\r\n\r\nIn the `vectorize` method, you'll loop through each document (represented as a list of tokens). You'll then call `featurize` on each document to create the feature list. Along the way, you'll need to store a mapping from each feature name to an integer, representing the column for that feature.\r\n\r\nFor example, for two documents:\r\n\r\n```python\r\n>>> docs = [['i', 'like', 'movies'], ['you', 'like', 'shows']]\r\n>>> features = [{'token=i': 1, 'token=like': 1, 'token=movies': 1},\r\n... {'token=you': 1, 'token=like': 1, 'token=shows': 1}]\r\n>>> vocab = {'token=i': 0, 'token=like': 1, 'token=movies': 2, 'token=you': 3, 'token=shows': 4}\r\n```\r\nWith those objects, you should then be able to construct the matrix.\r\n\r\nAlso keep in mind the `min_freq` and `vocab` parameters, which will complicate the above a little bit.\r\n\r\n"}}
{"actor":{"display_login":"aronwc"}}