{"action":"created","comment":{"url":"https://api.github.com/repos/seadsystem/Backend/pulls/comments/55458701","id":55458701,"diff_hunk":"@@ -53,8 +56,17 @@ def query(parsed_url):\n         list_format = parsed_url['list_format']\n     if 'events' in parsed_url.keys():\n         events = parsed_url['events']\n+    if 'total_energy' in parsed_url.keys():\n+        total_energy = parsed_url['total_energy']\n+\n+    if classify:\n+        if device is not None and start_time is not None:\n+            model = RMF.RandomForestModel.get_model()\n+            classification = model.classify(time=start_time, serial=device_id, panel=device)\n+            return format_data(['data'], classification, json=True)\n+        raise Exception(\"Received malformed URL data: missing start_time\")","path":"DB/api/query_db.py","position":36,"original_position":36,"commit_id":"a7db97bf77cc8fefbcea1636fa11839915b2011e","original_commit_id":"a7db97bf77cc8fefbcea1636fa11839915b2011e","user":{"login":"nsokolnikov","id":8564819,"avatar_url":"https://avatars.githubusercontent.com/u/8564819?v=3","gravatar_id":"","url":"https://api.github.com/users/nsokolnikov","html_url":"https://github.com/nsokolnikov","followers_url":"https://api.github.com/users/nsokolnikov/followers","following_url":"https://api.github.com/users/nsokolnikov/following{/other_user}","gists_url":"https://api.github.com/users/nsokolnikov/gists{/gist_id}","starred_url":"https://api.github.com/users/nsokolnikov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nsokolnikov/subscriptions","organizations_url":"https://api.github.com/users/nsokolnikov/orgs","repos_url":"https://api.github.com/users/nsokolnikov/repos","events_url":"https://api.github.com/users/nsokolnikov/events{/privacy}","received_events_url":"https://api.github.com/users/nsokolnikov/received_events","type":"User","site_admin":false},"body":"Because the end-time is determined by the window size and is generated internally inside the query execute method based on the window size of the model it's trying to classify with.","created_at":"2016-03-09T01:18:58Z","updated_at":"2016-03-09T01:18:58Z","html_url":"https://github.com/seadsystem/Backend/pull/23#discussion_r55458701","pull_request_url":"https://api.github.com/repos/seadsystem/Backend/pulls/23","_links":{"self":{"href":"https://api.github.com/repos/seadsystem/Backend/pulls/comments/55458701"},"html":{"href":"https://github.com/seadsystem/Backend/pull/23#discussion_r55458701"},"pull_request":{"href":"https://api.github.com/repos/seadsystem/Backend/pulls/23"}}},"pull_request":{"url":"https://api.github.com/repos/seadsystem/Backend/pulls/23","id":61663279,"html_url":"https://github.com/seadsystem/Backend/pull/23","diff_url":"https://github.com/seadsystem/Backend/pull/23.diff","patch_url":"https://github.com/seadsystem/Backend/pull/23.patch","issue_url":"https://api.github.com/repos/seadsystem/Backend/issues/23","number":23,"state":"open","locked":false,"title":"4.2 ml< >server utilities","user":{"login":"nsokolnikov","id":8564819,"avatar_url":"https://avatars.githubusercontent.com/u/8564819?v=3","gravatar_id":"","url":"https://api.github.com/users/nsokolnikov","html_url":"https://github.com/nsokolnikov","followers_url":"https://api.github.com/users/nsokolnikov/followers","following_url":"https://api.github.com/users/nsokolnikov/following{/other_user}","gists_url":"https://api.github.com/users/nsokolnikov/gists{/gist_id}","starred_url":"https://api.github.com/users/nsokolnikov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nsokolnikov/subscriptions","organizations_url":"https://api.github.com/users/nsokolnikov/orgs","repos_url":"https://api.github.com/users/nsokolnikov/repos","events_url":"https://api.github.com/users/nsokolnikov/events{/privacy}","received_events_url":"https://api.github.com/users/nsokolnikov/received_events","type":"User","site_admin":false},"body":"Classification blackbox completed\r\nFirst model works and outputs things with properly formed requests\r\n\r\nSupport for model storing, as well as dynamic window sizing in the first model.\r\n\r\nThe window_size is the amount of data points used for classification. Large values would give kind of meaningless results as they are likely to encompass several running devices, and small values may not be as accurate. \r\n\r\nModel is a RandomForestModel from scikit-learn. The way to construct it is \r\n```model = RandomForestModel(window_size plus any arguments in baseClassifier class)```\r\n\r\nTrain it with\r\n```model.train(your_data) ```\r\nThe format of the data is shown in the testdata variable in the source code for RandomForestClassifier. \r\n\r\nClassify with \r\n```model.classify(time) ```\r\nIt will automatically get the latest window_size rows since that timestamp and classify based on that. \r\n\r\nTo do it as a request to the server:\r\n```db.sead.systems/<device_id>/start_time=<start_time>&device=<Panel selection>&classify=1 ```\r\n\r\n\r\n\r\n\r\n","created_at":"2016-03-04T03:40:12Z","updated_at":"2016-03-09T01:18:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"51918cb2d9bf992a4aacfa4c77184d8df35a3b09","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/seadsystem/Backend/pulls/23/commits","review_comments_url":"https://api.github.com/repos/seadsystem/Backend/pulls/23/comments","review_comment_url":"https://api.github.com/repos/seadsystem/Backend/pulls/comments{/number}","comments_url":"https://api.github.com/repos/seadsystem/Backend/issues/23/comments","statuses_url":"https://api.github.com/repos/seadsystem/Backend/statuses/a7db97bf77cc8fefbcea1636fa11839915b2011e","head":{"label":"seadsystem:4.2-ml<->server-utilities","ref":"4.2-ml<->server-utilities","sha":"a7db97bf77cc8fefbcea1636fa11839915b2011e","user":{"login":"seadsystem","id":7507257,"avatar_url":"https://avatars.githubusercontent.com/u/7507257?v=3","gravatar_id":"","url":"https://api.github.com/users/seadsystem","html_url":"https://github.com/seadsystem","followers_url":"https://api.github.com/users/seadsystem/followers","following_url":"https://api.github.com/users/seadsystem/following{/other_user}","gists_url":"https://api.github.com/users/seadsystem/gists{/gist_id}","starred_url":"https://api.github.com/users/seadsystem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seadsystem/subscriptions","organizations_url":"https://api.github.com/users/seadsystem/orgs","repos_url":"https://api.github.com/users/seadsystem/repos","events_url":"https://api.github.com/users/seadsystem/events{/privacy}","received_events_url":"https://api.github.com/users/seadsystem/received_events","type":"Organization","site_admin":false},"repo":{"id":25625102,"name":"Backend","full_name":"seadsystem/Backend","owner":{"login":"seadsystem","id":7507257,"avatar_url":"https://avatars.githubusercontent.com/u/7507257?v=3","gravatar_id":"","url":"https://api.github.com/users/seadsystem","html_url":"https://github.com/seadsystem","followers_url":"https://api.github.com/users/seadsystem/followers","following_url":"https://api.github.com/users/seadsystem/following{/other_user}","gists_url":"https://api.github.com/users/seadsystem/gists{/gist_id}","starred_url":"https://api.github.com/users/seadsystem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seadsystem/subscriptions","organizations_url":"https://api.github.com/users/seadsystem/orgs","repos_url":"https://api.github.com/users/seadsystem/repos","events_url":"https://api.github.com/users/seadsystem/events{/privacy}","received_events_url":"https://api.github.com/users/seadsystem/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/seadsystem/Backend","description":"","fork":false,"url":"https://api.github.com/repos/seadsystem/Backend","forks_url":"https://api.github.com/repos/seadsystem/Backend/forks","keys_url":"https://api.github.com/repos/seadsystem/Backend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/seadsystem/Backend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/seadsystem/Backend/teams","hooks_url":"https://api.github.com/repos/seadsystem/Backend/hooks","issue_events_url":"https://api.github.com/repos/seadsystem/Backend/issues/events{/number}","events_url":"https://api.github.com/repos/seadsystem/Backend/events","assignees_url":"https://api.github.com/repos/seadsystem/Backend/assignees{/user}","branches_url":"https://api.github.com/repos/seadsystem/Backend/branches{/branch}","tags_url":"https://api.github.com/repos/seadsystem/Backend/tags","blobs_url":"https://api.github.com/repos/seadsystem/Backend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/seadsystem/Backend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/seadsystem/Backend/git/refs{/sha}","trees_url":"https://api.github.com/repos/seadsystem/Backend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/seadsystem/Backend/statuses/{sha}","languages_url":"https://api.github.com/repos/seadsystem/Backend/languages","stargazers_url":"https://api.github.com/repos/seadsystem/Backend/stargazers","contributors_url":"https://api.github.com/repos/seadsystem/Backend/contributors","subscribers_url":"https://api.github.com/repos/seadsystem/Backend/subscribers","subscription_url":"https://api.github.com/repos/seadsystem/Backend/subscription","commits_url":"https://api.github.com/repos/seadsystem/Backend/commits{/sha}","git_commits_url":"https://api.github.com/repos/seadsystem/Backend/git/commits{/sha}","comments_url":"https://api.github.com/repos/seadsystem/Backend/comments{/number}","issue_comment_url":"https://api.github.com/repos/seadsystem/Backend/issues/comments{/number}","contents_url":"https://api.github.com/repos/seadsystem/Backend/contents/{+path}","compare_url":"https://api.github.com/repos/seadsystem/Backend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/seadsystem/Backend/merges","archive_url":"https://api.github.com/repos/seadsystem/Backend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/seadsystem/Backend/downloads","issues_url":"https://api.github.com/repos/seadsystem/Backend/issues{/number}","pulls_url":"https://api.github.com/repos/seadsystem/Backend/pulls{/number}","milestones_url":"https://api.github.com/repos/seadsystem/Backend/milestones{/number}","notifications_url":"https://api.github.com/repos/seadsystem/Backend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/seadsystem/Backend/labels{/name}","releases_url":"https://api.github.com/repos/seadsystem/Backend/releases{/id}","deployments_url":"https://api.github.com/repos/seadsystem/Backend/deployments","created_at":"2014-10-23T07:34:08Z","updated_at":"2016-01-27T07:29:20Z","pushed_at":"2016-03-08T03:32:55Z","git_url":"git://github.com/seadsystem/Backend.git","ssh_url":"git@github.com:seadsystem/Backend.git","clone_url":"https://github.com/seadsystem/Backend.git","svn_url":"https://github.com/seadsystem/Backend","homepage":null,"size":76232,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":4,"forks":6,"open_issues":4,"watchers":2,"default_branch":"master"}},"base":{"label":"seadsystem:master","ref":"master","sha":"3dec95b25aecb9c709f6d084a724a147b9bfb03d","user":{"login":"seadsystem","id":7507257,"avatar_url":"https://avatars.githubusercontent.com/u/7507257?v=3","gravatar_id":"","url":"https://api.github.com/users/seadsystem","html_url":"https://github.com/seadsystem","followers_url":"https://api.github.com/users/seadsystem/followers","following_url":"https://api.github.com/users/seadsystem/following{/other_user}","gists_url":"https://api.github.com/users/seadsystem/gists{/gist_id}","starred_url":"https://api.github.com/users/seadsystem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seadsystem/subscriptions","organizations_url":"https://api.github.com/users/seadsystem/orgs","repos_url":"https://api.github.com/users/seadsystem/repos","events_url":"https://api.github.com/users/seadsystem/events{/privacy}","received_events_url":"https://api.github.com/users/seadsystem/received_events","type":"Organization","site_admin":false},"repo":{"id":25625102,"name":"Backend","full_name":"seadsystem/Backend","owner":{"login":"seadsystem","id":7507257,"avatar_url":"https://avatars.githubusercontent.com/u/7507257?v=3","gravatar_id":"","url":"https://api.github.com/users/seadsystem","html_url":"https://github.com/seadsystem","followers_url":"https://api.github.com/users/seadsystem/followers","following_url":"https://api.github.com/users/seadsystem/following{/other_user}","gists_url":"https://api.github.com/users/seadsystem/gists{/gist_id}","starred_url":"https://api.github.com/users/seadsystem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seadsystem/subscriptions","organizations_url":"https://api.github.com/users/seadsystem/orgs","repos_url":"https://api.github.com/users/seadsystem/repos","events_url":"https://api.github.com/users/seadsystem/events{/privacy}","received_events_url":"https://api.github.com/users/seadsystem/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/seadsystem/Backend","description":"","fork":false,"url":"https://api.github.com/repos/seadsystem/Backend","forks_url":"https://api.github.com/repos/seadsystem/Backend/forks","keys_url":"https://api.github.com/repos/seadsystem/Backend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/seadsystem/Backend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/seadsystem/Backend/teams","hooks_url":"https://api.github.com/repos/seadsystem/Backend/hooks","issue_events_url":"https://api.github.com/repos/seadsystem/Backend/issues/events{/number}","events_url":"https://api.github.com/repos/seadsystem/Backend/events","assignees_url":"https://api.github.com/repos/seadsystem/Backend/assignees{/user}","branches_url":"https://api.github.com/repos/seadsystem/Backend/branches{/branch}","tags_url":"https://api.github.com/repos/seadsystem/Backend/tags","blobs_url":"https://api.github.com/repos/seadsystem/Backend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/seadsystem/Backend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/seadsystem/Backend/git/refs{/sha}","trees_url":"https://api.github.com/repos/seadsystem/Backend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/seadsystem/Backend/statuses/{sha}","languages_url":"https://api.github.com/repos/seadsystem/Backend/languages","stargazers_url":"https://api.github.com/repos/seadsystem/Backend/stargazers","contributors_url":"https://api.github.com/repos/seadsystem/Backend/contributors","subscribers_url":"https://api.github.com/repos/seadsystem/Backend/subscribers","subscription_url":"https://api.github.com/repos/seadsystem/Backend/subscription","commits_url":"https://api.github.com/repos/seadsystem/Backend/commits{/sha}","git_commits_url":"https://api.github.com/repos/seadsystem/Backend/git/commits{/sha}","comments_url":"https://api.github.com/repos/seadsystem/Backend/comments{/number}","issue_comment_url":"https://api.github.com/repos/seadsystem/Backend/issues/comments{/number}","contents_url":"https://api.github.com/repos/seadsystem/Backend/contents/{+path}","compare_url":"https://api.github.com/repos/seadsystem/Backend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/seadsystem/Backend/merges","archive_url":"https://api.github.com/repos/seadsystem/Backend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/seadsystem/Backend/downloads","issues_url":"https://api.github.com/repos/seadsystem/Backend/issues{/number}","pulls_url":"https://api.github.com/repos/seadsystem/Backend/pulls{/number}","milestones_url":"https://api.github.com/repos/seadsystem/Backend/milestones{/number}","notifications_url":"https://api.github.com/repos/seadsystem/Backend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/seadsystem/Backend/labels{/name}","releases_url":"https://api.github.com/repos/seadsystem/Backend/releases{/id}","deployments_url":"https://api.github.com/repos/seadsystem/Backend/deployments","created_at":"2014-10-23T07:34:08Z","updated_at":"2016-01-27T07:29:20Z","pushed_at":"2016-03-08T03:32:55Z","git_url":"git://github.com/seadsystem/Backend.git","ssh_url":"git@github.com:seadsystem/Backend.git","clone_url":"https://github.com/seadsystem/Backend.git","svn_url":"https://github.com/seadsystem/Backend","homepage":null,"size":76232,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":4,"forks":6,"open_issues":4,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/seadsystem/Backend/pulls/23"},"html":{"href":"https://github.com/seadsystem/Backend/pull/23"},"issue":{"href":"https://api.github.com/repos/seadsystem/Backend/issues/23"},"comments":{"href":"https://api.github.com/repos/seadsystem/Backend/issues/23/comments"},"review_comments":{"href":"https://api.github.com/repos/seadsystem/Backend/pulls/23/comments"},"review_comment":{"href":"https://api.github.com/repos/seadsystem/Backend/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/seadsystem/Backend/pulls/23/commits"},"statuses":{"href":"https://api.github.com/repos/seadsystem/Backend/statuses/a7db97bf77cc8fefbcea1636fa11839915b2011e"}}}}