{"action":"created","comment":{"url":"https://api.github.com/repos/apache/flink/pulls/comments/33778892","id":33778892,"diff_hunk":"@@ -0,0 +1,43 @@\n+/*\n+ * Licensed to the Apache Software Foundation (ASF) under one\n+ * or more contributor license agreements.  See the NOTICE file\n+ * distributed with this work for additional information\n+ * regarding copyright ownership.  The ASF licenses this file\n+ * to you under the Apache License, Version 2.0 (the\n+ * \"License\"); you may not use this file except in compliance\n+ * with the License.  You may obtain a copy of the License at\n+ *\n+ *     http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+package org.apache.flink.ml.classification\n+\n+import org.apache.flink.api.scala._\n+import org.apache.flink.ml.evaluation.ClassificationScores\n+import org.apache.flink.ml.pipeline.Predictor\n+\n+/** Trait that classification algorithms should implement\n+  *\n+  * @tparam Self Type of the implementing class\n+  */\n+trait Classifier[Self] extends Predictor[Self]{\n+  that: Self =>\n+\n+  override def calculateScore[Prediction](input: DataSet[(Prediction, Prediction)])\n+    : DataSet[Double] = {\n+    val tpi = input.getType()\n+    if (tpi == createTypeInformation[(Double, Double)]) {\n+      val doubleInput = input.asInstanceOf[DataSet[(Double, Double)]]\n+      ClassificationScores.accuracyScore.evaluate(doubleInput)","path":"flink-staging/flink-ml/src/main/scala/org/apache/flink/ml/classification/Classifier.scala","position":37,"original_position":37,"commit_id":"492e9a383af6285f0fdca5031d2bd7bdfe3cd511","original_commit_id":"831c0465268ed83a2f99577650381b46b7e3eacb","user":{"login":"tillrohrmann","id":5756858,"avatar_url":"https://avatars.githubusercontent.com/u/5756858?v=3","gravatar_id":"","url":"https://api.github.com/users/tillrohrmann","html_url":"https://github.com/tillrohrmann","followers_url":"https://api.github.com/users/tillrohrmann/followers","following_url":"https://api.github.com/users/tillrohrmann/following{/other_user}","gists_url":"https://api.github.com/users/tillrohrmann/gists{/gist_id}","starred_url":"https://api.github.com/users/tillrohrmann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tillrohrmann/subscriptions","organizations_url":"https://api.github.com/users/tillrohrmann/orgs","repos_url":"https://api.github.com/users/tillrohrmann/repos","events_url":"https://api.github.com/users/tillrohrmann/events{/privacy}","received_events_url":"https://api.github.com/users/tillrohrmann/received_events","type":"User","site_admin":false},"body":"But why does `calculateScore` is then generic?","created_at":"2015-07-02T13:48:39Z","updated_at":"2015-07-02T13:48:39Z","html_url":"https://github.com/apache/flink/pull/871#discussion_r33778892","pull_request_url":"https://api.github.com/repos/apache/flink/pulls/871","_links":{"self":{"href":"https://api.github.com/repos/apache/flink/pulls/comments/33778892"},"html":{"href":"https://github.com/apache/flink/pull/871#discussion_r33778892"},"pull_request":{"href":"https://api.github.com/repos/apache/flink/pulls/871"}}},"pull_request":{"url":"https://api.github.com/repos/apache/flink/pulls/871","id":38643000,"html_url":"https://github.com/apache/flink/pull/871","diff_url":"https://github.com/apache/flink/pull/871.diff","patch_url":"https://github.com/apache/flink/pull/871.patch","issue_url":"https://api.github.com/repos/apache/flink/issues/871","number":871,"state":"open","locked":false,"title":"[FLINK-2157] [ml] [WIP]  Create evaluation framework for ML library","user":{"login":"thvasilo","id":9048995,"avatar_url":"https://avatars.githubusercontent.com/u/9048995?v=3","gravatar_id":"","url":"https://api.github.com/users/thvasilo","html_url":"https://github.com/thvasilo","followers_url":"https://api.github.com/users/thvasilo/followers","following_url":"https://api.github.com/users/thvasilo/following{/other_user}","gists_url":"https://api.github.com/users/thvasilo/gists{/gist_id}","starred_url":"https://api.github.com/users/thvasilo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thvasilo/subscriptions","organizations_url":"https://api.github.com/users/thvasilo/orgs","repos_url":"https://api.github.com/users/thvasilo/repos","events_url":"https://api.github.com/users/thvasilo/events{/privacy}","received_events_url":"https://api.github.com/users/thvasilo/received_events","type":"User","site_admin":false},"body":"WIP PR for the model evaluation framework for FlinkML.\r\n\r\nThe evaluation follow sklearn's paradigm, where a Scorer object is created with a performance score (sklearn's metrics), and provides an evaluate function that takes a trained model and a test dataset and produces a score.\r\n\r\nThe performance scores and Scorer are implemented in the flink.ml.evaluation package.\r\nCurrently we have squared loss, zero-one loss, accuracy score for classification and R^2 score for \r\nregression.\r\n\r\nFinally a score function has been added to regression algorithms (and will be added to classifiers as well) that provides an intuitive way to evaluate the performance of an algorithm without the need to create a Scorer, as per [FLINK-2108](https://issues.apache.org/jira/browse/FLINK-2108).\r\n\r\nThe PR currently includes some work from Mikio Braun for a linear regression solver, but that will be moved to a separate PR.","created_at":"2015-06-26T12:08:57Z","updated_at":"2015-07-02T13:48:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4551535150736ffa5aa2a2e4b43d381be2030367","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/flink/pulls/871/commits","review_comments_url":"https://api.github.com/repos/apache/flink/pulls/871/comments","review_comment_url":"https://api.github.com/repos/apache/flink/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/flink/issues/871/comments","statuses_url":"https://api.github.com/repos/apache/flink/statuses/492e9a383af6285f0fdca5031d2bd7bdfe3cd511","head":{"label":"thvasilo:evaluation","ref":"evaluation","sha":"492e9a383af6285f0fdca5031d2bd7bdfe3cd511","user":{"login":"thvasilo","id":9048995,"avatar_url":"https://avatars.githubusercontent.com/u/9048995?v=3","gravatar_id":"","url":"https://api.github.com/users/thvasilo","html_url":"https://github.com/thvasilo","followers_url":"https://api.github.com/users/thvasilo/followers","following_url":"https://api.github.com/users/thvasilo/following{/other_user}","gists_url":"https://api.github.com/users/thvasilo/gists{/gist_id}","starred_url":"https://api.github.com/users/thvasilo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thvasilo/subscriptions","organizations_url":"https://api.github.com/users/thvasilo/orgs","repos_url":"https://api.github.com/users/thvasilo/repos","events_url":"https://api.github.com/users/thvasilo/events{/privacy}","received_events_url":"https://api.github.com/users/thvasilo/received_events","type":"User","site_admin":false},"repo":{"id":31908956,"name":"flink","full_name":"thvasilo/flink","owner":{"login":"thvasilo","id":9048995,"avatar_url":"https://avatars.githubusercontent.com/u/9048995?v=3","gravatar_id":"","url":"https://api.github.com/users/thvasilo","html_url":"https://github.com/thvasilo","followers_url":"https://api.github.com/users/thvasilo/followers","following_url":"https://api.github.com/users/thvasilo/following{/other_user}","gists_url":"https://api.github.com/users/thvasilo/gists{/gist_id}","starred_url":"https://api.github.com/users/thvasilo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thvasilo/subscriptions","organizations_url":"https://api.github.com/users/thvasilo/orgs","repos_url":"https://api.github.com/users/thvasilo/repos","events_url":"https://api.github.com/users/thvasilo/events{/privacy}","received_events_url":"https://api.github.com/users/thvasilo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/thvasilo/flink","description":"Mirror of Apache Flink","fork":true,"url":"https://api.github.com/repos/thvasilo/flink","forks_url":"https://api.github.com/repos/thvasilo/flink/forks","keys_url":"https://api.github.com/repos/thvasilo/flink/keys{/key_id}","collaborators_url":"https://api.github.com/repos/thvasilo/flink/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/thvasilo/flink/teams","hooks_url":"https://api.github.com/repos/thvasilo/flink/hooks","issue_events_url":"https://api.github.com/repos/thvasilo/flink/issues/events{/number}","events_url":"https://api.github.com/repos/thvasilo/flink/events","assignees_url":"https://api.github.com/repos/thvasilo/flink/assignees{/user}","branches_url":"https://api.github.com/repos/thvasilo/flink/branches{/branch}","tags_url":"https://api.github.com/repos/thvasilo/flink/tags","blobs_url":"https://api.github.com/repos/thvasilo/flink/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/thvasilo/flink/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/thvasilo/flink/git/refs{/sha}","trees_url":"https://api.github.com/repos/thvasilo/flink/git/trees{/sha}","statuses_url":"https://api.github.com/repos/thvasilo/flink/statuses/{sha}","languages_url":"https://api.github.com/repos/thvasilo/flink/languages","stargazers_url":"https://api.github.com/repos/thvasilo/flink/stargazers","contributors_url":"https://api.github.com/repos/thvasilo/flink/contributors","subscribers_url":"https://api.github.com/repos/thvasilo/flink/subscribers","subscription_url":"https://api.github.com/repos/thvasilo/flink/subscription","commits_url":"https://api.github.com/repos/thvasilo/flink/commits{/sha}","git_commits_url":"https://api.github.com/repos/thvasilo/flink/git/commits{/sha}","comments_url":"https://api.github.com/repos/thvasilo/flink/comments{/number}","issue_comment_url":"https://api.github.com/repos/thvasilo/flink/issues/comments{/number}","contents_url":"https://api.github.com/repos/thvasilo/flink/contents/{+path}","compare_url":"https://api.github.com/repos/thvasilo/flink/compare/{base}...{head}","merges_url":"https://api.github.com/repos/thvasilo/flink/merges","archive_url":"https://api.github.com/repos/thvasilo/flink/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/thvasilo/flink/downloads","issues_url":"https://api.github.com/repos/thvasilo/flink/issues{/number}","pulls_url":"https://api.github.com/repos/thvasilo/flink/pulls{/number}","milestones_url":"https://api.github.com/repos/thvasilo/flink/milestones{/number}","notifications_url":"https://api.github.com/repos/thvasilo/flink/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/thvasilo/flink/labels{/name}","releases_url":"https://api.github.com/repos/thvasilo/flink/releases{/id}","created_at":"2015-03-09T16:14:55Z","updated_at":"2015-04-24T12:16:55Z","pushed_at":"2015-07-02T13:36:22Z","git_url":"git://github.com/thvasilo/flink.git","ssh_url":"git@github.com:thvasilo/flink.git","clone_url":"https://github.com/thvasilo/flink.git","svn_url":"https://github.com/thvasilo/flink","homepage":null,"size":51024,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"eb23f80742e743a75888f5d4fbed879383b6741e","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":20587599,"name":"flink","full_name":"apache/flink","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/flink","description":"Mirror of Apache Flink","fork":false,"url":"https://api.github.com/repos/apache/flink","forks_url":"https://api.github.com/repos/apache/flink/forks","keys_url":"https://api.github.com/repos/apache/flink/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/flink/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/flink/teams","hooks_url":"https://api.github.com/repos/apache/flink/hooks","issue_events_url":"https://api.github.com/repos/apache/flink/issues/events{/number}","events_url":"https://api.github.com/repos/apache/flink/events","assignees_url":"https://api.github.com/repos/apache/flink/assignees{/user}","branches_url":"https://api.github.com/repos/apache/flink/branches{/branch}","tags_url":"https://api.github.com/repos/apache/flink/tags","blobs_url":"https://api.github.com/repos/apache/flink/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/flink/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/flink/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/flink/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/flink/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/flink/languages","stargazers_url":"https://api.github.com/repos/apache/flink/stargazers","contributors_url":"https://api.github.com/repos/apache/flink/contributors","subscribers_url":"https://api.github.com/repos/apache/flink/subscribers","subscription_url":"https://api.github.com/repos/apache/flink/subscription","commits_url":"https://api.github.com/repos/apache/flink/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/flink/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/flink/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/flink/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/flink/contents/{+path}","compare_url":"https://api.github.com/repos/apache/flink/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/flink/merges","archive_url":"https://api.github.com/repos/apache/flink/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/flink/downloads","issues_url":"https://api.github.com/repos/apache/flink/issues{/number}","pulls_url":"https://api.github.com/repos/apache/flink/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/flink/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/flink/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/flink/labels{/name}","releases_url":"https://api.github.com/repos/apache/flink/releases{/id}","created_at":"2014-06-07T07:00:10Z","updated_at":"2015-06-29T06:58:50Z","pushed_at":"2015-07-02T13:36:23Z","git_url":"git://github.com/apache/flink.git","ssh_url":"git@github.com:apache/flink.git","clone_url":"https://github.com/apache/flink.git","svn_url":"https://github.com/apache/flink","homepage":null,"size":2553420,"stargazers_count":475,"watchers_count":475,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":313,"mirror_url":"git://git.apache.org/incubator-flink.git","open_issues_count":61,"forks":313,"open_issues":61,"watchers":475,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/flink/pulls/871"},"html":{"href":"https://github.com/apache/flink/pull/871"},"issue":{"href":"https://api.github.com/repos/apache/flink/issues/871"},"comments":{"href":"https://api.github.com/repos/apache/flink/issues/871/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/flink/pulls/871/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/flink/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/flink/pulls/871/commits"},"statuses":{"href":"https://api.github.com/repos/apache/flink/statuses/492e9a383af6285f0fdca5031d2bd7bdfe3cd511"}}}}