{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/55592623","id":55592623,"diff_hunk":"@@ -17,15 +17,41 @@\n \n package org.apache.spark.ml.api.r\n \n+import org.apache.spark.SparkException\n import org.apache.spark.ml.{Pipeline, PipelineModel}\n import org.apache.spark.ml.attribute._\n import org.apache.spark.ml.classification.{LogisticRegression, LogisticRegressionModel}\n import org.apache.spark.ml.clustering.{KMeans, KMeansModel}\n import org.apache.spark.ml.feature.{RFormula, VectorAssembler}\n-import org.apache.spark.ml.regression.{LinearRegression, LinearRegressionModel}\n+import org.apache.spark.ml.regression._\n import org.apache.spark.sql.DataFrame\n \n private[r] object SparkRWrappers {\n+  def fitGLM(\n+      value: String,\n+      df: DataFrame,\n+      family: String,\n+      lambda: Double,\n+      solver: String): PipelineModel = {\n+    if (solver.trim != \"irls\") throw new SparkException(\"Currently only support irls\")\n+\n+    val formula = new RFormula().setFormula(value)\n+    val regex = \"^\\\\s*(\\\\w+)\\\\s*(\\\\(\\\\s*link\\\\s*=\\\\s*\\\"(\\\\w+)\\\"\\\\s*\\\\))?\\\\s*$\".r\n+    val estimator = family match {\n+      case regex(familyName, group2, linkName) =>","path":"mllib/src/main/scala/org/apache/spark/ml/r/SparkRWrappers.scala","position":26,"original_position":26,"commit_id":"1cca19e68d9ef256769594e02d123ce6e3b0bd7d","original_commit_id":"1cca19e68d9ef256769594e02d123ce6e3b0bd7d","user":{"login":"thunterdb","id":7594753,"avatar_url":"https://avatars.githubusercontent.com/u/7594753?v=3","gravatar_id":"","url":"https://api.github.com/users/thunterdb","html_url":"https://github.com/thunterdb","followers_url":"https://api.github.com/users/thunterdb/followers","following_url":"https://api.github.com/users/thunterdb/following{/other_user}","gists_url":"https://api.github.com/users/thunterdb/gists{/gist_id}","starred_url":"https://api.github.com/users/thunterdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thunterdb/subscriptions","organizations_url":"https://api.github.com/users/thunterdb/orgs","repos_url":"https://api.github.com/users/thunterdb/repos","events_url":"https://api.github.com/users/thunterdb/events{/privacy}","received_events_url":"https://api.github.com/users/thunterdb/received_events","type":"User","site_admin":false},"body":"I am confused: why do you need a regex here? I do not see anything special on the other side in R.","created_at":"2016-03-09T21:28:23Z","updated_at":"2016-03-09T21:28:23Z","html_url":"https://github.com/apache/spark/pull/11549#discussion_r55592623","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/11549","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/55592623"},"html":{"href":"https://github.com/apache/spark/pull/11549#discussion_r55592623"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/11549"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/11549","id":61859418,"html_url":"https://github.com/apache/spark/pull/11549","diff_url":"https://github.com/apache/spark/pull/11549.diff","patch_url":"https://github.com/apache/spark/pull/11549.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/11549","number":11549,"state":"open","locked":false,"title":"[SPARK-12566] [ML] [WIP] GLM model family, link function support in SparkR:::glm","user":{"login":"hhbyyh","id":7981698,"avatar_url":"https://avatars.githubusercontent.com/u/7981698?v=3","gravatar_id":"","url":"https://api.github.com/users/hhbyyh","html_url":"https://github.com/hhbyyh","followers_url":"https://api.github.com/users/hhbyyh/followers","following_url":"https://api.github.com/users/hhbyyh/following{/other_user}","gists_url":"https://api.github.com/users/hhbyyh/gists{/gist_id}","starred_url":"https://api.github.com/users/hhbyyh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hhbyyh/subscriptions","organizations_url":"https://api.github.com/users/hhbyyh/orgs","repos_url":"https://api.github.com/users/hhbyyh/repos","events_url":"https://api.github.com/users/hhbyyh/events{/privacy}","received_events_url":"https://api.github.com/users/hhbyyh/received_events","type":"User","site_admin":false},"body":"## What changes were proposed in this pull request?\r\n\r\nThis JIRA is for extending the support of MLlib's Generalized Linear Models (GLMs) to more model families and link functions in SparkR. After SPARK-12811, we should be able to wrap GeneralizedLinearRegression in SparkR with support of popular families and link functions.\r\n\r\n\r\n## How was this patch tested?\r\n\r\nWIP, some manual test\r\n\r\n","created_at":"2016-03-06T23:30:08Z","updated_at":"2016-03-09T21:28:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cb875b9da370d3c6cfc767a1b253f32b3359d241","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/11549/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/11549/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/11549/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/1cca19e68d9ef256769594e02d123ce6e3b0bd7d","head":{"label":"hhbyyh:glmR","ref":"glmR","sha":"1cca19e68d9ef256769594e02d123ce6e3b0bd7d","user":{"login":"hhbyyh","id":7981698,"avatar_url":"https://avatars.githubusercontent.com/u/7981698?v=3","gravatar_id":"","url":"https://api.github.com/users/hhbyyh","html_url":"https://github.com/hhbyyh","followers_url":"https://api.github.com/users/hhbyyh/followers","following_url":"https://api.github.com/users/hhbyyh/following{/other_user}","gists_url":"https://api.github.com/users/hhbyyh/gists{/gist_id}","starred_url":"https://api.github.com/users/hhbyyh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hhbyyh/subscriptions","organizations_url":"https://api.github.com/users/hhbyyh/orgs","repos_url":"https://api.github.com/users/hhbyyh/repos","events_url":"https://api.github.com/users/hhbyyh/events{/privacy}","received_events_url":"https://api.github.com/users/hhbyyh/received_events","type":"User","site_admin":false},"repo":{"id":29568485,"name":"spark","full_name":"hhbyyh/spark","owner":{"login":"hhbyyh","id":7981698,"avatar_url":"https://avatars.githubusercontent.com/u/7981698?v=3","gravatar_id":"","url":"https://api.github.com/users/hhbyyh","html_url":"https://github.com/hhbyyh","followers_url":"https://api.github.com/users/hhbyyh/followers","following_url":"https://api.github.com/users/hhbyyh/following{/other_user}","gists_url":"https://api.github.com/users/hhbyyh/gists{/gist_id}","starred_url":"https://api.github.com/users/hhbyyh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hhbyyh/subscriptions","organizations_url":"https://api.github.com/users/hhbyyh/orgs","repos_url":"https://api.github.com/users/hhbyyh/repos","events_url":"https://api.github.com/users/hhbyyh/events{/privacy}","received_events_url":"https://api.github.com/users/hhbyyh/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hhbyyh/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/hhbyyh/spark","forks_url":"https://api.github.com/repos/hhbyyh/spark/forks","keys_url":"https://api.github.com/repos/hhbyyh/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hhbyyh/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hhbyyh/spark/teams","hooks_url":"https://api.github.com/repos/hhbyyh/spark/hooks","issue_events_url":"https://api.github.com/repos/hhbyyh/spark/issues/events{/number}","events_url":"https://api.github.com/repos/hhbyyh/spark/events","assignees_url":"https://api.github.com/repos/hhbyyh/spark/assignees{/user}","branches_url":"https://api.github.com/repos/hhbyyh/spark/branches{/branch}","tags_url":"https://api.github.com/repos/hhbyyh/spark/tags","blobs_url":"https://api.github.com/repos/hhbyyh/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hhbyyh/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hhbyyh/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/hhbyyh/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hhbyyh/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/hhbyyh/spark/languages","stargazers_url":"https://api.github.com/repos/hhbyyh/spark/stargazers","contributors_url":"https://api.github.com/repos/hhbyyh/spark/contributors","subscribers_url":"https://api.github.com/repos/hhbyyh/spark/subscribers","subscription_url":"https://api.github.com/repos/hhbyyh/spark/subscription","commits_url":"https://api.github.com/repos/hhbyyh/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/hhbyyh/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/hhbyyh/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/hhbyyh/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/hhbyyh/spark/contents/{+path}","compare_url":"https://api.github.com/repos/hhbyyh/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hhbyyh/spark/merges","archive_url":"https://api.github.com/repos/hhbyyh/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hhbyyh/spark/downloads","issues_url":"https://api.github.com/repos/hhbyyh/spark/issues{/number}","pulls_url":"https://api.github.com/repos/hhbyyh/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/hhbyyh/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/hhbyyh/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hhbyyh/spark/labels{/name}","releases_url":"https://api.github.com/repos/hhbyyh/spark/releases{/id}","deployments_url":"https://api.github.com/repos/hhbyyh/spark/deployments","created_at":"2015-01-21T03:08:12Z","updated_at":"2016-02-04T00:47:32Z","pushed_at":"2016-03-09T08:07:19Z","git_url":"git://github.com/hhbyyh/spark.git","ssh_url":"git@github.com:hhbyyh/spark.git","clone_url":"https://github.com/hhbyyh/spark.git","svn_url":"https://github.com/hhbyyh/spark","homepage":null,"size":145483,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"ee913e6e2d58dfac20f3f06ff306081bd0e48066","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":17165658,"name":"spark","full_name":"apache/spark","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/spark","description":"Mirror of Apache Spark","fork":false,"url":"https://api.github.com/repos/apache/spark","forks_url":"https://api.github.com/repos/apache/spark/forks","keys_url":"https://api.github.com/repos/apache/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/spark/teams","hooks_url":"https://api.github.com/repos/apache/spark/hooks","issue_events_url":"https://api.github.com/repos/apache/spark/issues/events{/number}","events_url":"https://api.github.com/repos/apache/spark/events","assignees_url":"https://api.github.com/repos/apache/spark/assignees{/user}","branches_url":"https://api.github.com/repos/apache/spark/branches{/branch}","tags_url":"https://api.github.com/repos/apache/spark/tags","blobs_url":"https://api.github.com/repos/apache/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/spark/languages","stargazers_url":"https://api.github.com/repos/apache/spark/stargazers","contributors_url":"https://api.github.com/repos/apache/spark/contributors","subscribers_url":"https://api.github.com/repos/apache/spark/subscribers","subscription_url":"https://api.github.com/repos/apache/spark/subscription","commits_url":"https://api.github.com/repos/apache/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/spark/contents/{+path}","compare_url":"https://api.github.com/repos/apache/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/spark/merges","archive_url":"https://api.github.com/repos/apache/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/spark/downloads","issues_url":"https://api.github.com/repos/apache/spark/issues{/number}","pulls_url":"https://api.github.com/repos/apache/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/spark/labels{/name}","releases_url":"https://api.github.com/repos/apache/spark/releases{/id}","deployments_url":"https://api.github.com/repos/apache/spark/deployments","created_at":"2014-02-25T08:00:08Z","updated_at":"2016-03-09T21:23:48Z","pushed_at":"2016-03-09T21:08:44Z","git_url":"git://github.com/apache/spark.git","ssh_url":"git@github.com:apache/spark.git","clone_url":"https://github.com/apache/spark.git","svn_url":"https://github.com/apache/spark","homepage":null,"size":440150,"stargazers_count":7733,"watchers_count":7733,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":7055,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":401,"forks":7055,"open_issues":401,"watchers":7733,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/11549"},"html":{"href":"https://github.com/apache/spark/pull/11549"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/11549"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/11549/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/11549/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/11549/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/1cca19e68d9ef256769594e02d123ce6e3b0bd7d"}}}}