{"action":"created","comment":{"url":"https://api.github.com/repos/frbl/OnlineSuperLearner/pulls/comments/197020650","pull_request_review_id":130676932,"id":197020650,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5NzAyMDY1MA==","diff_hunk":"@@ -0,0 +1,240 @@\n+#' ML.SpeedGLMSGD\n+#'\n+#' Base class for Speedglm in combination with SGD machine learning model.\n+#'\n+#' @docType class\n+#' @importFrom R6 R6Class\n+#' @importFrom Speedglm speedglm\n+#' @importFrom MASS write.matrix\n+#' @include ML.Base.R\n+#' @section Methods:\n+#' \\describe{\n+#'   \\item{\\code{initialize(weights = NULL, \n+#'offset = NULL, \n+#'sparse = NULL, \n+#'set.default = list(), \n+#'method = c(\"eigen\", \"Cholesky\", \"qr\"), \n+#'model = FALSE, \n+#' y = FALSE, \n+#'fitted = FALSE, \n+#'subset = NULL\n+#'family=binomial(link=logit)\n+#'\n+\n+#'\n+#'     @param family string the statistic algorithm used to\n+#'      optimize.\n+#'\n+#'   }\n+#'\n+#'   \\item{\\code{get_nthread}}{\n+#'     Active method. Function that returns the number of threads the speedlm\n+#'     algorithm runs on.\n+#'   }\n+#'\n+#'   \\item{\\code{get_validity}}{\n+#'     Active method. Function that shows wheter the current configuration of\n+#'     the initialisation is valid. The function returns \\code{TRUE} if everything is\n+#'     specified correctly. It will throw an error (with the error messages)\n+#'     when something is misspecified. This function is automatically called\n+#'     after initialization.\n+#'   }\n+#' }\n+#' \n+#' ## TO DO implement \n+ML.SpeedGLMSGD <- R6Class(\"ML.SpeedGLMSGD\",\n+  inherit = ML.Base,\n+  public =\n+    list(\n+      fitfunname='speedglm',\n+      lmclass='speedglm',\n+      initialize = function() {\n+        self$get_validity\n+        super$initialize()\n+        \n+      }\n+    ),  active =\n+    list(get_file_name = function() {\n+         return(private$file_name)\n+    }\n+    \n+      ),\n+  private =\n+      list(\n+           alpha = 0.001,\n+           loop = 1000,\n+           file_name = file.path('output', 'coef.prn'),\n+      \n+      do.predict = function(X_mat,Y_vals,save_model=FALSE,m.fit=NULL) {\n+        X_mat <- data.frame(X_mat)\n+        Y_vals <-data.frame(Y_vals)\n+        data<-cbind.data.frame(Y_vals,X_mat)\n+        \n+        #rename colums to standardize depending on the number of columns\n+        for (i in (1:(ncol(data)))){\n+          if (i == 1){\n+            colnames(data)[i] <- \"Y\"\n+          }\n+          if (i>1){\n+            colnames(data)[i]<-paste(\"x\",i-1, sep = \"\")\n+          }\n+        }\n+        \n+        \n+        if(!is.null(m.fit)){\n+          result<-private$predict_lr(X_mat,m.fit)\n+          \n+        }\n+        else {\n+            try(m.fit<-private$read_model(),silent = TRUE)\n+            if (!is.null(m.fit)){\n+             \n+            result<-private$predict_lr(X_mat,m.fit)\n+        }\n+          else {\n+            ## fit the model\n+            m.fit<- coef(private$do.fit(X_mat = X_mat, Y_vals = Y_vals, save_model = FALSE ))\n+            result<-private$predict_lr(X_mat,m.fit)\n+          }\n+        }\n+        \n+        if (save_model){\n+           private$save_model(model=coef(m.fit))\n+        }\n+        \n+        return(result)\n+      },\n+\n+      do.update = function(X_mat, Y_vals,save_model=FALSE, m.fit=NULL, ...) {\n+        # speedlm uses the coefficients of the last model to update with more data.\n+        X_mat <- data.frame(X_mat)\n+        Y_vals <- data.frame(Y_vals)\n+        data <- cbind.data.frame(Y_vals,X_mat)\n+        \n+        \n+        #rename colums to standardize depending on the number of columns\n+        for (i in (1:(ncol(data)))){\n+          if (i == 1){\n+            colnames(data)[i] <- \"Y\"\n+          }\n+          if (i>1){\n+            colnames(data)[i]<-paste(\"x\",i-1, sep = \"\")\n+          }\n+        }\n+       \n+       \n+        if(!is.null(m.fit)){\n+          result<-private$update_coef(X_mat,Y_vals,coef=m.fit,alpha=private$alpha,loop=private$loop)\n+          }\n+          else {\n+            try(m.fit<-private$read_model(),silent = TRUE)","path":"R/ML.SpeedGLMSGD.R","position":130,"original_position":130,"commit_id":"52a04c03425a6e1b9e871e89c192a905dc9967c2","original_commit_id":"52a04c03425a6e1b9e871e89c192a905dc9967c2","user":{"login":"frbl","id":617574,"node_id":"MDQ6VXNlcjYxNzU3NA==","avatar_url":"https://avatars1.githubusercontent.com/u/617574?v=4","gravatar_id":"","url":"https://api.github.com/users/frbl","html_url":"https://github.com/frbl","followers_url":"https://api.github.com/users/frbl/followers","following_url":"https://api.github.com/users/frbl/following{/other_user}","gists_url":"https://api.github.com/users/frbl/gists{/gist_id}","starred_url":"https://api.github.com/users/frbl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frbl/subscriptions","organizations_url":"https://api.github.com/users/frbl/orgs","repos_url":"https://api.github.com/users/frbl/repos","events_url":"https://api.github.com/users/frbl/events{/privacy}","received_events_url":"https://api.github.com/users/frbl/received_events","type":"User","site_admin":false},"body":"I'm pretty sure this is a bad idea. A try with a silent catch if it fails? Why do we need this?","created_at":"2018-06-21T06:12:17Z","updated_at":"2018-06-21T06:30:54Z","html_url":"https://github.com/frbl/OnlineSuperLearner/pull/64#discussion_r197020650","pull_request_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/pulls/64","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/frbl/OnlineSuperLearner/pulls/comments/197020650"},"html":{"href":"https://github.com/frbl/OnlineSuperLearner/pull/64#discussion_r197020650"},"pull_request":{"href":"https://api.github.com/repos/frbl/OnlineSuperLearner/pulls/64"}}},"pull_request":{"url":"https://api.github.com/repos/frbl/OnlineSuperLearner/pulls/64","id":196344099,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk2MzQ0MDk5","html_url":"https://github.com/frbl/OnlineSuperLearner/pull/64","diff_url":"https://github.com/frbl/OnlineSuperLearner/pull/64.diff","patch_url":"https://github.com/frbl/OnlineSuperLearner/pull/64.patch","issue_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/issues/64","number":64,"state":"open","locked":false,"title":"SpeedGLMSGD","user":{"login":"frbl","id":617574,"node_id":"MDQ6VXNlcjYxNzU3NA==","avatar_url":"https://avatars1.githubusercontent.com/u/617574?v=4","gravatar_id":"","url":"https://api.github.com/users/frbl","html_url":"https://github.com/frbl","followers_url":"https://api.github.com/users/frbl/followers","following_url":"https://api.github.com/users/frbl/following{/other_user}","gists_url":"https://api.github.com/users/frbl/gists{/gist_id}","starred_url":"https://api.github.com/users/frbl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frbl/subscriptions","organizations_url":"https://api.github.com/users/frbl/orgs","repos_url":"https://api.github.com/users/frbl/repos","events_url":"https://api.github.com/users/frbl/events{/privacy}","received_events_url":"https://api.github.com/users/frbl/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-06-21T06:05:02Z","updated_at":"2018-06-21T06:30:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4cc6146b554dd7948566089a67074217d4d09124","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/pulls/64/commits","review_comments_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/pulls/64/comments","review_comment_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/pulls/comments{/number}","comments_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/issues/64/comments","statuses_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/statuses/52a04c03425a6e1b9e871e89c192a905dc9967c2","head":{"label":"frbl:td-sgd","ref":"td-sgd","sha":"52a04c03425a6e1b9e871e89c192a905dc9967c2","user":{"login":"frbl","id":617574,"node_id":"MDQ6VXNlcjYxNzU3NA==","avatar_url":"https://avatars1.githubusercontent.com/u/617574?v=4","gravatar_id":"","url":"https://api.github.com/users/frbl","html_url":"https://github.com/frbl","followers_url":"https://api.github.com/users/frbl/followers","following_url":"https://api.github.com/users/frbl/following{/other_user}","gists_url":"https://api.github.com/users/frbl/gists{/gist_id}","starred_url":"https://api.github.com/users/frbl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frbl/subscriptions","organizations_url":"https://api.github.com/users/frbl/orgs","repos_url":"https://api.github.com/users/frbl/repos","events_url":"https://api.github.com/users/frbl/events{/privacy}","received_events_url":"https://api.github.com/users/frbl/received_events","type":"User","site_admin":false},"repo":{"id":80179809,"node_id":"MDEwOlJlcG9zaXRvcnk4MDE3OTgwOQ==","name":"OnlineSuperLearner","full_name":"frbl/OnlineSuperLearner","owner":{"login":"frbl","id":617574,"node_id":"MDQ6VXNlcjYxNzU3NA==","avatar_url":"https://avatars1.githubusercontent.com/u/617574?v=4","gravatar_id":"","url":"https://api.github.com/users/frbl","html_url":"https://github.com/frbl","followers_url":"https://api.github.com/users/frbl/followers","following_url":"https://api.github.com/users/frbl/following{/other_user}","gists_url":"https://api.github.com/users/frbl/gists{/gist_id}","starred_url":"https://api.github.com/users/frbl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frbl/subscriptions","organizations_url":"https://api.github.com/users/frbl/orgs","repos_url":"https://api.github.com/users/frbl/repos","events_url":"https://api.github.com/users/frbl/events{/privacy}","received_events_url":"https://api.github.com/users/frbl/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/frbl/OnlineSuperLearner","description":null,"fork":false,"url":"https://api.github.com/repos/frbl/OnlineSuperLearner","forks_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/forks","keys_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/keys{/key_id}","collaborators_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/teams","hooks_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/hooks","issue_events_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/issues/events{/number}","events_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/events","assignees_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/assignees{/user}","branches_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/branches{/branch}","tags_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/tags","blobs_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/git/refs{/sha}","trees_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/git/trees{/sha}","statuses_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/statuses/{sha}","languages_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/languages","stargazers_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/stargazers","contributors_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/contributors","subscribers_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/subscribers","subscription_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/subscription","commits_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/commits{/sha}","git_commits_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/git/commits{/sha}","comments_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/comments{/number}","issue_comment_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/issues/comments{/number}","contents_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/contents/{+path}","compare_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/compare/{base}...{head}","merges_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/merges","archive_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/downloads","issues_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/issues{/number}","pulls_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/pulls{/number}","milestones_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/milestones{/number}","notifications_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/labels{/name}","releases_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/releases{/id}","deployments_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/deployments","created_at":"2017-01-27T04:01:02Z","updated_at":"2018-06-07T14:30:40Z","pushed_at":"2018-06-21T06:05:02Z","git_url":"git://github.com/frbl/OnlineSuperLearner.git","ssh_url":"git@github.com:frbl/OnlineSuperLearner.git","clone_url":"https://github.com/frbl/OnlineSuperLearner.git","svn_url":"https://github.com/frbl/OnlineSuperLearner","homepage":null,"size":2034,"stargazers_count":6,"watchers_count":6,"language":"R","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":3,"open_issues":3,"watchers":6,"default_branch":"master"}},"base":{"label":"frbl:master","ref":"master","sha":"8d36c4ae946690f53c125362c8081d1039ee2947","user":{"login":"frbl","id":617574,"node_id":"MDQ6VXNlcjYxNzU3NA==","avatar_url":"https://avatars1.githubusercontent.com/u/617574?v=4","gravatar_id":"","url":"https://api.github.com/users/frbl","html_url":"https://github.com/frbl","followers_url":"https://api.github.com/users/frbl/followers","following_url":"https://api.github.com/users/frbl/following{/other_user}","gists_url":"https://api.github.com/users/frbl/gists{/gist_id}","starred_url":"https://api.github.com/users/frbl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frbl/subscriptions","organizations_url":"https://api.github.com/users/frbl/orgs","repos_url":"https://api.github.com/users/frbl/repos","events_url":"https://api.github.com/users/frbl/events{/privacy}","received_events_url":"https://api.github.com/users/frbl/received_events","type":"User","site_admin":false},"repo":{"id":80179809,"node_id":"MDEwOlJlcG9zaXRvcnk4MDE3OTgwOQ==","name":"OnlineSuperLearner","full_name":"frbl/OnlineSuperLearner","owner":{"login":"frbl","id":617574,"node_id":"MDQ6VXNlcjYxNzU3NA==","avatar_url":"https://avatars1.githubusercontent.com/u/617574?v=4","gravatar_id":"","url":"https://api.github.com/users/frbl","html_url":"https://github.com/frbl","followers_url":"https://api.github.com/users/frbl/followers","following_url":"https://api.github.com/users/frbl/following{/other_user}","gists_url":"https://api.github.com/users/frbl/gists{/gist_id}","starred_url":"https://api.github.com/users/frbl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frbl/subscriptions","organizations_url":"https://api.github.com/users/frbl/orgs","repos_url":"https://api.github.com/users/frbl/repos","events_url":"https://api.github.com/users/frbl/events{/privacy}","received_events_url":"https://api.github.com/users/frbl/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/frbl/OnlineSuperLearner","description":null,"fork":false,"url":"https://api.github.com/repos/frbl/OnlineSuperLearner","forks_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/forks","keys_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/keys{/key_id}","collaborators_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/teams","hooks_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/hooks","issue_events_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/issues/events{/number}","events_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/events","assignees_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/assignees{/user}","branches_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/branches{/branch}","tags_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/tags","blobs_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/git/refs{/sha}","trees_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/git/trees{/sha}","statuses_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/statuses/{sha}","languages_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/languages","stargazers_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/stargazers","contributors_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/contributors","subscribers_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/subscribers","subscription_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/subscription","commits_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/commits{/sha}","git_commits_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/git/commits{/sha}","comments_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/comments{/number}","issue_comment_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/issues/comments{/number}","contents_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/contents/{+path}","compare_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/compare/{base}...{head}","merges_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/merges","archive_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/downloads","issues_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/issues{/number}","pulls_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/pulls{/number}","milestones_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/milestones{/number}","notifications_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/labels{/name}","releases_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/releases{/id}","deployments_url":"https://api.github.com/repos/frbl/OnlineSuperLearner/deployments","created_at":"2017-01-27T04:01:02Z","updated_at":"2018-06-07T14:30:40Z","pushed_at":"2018-06-21T06:05:02Z","git_url":"git://github.com/frbl/OnlineSuperLearner.git","ssh_url":"git@github.com:frbl/OnlineSuperLearner.git","clone_url":"https://github.com/frbl/OnlineSuperLearner.git","svn_url":"https://github.com/frbl/OnlineSuperLearner","homepage":null,"size":2034,"stargazers_count":6,"watchers_count":6,"language":"R","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":3,"open_issues":3,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/frbl/OnlineSuperLearner/pulls/64"},"html":{"href":"https://github.com/frbl/OnlineSuperLearner/pull/64"},"issue":{"href":"https://api.github.com/repos/frbl/OnlineSuperLearner/issues/64"},"comments":{"href":"https://api.github.com/repos/frbl/OnlineSuperLearner/issues/64/comments"},"review_comments":{"href":"https://api.github.com/repos/frbl/OnlineSuperLearner/pulls/64/comments"},"review_comment":{"href":"https://api.github.com/repos/frbl/OnlineSuperLearner/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/frbl/OnlineSuperLearner/pulls/64/commits"},"statuses":{"href":"https://api.github.com/repos/frbl/OnlineSuperLearner/statuses/52a04c03425a6e1b9e871e89c192a905dc9967c2"}},"author_association":"OWNER"}}
{"actor":{"display_login":"frbl"}}