GitHub PullRequestReviewCommentEvent at 2014-07-14 03:26:59
Repository: spark
Actor: mengxr
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/14862909","id":14862909,"diff_hunk":"@@ -69,7 +69,54 @@ println(\"Within Set Sum of Squared Errors = \" + WSSSE)\n All of MLlib's methods use Java-friendly types, so you can import and call them there the same\n way you do in Scala. The only caveat is that the methods take Scala RDD objects, while the\n Spark Java API uses a separate `JavaRDD` class. You can convert a Java RDD to a Scala one by\n-calling `.rdd()` on your `JavaRDD` object.\n+calling `.rdd()` on your `JavaRDD` object. A standalone application example\n+that is equivalent to the provided example in Scala is given bellow:\n+\n+{% highlight java %}\n+import org.apache.spark.api.java.*;\n+import org.apache.spark.SparkConf;\n+import org.apache.spark.api.java.function.Function;\n+import org.apache.spark.mllib.clustering.KMeans;\n+import org.apache.spark.mllib.clustering.KMeansModel;\n+import org.apache.spark.mllib.linalg.Vectors;\n+import org.apache.spark.mllib.linalg.Vector;\n+\n+public class KMeansExample {\n+  public static void main(String[] args) {\n+    SparkConf conf = new SparkConf().setAppName(\"K-means Example\");\n+    JavaSparkContext sc = new JavaSparkContext(conf);\n+\n+    // Load and parse data\n+    String path = \"{SPARK_HOME}/data/kmeans_data.txt\";\n+    JavaRDD<String> data = sc.textFile(path);\n+    JavaRDD<Vector> parsedData = data.map(\n+      new Function<String, Vector>() {\n+        public Vector call(String s) {\n+          String[] sarray = s.split(\" \");\n+          double[] values = new double[sarray.length];\n+          for (int i = 0; i < sarray.length; i++)\n+            values[i] = Double.parseDouble(sarray[i]);\n+          return Vectors.dense(values);\n+        }\n+      }\n+    );\n+\n+    // Cluster the data into two classes using KMeans\n+    int numClusters = 2;\n+    int numIterations = 20;\n+    KMeansModel clusters = KMeans.train(JavaRDD.toRDD(parsedData), numClusters, numIterations);\n+\n+    // Evaluate clustering by computing Within Set Sum of Squared Errors\n+    double WSSSE = clusters.computeCost(JavaRDD.toRDD(parsedData));","path":"docs/mllib-clustering.md","position":43,"original_position":43,"commit_id":"38d92c7da34824000eb3d1465835a2985e92082c","original_commit_id":"38d92c7da34824000eb3d1465835a2985e92082c","user":{"login":"mengxr","id":829644,"avatar_url":"https://avatars.githubusercontent.com/u/829644?","gravatar_id":"0e16fce91950d1b5a312649751ff1b14","url":"https://api.github.com/users/mengxr","html_url":"https://github.com/mengxr","followers_url":"https://api.github.com/users/mengxr/followers","following_url":"https://api.github.com/users/mengxr/following{/other_user}","gists_url":"https://api.github.com/users/mengxr/gists{/gist_id}","starred_url":"https://api.github.com/users/mengxr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mengxr/subscriptions","organizations_url":"https://api.github.com/users/mengxr/orgs","repos_url":"https://api.github.com/users/mengxr/repos","events_url":"https://api.github.com/users/mengxr/events{/privacy}","received_events_url":"https://api.github.com/users/mengxr/received_events","type":"User","site_admin":false},"body":"ditto: `JavaRDD.toRDD(parsedData)` -> `parsedData.rdd()`","created_at":"2014-07-14T03:26:59Z","updated_at":"2014-07-14T03:26:59Z","html_url":"https://github.com/apache/spark/pull/1311#discussion_r14862909","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/1311","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/14862909"},"html":{"href":"https://github.com/apache/spark/pull/1311#discussion_r14862909"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/1311"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/1311","id":18019087,"html_url":"https://github.com/apache/spark/pull/1311","diff_url":"https://github.com/apache/spark/pull/1311.diff","patch_url":"https://github.com/apache/spark/pull/1311.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/1311","number":1311,"state":"open","title":"[SPARK-1945][MLLIB] Documentation Improvements for Spark 1.0","user":{"login":"miccagiann","id":3640922,"avatar_url":"https://avatars.githubusercontent.com/u/3640922?","gravatar_id":"00126fc41deeeb6b8cc02e3bb61fbd79","url":"https://api.github.com/users/miccagiann","html_url":"https://github.com/miccagiann","followers_url":"https://api.github.com/users/miccagiann/followers","following_url":"https://api.github.com/users/miccagiann/following{/other_user}","gists_url":"https://api.github.com/users/miccagiann/gists{/gist_id}","starred_url":"https://api.github.com/users/miccagiann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miccagiann/subscriptions","organizations_url":"https://api.github.com/users/miccagiann/orgs","repos_url":"https://api.github.com/users/miccagiann/repos","events_url":"https://api.github.com/users/miccagiann/events{/privacy}","received_events_url":"https://api.github.com/users/miccagiann/received_events","type":"User","site_admin":false},"body":"Standalone application examples are added to 'mllib-linear-methods.md' file written in Java.\r\nThis commit is related to the issue [Add full Java Examples in MLlib docs](https://issues.apache.org/jira/browse/SPARK-1945).\r\nAlso I changed the name of the sigmoid function from 'logit' to 'f'. This is because the logit function\r\nis the inverse of sigmoid.\r\n\r\nThanks,\r\nMichael","created_at":"2014-07-06T15:24:46Z","updated_at":"2014-07-14T03:26:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e892173d13f576728c6cebd524570c12a62dcf83","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/1311/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/1311/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments/{number}","comments_url":"https://api.github.com/repos/apache/spark/issues/1311/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/38d92c7da34824000eb3d1465835a2985e92082c","head":{"label":"miccagiann:master","ref":"master","sha":"38d92c7da34824000eb3d1465835a2985e92082c","user":{"login":"miccagiann","id":3640922,"avatar_url":"https://avatars.githubusercontent.com/u/3640922?","gravatar_id":"00126fc41deeeb6b8cc02e3bb61fbd79","url":"https://api.github.com/users/miccagiann","html_url":"https://github.com/miccagiann","followers_url":"https://api.github.com/users/miccagiann/followers","following_url":"https://api.github.com/users/miccagiann/following{/other_user}","gists_url":"https://api.github.com/users/miccagiann/gists{/gist_id}","starred_url":"https://api.github.com/users/miccagiann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miccagiann/subscriptions","organizations_url":"https://api.github.com/users/miccagiann/orgs","repos_url":"https://api.github.com/users/miccagiann/repos","events_url":"https://api.github.com/users/miccagiann/events{/privacy}","received_events_url":"https://api.github.com/users/miccagiann/received_events","type":"User","site_admin":false},"repo":{"id":21005525,"name":"spark","full_name":"miccagiann/spark","owner":{"login":"miccagiann","id":3640922,"avatar_url":"https://avatars.githubusercontent.com/u/3640922?","gravatar_id":"00126fc41deeeb6b8cc02e3bb61fbd79","url":"https://api.github.com/users/miccagiann","html_url":"https://github.com/miccagiann","followers_url":"https://api.github.com/users/miccagiann/followers","following_url":"https://api.github.com/users/miccagiann/following{/other_user}","gists_url":"https://api.github.com/users/miccagiann/gists{/gist_id}","starred_url":"https://api.github.com/users/miccagiann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miccagiann/subscriptions","organizations_url":"https://api.github.com/users/miccagiann/orgs","repos_url":"https://api.github.com/users/miccagiann/repos","events_url":"https://api.github.com/users/miccagiann/events{/privacy}","received_events_url":"https://api.github.com/users/miccagiann/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/miccagiann/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/miccagiann/spark","forks_url":"https://api.github.com/repos/miccagiann/spark/forks","keys_url":"https://api.github.com/repos/miccagiann/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/miccagiann/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/miccagiann/spark/teams","hooks_url":"https://api.github.com/repos/miccagiann/spark/hooks","issue_events_url":"https://api.github.com/repos/miccagiann/spark/issues/events{/number}","events_url":"https://api.github.com/repos/miccagiann/spark/events","assignees_url":"https://api.github.com/repos/miccagiann/spark/assignees{/user}","branches_url":"https://api.github.com/repos/miccagiann/spark/branches{/branch}","tags_url":"https://api.github.com/repos/miccagiann/spark/tags","blobs_url":"https://api.github.com/repos/miccagiann/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/miccagiann/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/miccagiann/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/miccagiann/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/miccagiann/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/miccagiann/spark/languages","stargazers_url":"https://api.github.com/repos/miccagiann/spark/stargazers","contributors_url":"https://api.github.com/repos/miccagiann/spark/contributors","subscribers_url":"https://api.github.com/repos/miccagiann/spark/subscribers","subscription_url":"https://api.github.com/repos/miccagiann/spark/subscription","commits_url":"https://api.github.com/repos/miccagiann/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/miccagiann/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/miccagiann/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/miccagiann/spark/issues/comments/{number}","contents_url":"https://api.github.com/repos/miccagiann/spark/contents/{+path}","compare_url":"https://api.github.com/repos/miccagiann/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/miccagiann/spark/merges","archive_url":"https://api.github.com/repos/miccagiann/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/miccagiann/spark/downloads","issues_url":"https://api.github.com/repos/miccagiann/spark/issues{/number}","pulls_url":"https://api.github.com/repos/miccagiann/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/miccagiann/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/miccagiann/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/miccagiann/spark/labels{/name}","releases_url":"https://api.github.com/repos/miccagiann/spark/releases{/id}","created_at":"2014-06-19T15:30:20Z","updated_at":"2014-07-06T15:08:19Z","pushed_at":"2014-07-14T00:07:01Z","git_url":"git://github.com/miccagiann/spark.git","ssh_url":"git@github.com:miccagiann/spark.git","clone_url":"https://github.com/miccagiann/spark.git","svn_url":"https://github.com/miccagiann/spark","homepage":null,"size":71046,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":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":"e6f7bfcfbf6aff7a9f8cd8e0a2166d0bf62b0912","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?","gravatar_id":"a676c0bf448fcd49f588249ead719b4c","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?","gravatar_id":"a676c0bf448fcd49f588249ead719b4c","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}","created_at":"2014-02-25T08:00:08Z","updated_at":"2014-07-13T16:09:33Z","pushed_at":"2014-07-14T02:29:01Z","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":2194807,"stargazers_count":805,"watchers_count":805,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"forks_count":829,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":242,"forks":829,"open_issues":242,"watchers":805,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/1311"},"html":{"href":"https://github.com/apache/spark/pull/1311"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/1311"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/1311/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/1311/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/1311/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/38d92c7da34824000eb3d1465835a2985e92082c"}}}}