{"action":"created","comment":{"url":"https://api.github.com/repos/Rambatino/CHAID/pulls/comments/78939700","id":78939700,"diff_hunk":"@@ -366,37 +369,63 @@ def node(self, rows, ind, dep, depth=0, parent=None, parent_decisions=None):\n                 self.node_count += 1\n         return self.tree_store\n \n-    def generate_best_split(self, ind, dep):\n+    def generate_best_split(self, ind, dep, wt):\n         \"\"\" internal method to generate the best split \"\"\"\n         split = CHAIDSplit(None, None, None, 1)\n         relative_split_threshold = 1 - self.split_threshold\n+\n         for i, index in enumerate(ind):\n             index = index.deep_copy()\n             unique = set(index.arr)\n \n             mappings = MappingDict()\n-            frequencies = {}\n+            freq = {}\n+            wt_freq = {}\n             for col in unique:\n                 counts = np.unique(dep.arr[index.arr == col], return_counts=True)\n-                frequencies[col] = cl.defaultdict(int)\n-                frequencies[col].update(np.transpose(counts))\n+                freq[col] = cl.defaultdict(int)\n+                wt_freq[col] = cl.defaultdict(int)\n+                freq[col].update(np.transpose(counts))\n+                if wt is not None:\n+                    for dep_v in set(dep.arr):\n+                        wt_freq[col][dep_v] = wt[(index.arr == col) * (dep.arr == dep_v)].sum()\n \n             while len(unique) > 1:\n                 size = int((len(unique) * (len(unique) - 1)) / 2)\n                 sub_data_columns = [('combinations', object), ('chi', float), ('p', float)]\n                 sub_data = np.array([(None, 0, 1)]*size, dtype=sub_data_columns, order='F')\n                 for j, comb in enumerate(it.combinations(unique, 2)):\n-                    col1_freq = frequencies[comb[0]]\n-                    col2_freq = frequencies[comb[1]]\n+                    col1_freq = freq[comb[0]]\n+                    col2_freq = freq[comb[1]]\n \n                     keys = set(col1_freq.keys()).union(col2_freq.keys())\n \n-                    cr_table = [\n+                    n_ij = np.array([\n                         [col1_freq.get(k, 0) for k in keys],\n                         [col2_freq.get(k, 0) for k in keys]\n-                    ]\n+                    ])\n+\n+                    if wt is not None:","path":"CHAID/CHAID.py","position":75,"original_position":76,"commit_id":"cdd4c8174f0f2be5c2d89dbb7f7f2f83aadcc2d0","original_commit_id":"31650661ebf39bedaa6110630edede4180898c98","user":{"login":"xulaus","id":9027149,"avatar_url":"https://avatars.githubusercontent.com/u/9027149?v=3","gravatar_id":"","url":"https://api.github.com/users/xulaus","html_url":"https://github.com/xulaus","followers_url":"https://api.github.com/users/xulaus/followers","following_url":"https://api.github.com/users/xulaus/following{/other_user}","gists_url":"https://api.github.com/users/xulaus/gists{/gist_id}","starred_url":"https://api.github.com/users/xulaus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xulaus/subscriptions","organizations_url":"https://api.github.com/users/xulaus/orgs","repos_url":"https://api.github.com/users/xulaus/repos","events_url":"https://api.github.com/users/xulaus/events{/privacy}","received_events_url":"https://api.github.com/users/xulaus/received_events","type":"User","site_admin":false},"body":"My bad","created_at":"2016-09-15T11:13:23Z","updated_at":"2016-09-15T11:15:53Z","html_url":"https://github.com/Rambatino/CHAID/pull/37#discussion_r78939700","pull_request_url":"https://api.github.com/repos/Rambatino/CHAID/pulls/37","_links":{"self":{"href":"https://api.github.com/repos/Rambatino/CHAID/pulls/comments/78939700"},"html":{"href":"https://github.com/Rambatino/CHAID/pull/37#discussion_r78939700"},"pull_request":{"href":"https://api.github.com/repos/Rambatino/CHAID/pulls/37"}}},"pull_request":{"url":"https://api.github.com/repos/Rambatino/CHAID/pulls/37","id":85235618,"html_url":"https://github.com/Rambatino/CHAID/pull/37","diff_url":"https://github.com/Rambatino/CHAID/pull/37.diff","patch_url":"https://github.com/Rambatino/CHAID/pull/37.patch","issue_url":"https://api.github.com/repos/Rambatino/CHAID/issues/37","number":37,"state":"open","locked":false,"title":"Added SPSS weighting to the CHAID Algorithm","user":{"login":"Rambatino","id":3631109,"avatar_url":"https://avatars.githubusercontent.com/u/3631109?v=3","gravatar_id":"","url":"https://api.github.com/users/Rambatino","html_url":"https://github.com/Rambatino","followers_url":"https://api.github.com/users/Rambatino/followers","following_url":"https://api.github.com/users/Rambatino/following{/other_user}","gists_url":"https://api.github.com/users/Rambatino/gists{/gist_id}","starred_url":"https://api.github.com/users/Rambatino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Rambatino/subscriptions","organizations_url":"https://api.github.com/users/Rambatino/orgs","repos_url":"https://api.github.com/users/Rambatino/repos","events_url":"https://api.github.com/users/Rambatino/events{/privacy}","received_events_url":"https://api.github.com/users/Rambatino/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-09-14T14:14:38Z","updated_at":"2016-09-15T11:15:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"267a52bd9471907d0b4d2ae121a664fef941fe5a","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Rambatino/CHAID/pulls/37/commits","review_comments_url":"https://api.github.com/repos/Rambatino/CHAID/pulls/37/comments","review_comment_url":"https://api.github.com/repos/Rambatino/CHAID/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Rambatino/CHAID/issues/37/comments","statuses_url":"https://api.github.com/repos/Rambatino/CHAID/statuses/cdd4c8174f0f2be5c2d89dbb7f7f2f83aadcc2d0","head":{"label":"Rambatino:feature/spss_weighting","ref":"feature/spss_weighting","sha":"cdd4c8174f0f2be5c2d89dbb7f7f2f83aadcc2d0","user":{"login":"Rambatino","id":3631109,"avatar_url":"https://avatars.githubusercontent.com/u/3631109?v=3","gravatar_id":"","url":"https://api.github.com/users/Rambatino","html_url":"https://github.com/Rambatino","followers_url":"https://api.github.com/users/Rambatino/followers","following_url":"https://api.github.com/users/Rambatino/following{/other_user}","gists_url":"https://api.github.com/users/Rambatino/gists{/gist_id}","starred_url":"https://api.github.com/users/Rambatino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Rambatino/subscriptions","organizations_url":"https://api.github.com/users/Rambatino/orgs","repos_url":"https://api.github.com/users/Rambatino/repos","events_url":"https://api.github.com/users/Rambatino/events{/privacy}","received_events_url":"https://api.github.com/users/Rambatino/received_events","type":"User","site_admin":false},"repo":{"id":56257335,"name":"CHAID","full_name":"Rambatino/CHAID","owner":{"login":"Rambatino","id":3631109,"avatar_url":"https://avatars.githubusercontent.com/u/3631109?v=3","gravatar_id":"","url":"https://api.github.com/users/Rambatino","html_url":"https://github.com/Rambatino","followers_url":"https://api.github.com/users/Rambatino/followers","following_url":"https://api.github.com/users/Rambatino/following{/other_user}","gists_url":"https://api.github.com/users/Rambatino/gists{/gist_id}","starred_url":"https://api.github.com/users/Rambatino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Rambatino/subscriptions","organizations_url":"https://api.github.com/users/Rambatino/orgs","repos_url":"https://api.github.com/users/Rambatino/repos","events_url":"https://api.github.com/users/Rambatino/events{/privacy}","received_events_url":"https://api.github.com/users/Rambatino/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Rambatino/CHAID","description":"A python implementation of the common CHAID algorithm","fork":false,"url":"https://api.github.com/repos/Rambatino/CHAID","forks_url":"https://api.github.com/repos/Rambatino/CHAID/forks","keys_url":"https://api.github.com/repos/Rambatino/CHAID/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Rambatino/CHAID/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Rambatino/CHAID/teams","hooks_url":"https://api.github.com/repos/Rambatino/CHAID/hooks","issue_events_url":"https://api.github.com/repos/Rambatino/CHAID/issues/events{/number}","events_url":"https://api.github.com/repos/Rambatino/CHAID/events","assignees_url":"https://api.github.com/repos/Rambatino/CHAID/assignees{/user}","branches_url":"https://api.github.com/repos/Rambatino/CHAID/branches{/branch}","tags_url":"https://api.github.com/repos/Rambatino/CHAID/tags","blobs_url":"https://api.github.com/repos/Rambatino/CHAID/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Rambatino/CHAID/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Rambatino/CHAID/git/refs{/sha}","trees_url":"https://api.github.com/repos/Rambatino/CHAID/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Rambatino/CHAID/statuses/{sha}","languages_url":"https://api.github.com/repos/Rambatino/CHAID/languages","stargazers_url":"https://api.github.com/repos/Rambatino/CHAID/stargazers","contributors_url":"https://api.github.com/repos/Rambatino/CHAID/contributors","subscribers_url":"https://api.github.com/repos/Rambatino/CHAID/subscribers","subscription_url":"https://api.github.com/repos/Rambatino/CHAID/subscription","commits_url":"https://api.github.com/repos/Rambatino/CHAID/commits{/sha}","git_commits_url":"https://api.github.com/repos/Rambatino/CHAID/git/commits{/sha}","comments_url":"https://api.github.com/repos/Rambatino/CHAID/comments{/number}","issue_comment_url":"https://api.github.com/repos/Rambatino/CHAID/issues/comments{/number}","contents_url":"https://api.github.com/repos/Rambatino/CHAID/contents/{+path}","compare_url":"https://api.github.com/repos/Rambatino/CHAID/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Rambatino/CHAID/merges","archive_url":"https://api.github.com/repos/Rambatino/CHAID/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Rambatino/CHAID/downloads","issues_url":"https://api.github.com/repos/Rambatino/CHAID/issues{/number}","pulls_url":"https://api.github.com/repos/Rambatino/CHAID/pulls{/number}","milestones_url":"https://api.github.com/repos/Rambatino/CHAID/milestones{/number}","notifications_url":"https://api.github.com/repos/Rambatino/CHAID/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Rambatino/CHAID/labels{/name}","releases_url":"https://api.github.com/repos/Rambatino/CHAID/releases{/id}","deployments_url":"https://api.github.com/repos/Rambatino/CHAID/deployments","created_at":"2016-04-14T17:34:11Z","updated_at":"2016-07-22T23:00:54Z","pushed_at":"2016-09-15T10:09:45Z","git_url":"git://github.com/Rambatino/CHAID.git","ssh_url":"git@github.com:Rambatino/CHAID.git","clone_url":"https://github.com/Rambatino/CHAID.git","svn_url":"https://github.com/Rambatino/CHAID","homepage":null,"size":5421,"stargazers_count":3,"watchers_count":3,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":8,"forks":0,"open_issues":8,"watchers":3,"default_branch":"master"}},"base":{"label":"Rambatino:master","ref":"master","sha":"1c453197176832f3a6ce7d0d33f5ab37749cab26","user":{"login":"Rambatino","id":3631109,"avatar_url":"https://avatars.githubusercontent.com/u/3631109?v=3","gravatar_id":"","url":"https://api.github.com/users/Rambatino","html_url":"https://github.com/Rambatino","followers_url":"https://api.github.com/users/Rambatino/followers","following_url":"https://api.github.com/users/Rambatino/following{/other_user}","gists_url":"https://api.github.com/users/Rambatino/gists{/gist_id}","starred_url":"https://api.github.com/users/Rambatino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Rambatino/subscriptions","organizations_url":"https://api.github.com/users/Rambatino/orgs","repos_url":"https://api.github.com/users/Rambatino/repos","events_url":"https://api.github.com/users/Rambatino/events{/privacy}","received_events_url":"https://api.github.com/users/Rambatino/received_events","type":"User","site_admin":false},"repo":{"id":56257335,"name":"CHAID","full_name":"Rambatino/CHAID","owner":{"login":"Rambatino","id":3631109,"avatar_url":"https://avatars.githubusercontent.com/u/3631109?v=3","gravatar_id":"","url":"https://api.github.com/users/Rambatino","html_url":"https://github.com/Rambatino","followers_url":"https://api.github.com/users/Rambatino/followers","following_url":"https://api.github.com/users/Rambatino/following{/other_user}","gists_url":"https://api.github.com/users/Rambatino/gists{/gist_id}","starred_url":"https://api.github.com/users/Rambatino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Rambatino/subscriptions","organizations_url":"https://api.github.com/users/Rambatino/orgs","repos_url":"https://api.github.com/users/Rambatino/repos","events_url":"https://api.github.com/users/Rambatino/events{/privacy}","received_events_url":"https://api.github.com/users/Rambatino/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Rambatino/CHAID","description":"A python implementation of the common CHAID algorithm","fork":false,"url":"https://api.github.com/repos/Rambatino/CHAID","forks_url":"https://api.github.com/repos/Rambatino/CHAID/forks","keys_url":"https://api.github.com/repos/Rambatino/CHAID/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Rambatino/CHAID/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Rambatino/CHAID/teams","hooks_url":"https://api.github.com/repos/Rambatino/CHAID/hooks","issue_events_url":"https://api.github.com/repos/Rambatino/CHAID/issues/events{/number}","events_url":"https://api.github.com/repos/Rambatino/CHAID/events","assignees_url":"https://api.github.com/repos/Rambatino/CHAID/assignees{/user}","branches_url":"https://api.github.com/repos/Rambatino/CHAID/branches{/branch}","tags_url":"https://api.github.com/repos/Rambatino/CHAID/tags","blobs_url":"https://api.github.com/repos/Rambatino/CHAID/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Rambatino/CHAID/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Rambatino/CHAID/git/refs{/sha}","trees_url":"https://api.github.com/repos/Rambatino/CHAID/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Rambatino/CHAID/statuses/{sha}","languages_url":"https://api.github.com/repos/Rambatino/CHAID/languages","stargazers_url":"https://api.github.com/repos/Rambatino/CHAID/stargazers","contributors_url":"https://api.github.com/repos/Rambatino/CHAID/contributors","subscribers_url":"https://api.github.com/repos/Rambatino/CHAID/subscribers","subscription_url":"https://api.github.com/repos/Rambatino/CHAID/subscription","commits_url":"https://api.github.com/repos/Rambatino/CHAID/commits{/sha}","git_commits_url":"https://api.github.com/repos/Rambatino/CHAID/git/commits{/sha}","comments_url":"https://api.github.com/repos/Rambatino/CHAID/comments{/number}","issue_comment_url":"https://api.github.com/repos/Rambatino/CHAID/issues/comments{/number}","contents_url":"https://api.github.com/repos/Rambatino/CHAID/contents/{+path}","compare_url":"https://api.github.com/repos/Rambatino/CHAID/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Rambatino/CHAID/merges","archive_url":"https://api.github.com/repos/Rambatino/CHAID/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Rambatino/CHAID/downloads","issues_url":"https://api.github.com/repos/Rambatino/CHAID/issues{/number}","pulls_url":"https://api.github.com/repos/Rambatino/CHAID/pulls{/number}","milestones_url":"https://api.github.com/repos/Rambatino/CHAID/milestones{/number}","notifications_url":"https://api.github.com/repos/Rambatino/CHAID/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Rambatino/CHAID/labels{/name}","releases_url":"https://api.github.com/repos/Rambatino/CHAID/releases{/id}","deployments_url":"https://api.github.com/repos/Rambatino/CHAID/deployments","created_at":"2016-04-14T17:34:11Z","updated_at":"2016-07-22T23:00:54Z","pushed_at":"2016-09-15T10:09:45Z","git_url":"git://github.com/Rambatino/CHAID.git","ssh_url":"git@github.com:Rambatino/CHAID.git","clone_url":"https://github.com/Rambatino/CHAID.git","svn_url":"https://github.com/Rambatino/CHAID","homepage":null,"size":5421,"stargazers_count":3,"watchers_count":3,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":8,"forks":0,"open_issues":8,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Rambatino/CHAID/pulls/37"},"html":{"href":"https://github.com/Rambatino/CHAID/pull/37"},"issue":{"href":"https://api.github.com/repos/Rambatino/CHAID/issues/37"},"comments":{"href":"https://api.github.com/repos/Rambatino/CHAID/issues/37/comments"},"review_comments":{"href":"https://api.github.com/repos/Rambatino/CHAID/pulls/37/comments"},"review_comment":{"href":"https://api.github.com/repos/Rambatino/CHAID/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Rambatino/CHAID/pulls/37/commits"},"statuses":{"href":"https://api.github.com/repos/Rambatino/CHAID/statuses/cdd4c8174f0f2be5c2d89dbb7f7f2f83aadcc2d0"}}}}
{"actor":{"display_login":"xulaus"}}