{"action":"created","comment":{"url":"https://api.github.com/repos/sjyk/sampleclean-async/pulls/comments/25136781","id":25136781,"diff_hunk":"@@ -0,0 +1,129 @@\n+package sampleclean.eval\n+\n+import sampleclean.api.SampleCleanContext\n+import sampleclean.clean.algorithm.SampleCleanAlgorithm\n+import org.apache.spark.SparkContext._\n+import org.apache.spark.sql.SQLContext\n+import sampleclean.clean.algorithm.AlgorithmParameters\n+import org.apache.spark.rdd.RDD\n+import org.apache.spark.sql.{SchemaRDD, Row}\n+\n+class Evaluator(scc:SampleCleanContext,\n+\t\t\t\talgorithms:List[SampleCleanAlgorithm], \n+\t\t\t\tunaryConstraints:scala.collection.mutable.Map[(String,String),String] \n+\t\t\t\t\t\t\t\t\t=  scala.collection.mutable.Map(),\n+\t\t\t\tbinaryConstraints:scala.collection.mutable.Map[(String,String,String), Boolean] \n+\t\t\t\t\t\t\t\t\t=  scala.collection.mutable.Map())\n+\t\t\t\textends Serializable\n+{\n+\n+\t  var binaryKeySet:Set[String] = Set()\n+\t  var resultTable:List[(Double, Double, Double)] = List()\n+\n+\t  def addUnaryConstraint(hash:String, attr:String, value:String) ={\n+\t  \t  unaryConstraints((hash,attr)) = value\n+\t  }\n+\n+\t  def addBinaryConstraint(hash1:String, hash2:String, attr:String, same:Boolean) ={\n+\t  \t  binaryConstraints((hash1,hash2,attr))= same\n+\t  \t  binaryKeySet += hash1\n+\t  \t  binaryKeySet += hash2\n+\t  }\n+\n+\t  def setAlgorithmsToSample(sampleName:String) = {\n+\t  \tfor(a <- algorithms)\n+\t  \t\ta.setSampleName(sampleName)\n+\t  }\n+\n+\t  def compareValues(row:Row, \n+\t  \t\t\t\t\tschemaLength:Int , \n+\t  \t\t\t\t\tschemaMap:Map[Int,String], \n+\t  \t\t\t\t\tgt:scala.collection.mutable.Map[(String,String),String]):(Int, Int) = {\n+\n+\t  \t\tvar hit = 0\n+\t  \t\tvar total = 0\n+\t  \t\tfor(i <- 1 until schemaLength)\n+\t  \t\t{\n+\t  \t\t\tval attr = schemaMap(i)\n+\t  \t\t\tval hash = row(0).asInstanceOf[String]\n+\t  \t\t\t\n+\t  \t\t\tif(gt contains (hash,attr))\n+\t  \t\t\t{\ttotal = total + 1\n+\t  \t\t\t\tif(gt((hash,attr)) == row(i).toString())\n+\t  \t\t\t\t\thit = hit + 1\n+\t  \t\t\t}\n+\t  \t\t}\n+\n+\t  \t\treturn (total,hit)\n+\t  }\t\n+\n+\t  def compairPairs(row1:Row,\n+\t  \t\t\t\t   row2:Row,\n+\t  \t\t\t\t   schemaLength:Int , \n+\t  \t\t\t\t   schemaMap:Map[Int,String],\n+\t  \t\t\t\t   gt:scala.collection.mutable.Map[(String,String,String), Boolean]):(Int,Int) ={\n+\n+\t  \t\tvar hit = 0\n+\t  \t\tvar total = 0\n+\t  \t\tfor(i <- 1 until schemaLength)\n+\t  \t\t{\n+\t  \t\t\tval attr = schemaMap(i)\n+\t  \t\t\tval hash1 = row1(0).asInstanceOf[String]\n+\t  \t\t\tval hash2 = row2(0).asInstanceOf[String]\n+\t  \t\t\t\n+\t  \t\t\tif(gt contains (hash1,hash2,attr))\n+\t  \t\t\t{\ttotal = total + 1\n+\t  \t\t\t\tif(gt((hash1,hash2,attr)))\n+\t  \t\t\t\t{\n+\t  \t\t\t\t\tif(row1(i) == row2(i))\n+\t  \t\t\t\t\t\thit = hit + 1\n+\t  \t\t\t\t}\n+\t  \t\t\t\telse{\n+\n+\t  \t\t\t\t\tif(row1(i) != row2(i))\n+\t  \t\t\t\t\t\thit = hit + 1\n+\n+\t  \t\t\t\t}\n+\t  \t\t\t}\n+\t  \t\t}\n+\n+\t  \t\treturn (total,hit)\n+\t  }\n+\n+\t  def evaluate(sampleName:String) = {\n+\t  \t  println(\"This procedure will remove any changes in your sample. Rebase to save changes. \")\n+\t  \t  val schema = scc.getHiveTableSchema(scc.qb.getCleanSampleName(sampleName))\n+\t  \t  var schemaMap:Map[Int,String] = Map()\n+\t  \t  for (i <- 0 until schema.length)\n+\t  \t  \tschemaMap = schemaMap + (i -> schema(i)) \n+\n+\t  \t  for(a <- algorithms)\n+\t  \t  {\n+\t  \t  \t  scc.resetSample(sampleName)\n+\t  \t  \t  val timeStart = System.currentTimeMillis;\n+\t  \t  \t  val result = a.synchronousExecAndRead()\n+\t  \t  \t  val totalTime = (System.currentTimeMillis-timeStart)/1000.0\n+\t  \t  \t  val accTuples:RDD[(Int,Int)] = result.map(compareValues(_,schema.length, schemaMap, unaryConstraints))\n+\t  \t  \t  val unaryResults = accTuples.reduce((x:(Int,Int),y:(Int,Int)) => (x._1+y._1,x._2+y._2))\n+\t\t\t  val binarySet = result.filter(x => binaryKeySet.contains(x(0).asInstanceOf[String]))\n+\t\t\t  val pairs = binarySet.cartesian(binarySet)\n+\t\t\t  val accBTuples:RDD[(Int,Int)] = pairs.map(x => compairPairs(x._1,x._2,schema.length, schemaMap, binaryConstraints))\n+\t\t\t  val binaryResults = accBTuples.reduce((x:(Int,Int),y:(Int,Int)) => (x._1+y._1,x._2+y._2))\n+\t\t\t  resultTable = ((unaryResults._2+0.0)/(unaryResults._1), \n+\t\t\t  \t\t\t\t (binaryResults._2+0.0)/(binaryResults._1),\n+\t\t\t  \t\t\t\t totalTime) :: resultTable \t","path":"src/main/scala/sampleclean/eval/Evaluator.scala","position":114,"original_position":114,"commit_id":"b3ed9f3410f6117130c8fb9ba4e62e7247d8464c","original_commit_id":"b3ed9f3410f6117130c8fb9ba4e62e7247d8464c","user":{"login":"thisisdhaas","id":390825,"avatar_url":"https://avatars.githubusercontent.com/u/390825?v=3","gravatar_id":"","url":"https://api.github.com/users/thisisdhaas","html_url":"https://github.com/thisisdhaas","followers_url":"https://api.github.com/users/thisisdhaas/followers","following_url":"https://api.github.com/users/thisisdhaas/following{/other_user}","gists_url":"https://api.github.com/users/thisisdhaas/gists{/gist_id}","starred_url":"https://api.github.com/users/thisisdhaas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thisisdhaas/subscriptions","organizations_url":"https://api.github.com/users/thisisdhaas/orgs","repos_url":"https://api.github.com/users/thisisdhaas/repos","events_url":"https://api.github.com/users/thisisdhaas/events{/privacy}","received_events_url":"https://api.github.com/users/thisisdhaas/received_events","type":"User","site_admin":false},"body":"Can you add a docstring or something describing exactly what this function does? Looks like you're running through several algorithms on a sample and comparing accuracy of algorithm output on some passed in constraints? what does `resultTable` give? & etc...","created_at":"2015-02-22T21:26:16Z","updated_at":"2015-02-22T21:26:16Z","html_url":"https://github.com/sjyk/sampleclean-async/pull/56#discussion_r25136781","pull_request_url":"https://api.github.com/repos/sjyk/sampleclean-async/pulls/56","_links":{"self":{"href":"https://api.github.com/repos/sjyk/sampleclean-async/pulls/comments/25136781"},"html":{"href":"https://github.com/sjyk/sampleclean-async/pull/56#discussion_r25136781"},"pull_request":{"href":"https://api.github.com/repos/sjyk/sampleclean-async/pulls/56"}}},"pull_request":{"url":"https://api.github.com/repos/sjyk/sampleclean-async/pulls/56","id":29776496,"html_url":"https://github.com/sjyk/sampleclean-async/pull/56","diff_url":"https://github.com/sjyk/sampleclean-async/pull/56.diff","patch_url":"https://github.com/sjyk/sampleclean-async/pull/56.patch","issue_url":"https://api.github.com/repos/sjyk/sampleclean-async/issues/56","number":56,"state":"open","locked":false,"title":"New api","user":{"login":"sjyk","id":1522482,"avatar_url":"https://avatars.githubusercontent.com/u/1522482?v=3","gravatar_id":"","url":"https://api.github.com/users/sjyk","html_url":"https://github.com/sjyk","followers_url":"https://api.github.com/users/sjyk/followers","following_url":"https://api.github.com/users/sjyk/following{/other_user}","gists_url":"https://api.github.com/users/sjyk/gists{/gist_id}","starred_url":"https://api.github.com/users/sjyk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sjyk/subscriptions","organizations_url":"https://api.github.com/users/sjyk/orgs","repos_url":"https://api.github.com/users/sjyk/repos","events_url":"https://api.github.com/users/sjyk/events{/privacy}","received_events_url":"https://api.github.com/users/sjyk/received_events","type":"User","site_admin":false},"body":"Added in the magical \"Eval\" operator.","created_at":"2015-02-22T20:49:08Z","updated_at":"2015-02-22T21:26:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f8d055617e27d55eaed93d595d26e0fdcc972bf5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/sjyk/sampleclean-async/pulls/56/commits","review_comments_url":"https://api.github.com/repos/sjyk/sampleclean-async/pulls/56/comments","review_comment_url":"https://api.github.com/repos/sjyk/sampleclean-async/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sjyk/sampleclean-async/issues/56/comments","statuses_url":"https://api.github.com/repos/sjyk/sampleclean-async/statuses/b3ed9f3410f6117130c8fb9ba4e62e7247d8464c","head":{"label":"sjyk:new_api","ref":"new_api","sha":"b3ed9f3410f6117130c8fb9ba4e62e7247d8464c","user":{"login":"sjyk","id":1522482,"avatar_url":"https://avatars.githubusercontent.com/u/1522482?v=3","gravatar_id":"","url":"https://api.github.com/users/sjyk","html_url":"https://github.com/sjyk","followers_url":"https://api.github.com/users/sjyk/followers","following_url":"https://api.github.com/users/sjyk/following{/other_user}","gists_url":"https://api.github.com/users/sjyk/gists{/gist_id}","starred_url":"https://api.github.com/users/sjyk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sjyk/subscriptions","organizations_url":"https://api.github.com/users/sjyk/orgs","repos_url":"https://api.github.com/users/sjyk/repos","events_url":"https://api.github.com/users/sjyk/events{/privacy}","received_events_url":"https://api.github.com/users/sjyk/received_events","type":"User","site_admin":false},"repo":{"id":23436019,"name":"sampleclean-async","full_name":"sjyk/sampleclean-async","owner":{"login":"sjyk","id":1522482,"avatar_url":"https://avatars.githubusercontent.com/u/1522482?v=3","gravatar_id":"","url":"https://api.github.com/users/sjyk","html_url":"https://github.com/sjyk","followers_url":"https://api.github.com/users/sjyk/followers","following_url":"https://api.github.com/users/sjyk/following{/other_user}","gists_url":"https://api.github.com/users/sjyk/gists{/gist_id}","starred_url":"https://api.github.com/users/sjyk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sjyk/subscriptions","organizations_url":"https://api.github.com/users/sjyk/orgs","repos_url":"https://api.github.com/users/sjyk/repos","events_url":"https://api.github.com/users/sjyk/events{/privacy}","received_events_url":"https://api.github.com/users/sjyk/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sjyk/sampleclean-async","description":"","fork":false,"url":"https://api.github.com/repos/sjyk/sampleclean-async","forks_url":"https://api.github.com/repos/sjyk/sampleclean-async/forks","keys_url":"https://api.github.com/repos/sjyk/sampleclean-async/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sjyk/sampleclean-async/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sjyk/sampleclean-async/teams","hooks_url":"https://api.github.com/repos/sjyk/sampleclean-async/hooks","issue_events_url":"https://api.github.com/repos/sjyk/sampleclean-async/issues/events{/number}","events_url":"https://api.github.com/repos/sjyk/sampleclean-async/events","assignees_url":"https://api.github.com/repos/sjyk/sampleclean-async/assignees{/user}","branches_url":"https://api.github.com/repos/sjyk/sampleclean-async/branches{/branch}","tags_url":"https://api.github.com/repos/sjyk/sampleclean-async/tags","blobs_url":"https://api.github.com/repos/sjyk/sampleclean-async/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sjyk/sampleclean-async/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sjyk/sampleclean-async/git/refs{/sha}","trees_url":"https://api.github.com/repos/sjyk/sampleclean-async/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sjyk/sampleclean-async/statuses/{sha}","languages_url":"https://api.github.com/repos/sjyk/sampleclean-async/languages","stargazers_url":"https://api.github.com/repos/sjyk/sampleclean-async/stargazers","contributors_url":"https://api.github.com/repos/sjyk/sampleclean-async/contributors","subscribers_url":"https://api.github.com/repos/sjyk/sampleclean-async/subscribers","subscription_url":"https://api.github.com/repos/sjyk/sampleclean-async/subscription","commits_url":"https://api.github.com/repos/sjyk/sampleclean-async/commits{/sha}","git_commits_url":"https://api.github.com/repos/sjyk/sampleclean-async/git/commits{/sha}","comments_url":"https://api.github.com/repos/sjyk/sampleclean-async/comments{/number}","issue_comment_url":"https://api.github.com/repos/sjyk/sampleclean-async/issues/comments{/number}","contents_url":"https://api.github.com/repos/sjyk/sampleclean-async/contents/{+path}","compare_url":"https://api.github.com/repos/sjyk/sampleclean-async/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sjyk/sampleclean-async/merges","archive_url":"https://api.github.com/repos/sjyk/sampleclean-async/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sjyk/sampleclean-async/downloads","issues_url":"https://api.github.com/repos/sjyk/sampleclean-async/issues{/number}","pulls_url":"https://api.github.com/repos/sjyk/sampleclean-async/pulls{/number}","milestones_url":"https://api.github.com/repos/sjyk/sampleclean-async/milestones{/number}","notifications_url":"https://api.github.com/repos/sjyk/sampleclean-async/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sjyk/sampleclean-async/labels{/name}","releases_url":"https://api.github.com/repos/sjyk/sampleclean-async/releases{/id}","created_at":"2014-08-28T17:01:08Z","updated_at":"2015-02-22T08:02:58Z","pushed_at":"2015-02-22T20:48:46Z","git_url":"git://github.com/sjyk/sampleclean-async.git","ssh_url":"git@github.com:sjyk/sampleclean-async.git","clone_url":"https://github.com/sjyk/sampleclean-async.git","svn_url":"https://github.com/sjyk/sampleclean-async","homepage":"http://sampleclean.org","size":4165,"stargazers_count":4,"watchers_count":4,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":5,"forks":5,"open_issues":5,"watchers":4,"default_branch":"master"}},"base":{"label":"sjyk:master","ref":"master","sha":"6a96d184a00d155f7904259df0addc6a27283cda","user":{"login":"sjyk","id":1522482,"avatar_url":"https://avatars.githubusercontent.com/u/1522482?v=3","gravatar_id":"","url":"https://api.github.com/users/sjyk","html_url":"https://github.com/sjyk","followers_url":"https://api.github.com/users/sjyk/followers","following_url":"https://api.github.com/users/sjyk/following{/other_user}","gists_url":"https://api.github.com/users/sjyk/gists{/gist_id}","starred_url":"https://api.github.com/users/sjyk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sjyk/subscriptions","organizations_url":"https://api.github.com/users/sjyk/orgs","repos_url":"https://api.github.com/users/sjyk/repos","events_url":"https://api.github.com/users/sjyk/events{/privacy}","received_events_url":"https://api.github.com/users/sjyk/received_events","type":"User","site_admin":false},"repo":{"id":23436019,"name":"sampleclean-async","full_name":"sjyk/sampleclean-async","owner":{"login":"sjyk","id":1522482,"avatar_url":"https://avatars.githubusercontent.com/u/1522482?v=3","gravatar_id":"","url":"https://api.github.com/users/sjyk","html_url":"https://github.com/sjyk","followers_url":"https://api.github.com/users/sjyk/followers","following_url":"https://api.github.com/users/sjyk/following{/other_user}","gists_url":"https://api.github.com/users/sjyk/gists{/gist_id}","starred_url":"https://api.github.com/users/sjyk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sjyk/subscriptions","organizations_url":"https://api.github.com/users/sjyk/orgs","repos_url":"https://api.github.com/users/sjyk/repos","events_url":"https://api.github.com/users/sjyk/events{/privacy}","received_events_url":"https://api.github.com/users/sjyk/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sjyk/sampleclean-async","description":"","fork":false,"url":"https://api.github.com/repos/sjyk/sampleclean-async","forks_url":"https://api.github.com/repos/sjyk/sampleclean-async/forks","keys_url":"https://api.github.com/repos/sjyk/sampleclean-async/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sjyk/sampleclean-async/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sjyk/sampleclean-async/teams","hooks_url":"https://api.github.com/repos/sjyk/sampleclean-async/hooks","issue_events_url":"https://api.github.com/repos/sjyk/sampleclean-async/issues/events{/number}","events_url":"https://api.github.com/repos/sjyk/sampleclean-async/events","assignees_url":"https://api.github.com/repos/sjyk/sampleclean-async/assignees{/user}","branches_url":"https://api.github.com/repos/sjyk/sampleclean-async/branches{/branch}","tags_url":"https://api.github.com/repos/sjyk/sampleclean-async/tags","blobs_url":"https://api.github.com/repos/sjyk/sampleclean-async/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sjyk/sampleclean-async/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sjyk/sampleclean-async/git/refs{/sha}","trees_url":"https://api.github.com/repos/sjyk/sampleclean-async/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sjyk/sampleclean-async/statuses/{sha}","languages_url":"https://api.github.com/repos/sjyk/sampleclean-async/languages","stargazers_url":"https://api.github.com/repos/sjyk/sampleclean-async/stargazers","contributors_url":"https://api.github.com/repos/sjyk/sampleclean-async/contributors","subscribers_url":"https://api.github.com/repos/sjyk/sampleclean-async/subscribers","subscription_url":"https://api.github.com/repos/sjyk/sampleclean-async/subscription","commits_url":"https://api.github.com/repos/sjyk/sampleclean-async/commits{/sha}","git_commits_url":"https://api.github.com/repos/sjyk/sampleclean-async/git/commits{/sha}","comments_url":"https://api.github.com/repos/sjyk/sampleclean-async/comments{/number}","issue_comment_url":"https://api.github.com/repos/sjyk/sampleclean-async/issues/comments{/number}","contents_url":"https://api.github.com/repos/sjyk/sampleclean-async/contents/{+path}","compare_url":"https://api.github.com/repos/sjyk/sampleclean-async/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sjyk/sampleclean-async/merges","archive_url":"https://api.github.com/repos/sjyk/sampleclean-async/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sjyk/sampleclean-async/downloads","issues_url":"https://api.github.com/repos/sjyk/sampleclean-async/issues{/number}","pulls_url":"https://api.github.com/repos/sjyk/sampleclean-async/pulls{/number}","milestones_url":"https://api.github.com/repos/sjyk/sampleclean-async/milestones{/number}","notifications_url":"https://api.github.com/repos/sjyk/sampleclean-async/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sjyk/sampleclean-async/labels{/name}","releases_url":"https://api.github.com/repos/sjyk/sampleclean-async/releases{/id}","created_at":"2014-08-28T17:01:08Z","updated_at":"2015-02-22T08:02:58Z","pushed_at":"2015-02-22T20:48:46Z","git_url":"git://github.com/sjyk/sampleclean-async.git","ssh_url":"git@github.com:sjyk/sampleclean-async.git","clone_url":"https://github.com/sjyk/sampleclean-async.git","svn_url":"https://github.com/sjyk/sampleclean-async","homepage":"http://sampleclean.org","size":4165,"stargazers_count":4,"watchers_count":4,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":5,"forks":5,"open_issues":5,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sjyk/sampleclean-async/pulls/56"},"html":{"href":"https://github.com/sjyk/sampleclean-async/pull/56"},"issue":{"href":"https://api.github.com/repos/sjyk/sampleclean-async/issues/56"},"comments":{"href":"https://api.github.com/repos/sjyk/sampleclean-async/issues/56/comments"},"review_comments":{"href":"https://api.github.com/repos/sjyk/sampleclean-async/pulls/56/comments"},"review_comment":{"href":"https://api.github.com/repos/sjyk/sampleclean-async/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sjyk/sampleclean-async/pulls/56/commits"},"statuses":{"href":"https://api.github.com/repos/sjyk/sampleclean-async/statuses/b3ed9f3410f6117130c8fb9ba4e62e7247d8464c"}}}}