{"action":"created","issue":{"url":"https://api.github.com/repos/mlpack/mlpack/issues/732","repository_url":"https://api.github.com/repos/mlpack/mlpack","labels_url":"https://api.github.com/repos/mlpack/mlpack/issues/732/labels{/name}","comments_url":"https://api.github.com/repos/mlpack/mlpack/issues/732/comments","events_url":"https://api.github.com/repos/mlpack/mlpack/issues/732/events","html_url":"https://github.com/mlpack/mlpack/pull/732","id":166971789,"number":732,"title":"Heaps for mlpack!","user":{"login":"MarcosPividori","id":4282009,"avatar_url":"https://avatars.githubusercontent.com/u/4282009?v=3","gravatar_id":"","url":"https://api.github.com/users/MarcosPividori","html_url":"https://github.com/MarcosPividori","followers_url":"https://api.github.com/users/MarcosPividori/followers","following_url":"https://api.github.com/users/MarcosPividori/following{/other_user}","gists_url":"https://api.github.com/users/MarcosPividori/gists{/gist_id}","starred_url":"https://api.github.com/users/MarcosPividori/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MarcosPividori/subscriptions","organizations_url":"https://api.github.com/users/MarcosPividori/orgs","repos_url":"https://api.github.com/users/MarcosPividori/repos","events_url":"https://api.github.com/users/MarcosPividori/events{/privacy}","received_events_url":"https://api.github.com/users/MarcosPividori/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2016-07-22T05:18:27Z","updated_at":"2016-07-22T18:21:52Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/mlpack/mlpack/pulls/732","html_url":"https://github.com/mlpack/mlpack/pull/732","diff_url":"https://github.com/mlpack/mlpack/pull/732.diff","patch_url":"https://github.com/mlpack/mlpack/pull/732.patch"},"body":"Hi,\r\nI realized in many parts of the code, we keep track of  the best k candidates visited.\r\nIn this situation, it is not necessary to keep a sorted list of the k elements. We only need to know the value of the worst candidate, so we can compare it with new elements and know if we must insert them to this list.\r\nSo, instead of maintaining a sorted list, a better approach is to use a priority queue.\r\nWhen we finish looking for the best k candidates, we can easily get a sorted list from the priority queue, taking the top elements and saving them in reverse order.\r\nIf we use a greater value of k, the difference in performance is greater and we have a considerably faster algorithm.\r\nThanks!\r\nMarcos"},"comment":{"url":"https://api.github.com/repos/mlpack/mlpack/issues/comments/234618428","html_url":"https://github.com/mlpack/mlpack/pull/732#issuecomment-234618428","issue_url":"https://api.github.com/repos/mlpack/mlpack/issues/732","id":234618428,"user":{"login":"MarcosPividori","id":4282009,"avatar_url":"https://avatars.githubusercontent.com/u/4282009?v=3","gravatar_id":"","url":"https://api.github.com/users/MarcosPividori","html_url":"https://github.com/MarcosPividori","followers_url":"https://api.github.com/users/MarcosPividori/followers","following_url":"https://api.github.com/users/MarcosPividori/following{/other_user}","gists_url":"https://api.github.com/users/MarcosPividori/gists{/gist_id}","starred_url":"https://api.github.com/users/MarcosPividori/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MarcosPividori/subscriptions","organizations_url":"https://api.github.com/users/MarcosPividori/orgs","repos_url":"https://api.github.com/users/MarcosPividori/repos","events_url":"https://api.github.com/users/MarcosPividori/events{/privacy}","received_events_url":"https://api.github.com/users/MarcosPividori/received_events","type":"User","site_admin":false},"created_at":"2016-07-22T18:21:52Z","updated_at":"2016-07-22T18:21:52Z","body":"Yes, that code looks really different to the actual version!"}}
{"actor":{"display_login":"MarcosPividori"}}