{"action":"created","comment":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments/43175350","id":43175350,"diff_hunk":"@@ -0,0 +1,176 @@\n+# cython: cdivision=True\n+# cython: boundscheck=False\n+# cython: wraparound=False\n+#\n+# Author: Andreas Mueller\n+#\n+# Licence: BSD 3 clause\n+\n+import numpy as np\n+cimport numpy as np\n+cimport cython\n+\n+from libc.math cimport sqrt\n+\n+from ..metrics import euclidean_distances\n+from ._k_means import _centers_dense\n+\n+\n+cdef double *getfloatpointer(np.ndarray[np.float64_t, ndim=2, mode='c'] data):\n+    return <double *>(data.data)\n+\n+\n+cdef double d(double* a, double* b, int n_features) nogil:\n+    cdef double result, tmp\n+    result = 0\n+    cdef int i\n+    for i in range(n_features):\n+        tmp = (a[0] - b[0])\n+        a += 1\n+        b += 1\n+        result += tmp * tmp\n+    return sqrt(result)\n+\n+\n+cdef update_labels_distances_inplace(\n+        double* X, double* centers, double[:, :] center_distances, int[:] labels,\n+        double[:, :] lower_bounds, double[:] distances, int n_samples, int\n+        n_features, int n_clusters):\n+    # assigns closest center to X\n+    # uses triangle inequality\n+    cdef double* x\n+    cdef double* c\n+    cdef double d_c, dist\n+    cdef int c_x, j, sample\n+    for sample in range(n_samples):\n+        # assign first cluster center\n+        c_x = 0\n+        x = X + sample * n_features\n+        d_c = d(x, centers, n_features)\n+        lower_bounds[sample, 0] = d_c\n+        for j in range(n_clusters):\n+            if d_c > center_distances[c_x, j]:\n+                c = centers + j * n_features\n+                dist = d(x, c, n_features)\n+                lower_bounds[sample, j] = dist\n+                if dist < d_c:\n+                    d_c = dist\n+                    c_x = j\n+        labels[sample] = c_x\n+        distances[sample] = d_c\n+\n+\n+def k_means_elkan(X_, int n_clusters, init, float tol=1e-4, int max_iter=30, verbose=False):","path":"sklearn/cluster/_k_means_elkan.pyx","position":63,"original_position":63,"commit_id":"fee7ec62b3f28e1f2a21ac431e9bdfe91af0858e","original_commit_id":"fee7ec62b3f28e1f2a21ac431e9bdfe91af0858e","user":{"login":"MechCoder","id":1867024,"avatar_url":"https://avatars.githubusercontent.com/u/1867024?v=3","gravatar_id":"","url":"https://api.github.com/users/MechCoder","html_url":"https://github.com/MechCoder","followers_url":"https://api.github.com/users/MechCoder/followers","following_url":"https://api.github.com/users/MechCoder/following{/other_user}","gists_url":"https://api.github.com/users/MechCoder/gists{/gist_id}","starred_url":"https://api.github.com/users/MechCoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MechCoder/subscriptions","organizations_url":"https://api.github.com/users/MechCoder/orgs","repos_url":"https://api.github.com/users/MechCoder/repos","events_url":"https://api.github.com/users/MechCoder/events{/privacy}","received_events_url":"https://api.github.com/users/MechCoder/received_events","type":"User","site_admin":false},"body":"X_, init and verbose should have types","created_at":"2015-10-27T19:42:29Z","updated_at":"2015-10-27T19:42:29Z","html_url":"https://github.com/scikit-learn/scikit-learn/pull/5414#discussion_r43175350","pull_request_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/5414","_links":{"self":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments/43175350"},"html":{"href":"https://github.com/scikit-learn/scikit-learn/pull/5414#discussion_r43175350"},"pull_request":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/5414"}}},"pull_request":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/5414","id":47841775,"html_url":"https://github.com/scikit-learn/scikit-learn/pull/5414","diff_url":"https://github.com/scikit-learn/scikit-learn/pull/5414.diff","patch_url":"https://github.com/scikit-learn/scikit-learn/pull/5414.patch","issue_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/5414","number":5414,"state":"open","locked":false,"title":"[MRG] Elkans K means","user":{"login":"vighneshbirodkar","id":3823490,"avatar_url":"https://avatars.githubusercontent.com/u/3823490?v=3","gravatar_id":"","url":"https://api.github.com/users/vighneshbirodkar","html_url":"https://github.com/vighneshbirodkar","followers_url":"https://api.github.com/users/vighneshbirodkar/followers","following_url":"https://api.github.com/users/vighneshbirodkar/following{/other_user}","gists_url":"https://api.github.com/users/vighneshbirodkar/gists{/gist_id}","starred_url":"https://api.github.com/users/vighneshbirodkar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vighneshbirodkar/subscriptions","organizations_url":"https://api.github.com/users/vighneshbirodkar/orgs","repos_url":"https://api.github.com/users/vighneshbirodkar/repos","events_url":"https://api.github.com/users/vighneshbirodkar/events{/privacy}","received_events_url":"https://api.github.com/users/vighneshbirodkar/received_events","type":"User","site_admin":false},"body":"It is just minor modifications to @amueller 's PR #2008 ","created_at":"2015-10-15T21:06:15Z","updated_at":"2015-10-27T19:42:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2fa3fa455cdcfa57800477099ef8acde99c3e43c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/5414/commits","review_comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/5414/comments","review_comment_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments{/number}","comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/5414/comments","statuses_url":"https://api.github.com/repos/scikit-learn/scikit-learn/statuses/fee7ec62b3f28e1f2a21ac431e9bdfe91af0858e","head":{"label":"vighneshbirodkar:el","ref":"el","sha":"fee7ec62b3f28e1f2a21ac431e9bdfe91af0858e","user":{"login":"vighneshbirodkar","id":3823490,"avatar_url":"https://avatars.githubusercontent.com/u/3823490?v=3","gravatar_id":"","url":"https://api.github.com/users/vighneshbirodkar","html_url":"https://github.com/vighneshbirodkar","followers_url":"https://api.github.com/users/vighneshbirodkar/followers","following_url":"https://api.github.com/users/vighneshbirodkar/following{/other_user}","gists_url":"https://api.github.com/users/vighneshbirodkar/gists{/gist_id}","starred_url":"https://api.github.com/users/vighneshbirodkar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vighneshbirodkar/subscriptions","organizations_url":"https://api.github.com/users/vighneshbirodkar/orgs","repos_url":"https://api.github.com/users/vighneshbirodkar/repos","events_url":"https://api.github.com/users/vighneshbirodkar/events{/privacy}","received_events_url":"https://api.github.com/users/vighneshbirodkar/received_events","type":"User","site_admin":false},"repo":{"id":41329896,"name":"scikit-learn","full_name":"vighneshbirodkar/scikit-learn","owner":{"login":"vighneshbirodkar","id":3823490,"avatar_url":"https://avatars.githubusercontent.com/u/3823490?v=3","gravatar_id":"","url":"https://api.github.com/users/vighneshbirodkar","html_url":"https://github.com/vighneshbirodkar","followers_url":"https://api.github.com/users/vighneshbirodkar/followers","following_url":"https://api.github.com/users/vighneshbirodkar/following{/other_user}","gists_url":"https://api.github.com/users/vighneshbirodkar/gists{/gist_id}","starred_url":"https://api.github.com/users/vighneshbirodkar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vighneshbirodkar/subscriptions","organizations_url":"https://api.github.com/users/vighneshbirodkar/orgs","repos_url":"https://api.github.com/users/vighneshbirodkar/repos","events_url":"https://api.github.com/users/vighneshbirodkar/events{/privacy}","received_events_url":"https://api.github.com/users/vighneshbirodkar/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vighneshbirodkar/scikit-learn","description":"scikit-learn: machine learning in Python","fork":true,"url":"https://api.github.com/repos/vighneshbirodkar/scikit-learn","forks_url":"https://api.github.com/repos/vighneshbirodkar/scikit-learn/forks","keys_url":"https://api.github.com/repos/vighneshbirodkar/scikit-learn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vighneshbirodkar/scikit-learn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vighneshbirodkar/scikit-learn/teams","hooks_url":"https://api.github.com/repos/vighneshbirodkar/scikit-learn/hooks","issue_events_url":"https://api.github.com/repos/vighneshbirodkar/scikit-learn/issues/events{/number}","events_url":"https://api.github.com/repos/vighneshbirodkar/scikit-learn/events","assignees_url":"https://api.github.com/repos/vighneshbirodkar/scikit-learn/assignees{/user}","branches_url":"https://api.github.com/repos/vighneshbirodkar/scikit-learn/branches{/branch}","tags_url":"https://api.github.com/repos/vighneshbirodkar/scikit-learn/tags","blobs_url":"https://api.github.com/repos/vighneshbirodkar/scikit-learn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vighneshbirodkar/scikit-learn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vighneshbirodkar/scikit-learn/git/refs{/sha}","trees_url":"https://api.github.com/repos/vighneshbirodkar/scikit-learn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vighneshbirodkar/scikit-learn/statuses/{sha}","languages_url":"https://api.github.com/repos/vighneshbirodkar/scikit-learn/languages","stargazers_url":"https://api.github.com/repos/vighneshbirodkar/scikit-learn/stargazers","contributors_url":"https://api.github.com/repos/vighneshbirodkar/scikit-learn/contributors","subscribers_url":"https://api.github.com/repos/vighneshbirodkar/scikit-learn/subscribers","subscription_url":"https://api.github.com/repos/vighneshbirodkar/scikit-learn/subscription","commits_url":"https://api.github.com/repos/vighneshbirodkar/scikit-learn/commits{/sha}","git_commits_url":"https://api.github.com/repos/vighneshbirodkar/scikit-learn/git/commits{/sha}","comments_url":"https://api.github.com/repos/vighneshbirodkar/scikit-learn/comments{/number}","issue_comment_url":"https://api.github.com/repos/vighneshbirodkar/scikit-learn/issues/comments{/number}","contents_url":"https://api.github.com/repos/vighneshbirodkar/scikit-learn/contents/{+path}","compare_url":"https://api.github.com/repos/vighneshbirodkar/scikit-learn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vighneshbirodkar/scikit-learn/merges","archive_url":"https://api.github.com/repos/vighneshbirodkar/scikit-learn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vighneshbirodkar/scikit-learn/downloads","issues_url":"https://api.github.com/repos/vighneshbirodkar/scikit-learn/issues{/number}","pulls_url":"https://api.github.com/repos/vighneshbirodkar/scikit-learn/pulls{/number}","milestones_url":"https://api.github.com/repos/vighneshbirodkar/scikit-learn/milestones{/number}","notifications_url":"https://api.github.com/repos/vighneshbirodkar/scikit-learn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vighneshbirodkar/scikit-learn/labels{/name}","releases_url":"https://api.github.com/repos/vighneshbirodkar/scikit-learn/releases{/id}","created_at":"2015-08-24T22:22:54Z","updated_at":"2015-08-24T22:23:00Z","pushed_at":"2015-10-27T16:19:32Z","git_url":"git://github.com/vighneshbirodkar/scikit-learn.git","ssh_url":"git@github.com:vighneshbirodkar/scikit-learn.git","clone_url":"https://github.com/vighneshbirodkar/scikit-learn.git","svn_url":"https://github.com/vighneshbirodkar/scikit-learn","homepage":"http://scikit-learn.org","size":68792,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"scikit-learn:master","ref":"master","sha":"3f8743f47b61a269e8bfff2322cb544170976574","user":{"login":"scikit-learn","id":365630,"avatar_url":"https://avatars.githubusercontent.com/u/365630?v=3","gravatar_id":"","url":"https://api.github.com/users/scikit-learn","html_url":"https://github.com/scikit-learn","followers_url":"https://api.github.com/users/scikit-learn/followers","following_url":"https://api.github.com/users/scikit-learn/following{/other_user}","gists_url":"https://api.github.com/users/scikit-learn/gists{/gist_id}","starred_url":"https://api.github.com/users/scikit-learn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scikit-learn/subscriptions","organizations_url":"https://api.github.com/users/scikit-learn/orgs","repos_url":"https://api.github.com/users/scikit-learn/repos","events_url":"https://api.github.com/users/scikit-learn/events{/privacy}","received_events_url":"https://api.github.com/users/scikit-learn/received_events","type":"Organization","site_admin":false},"repo":{"id":843222,"name":"scikit-learn","full_name":"scikit-learn/scikit-learn","owner":{"login":"scikit-learn","id":365630,"avatar_url":"https://avatars.githubusercontent.com/u/365630?v=3","gravatar_id":"","url":"https://api.github.com/users/scikit-learn","html_url":"https://github.com/scikit-learn","followers_url":"https://api.github.com/users/scikit-learn/followers","following_url":"https://api.github.com/users/scikit-learn/following{/other_user}","gists_url":"https://api.github.com/users/scikit-learn/gists{/gist_id}","starred_url":"https://api.github.com/users/scikit-learn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scikit-learn/subscriptions","organizations_url":"https://api.github.com/users/scikit-learn/orgs","repos_url":"https://api.github.com/users/scikit-learn/repos","events_url":"https://api.github.com/users/scikit-learn/events{/privacy}","received_events_url":"https://api.github.com/users/scikit-learn/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/scikit-learn/scikit-learn","description":"scikit-learn: machine learning in Python","fork":false,"url":"https://api.github.com/repos/scikit-learn/scikit-learn","forks_url":"https://api.github.com/repos/scikit-learn/scikit-learn/forks","keys_url":"https://api.github.com/repos/scikit-learn/scikit-learn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scikit-learn/scikit-learn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scikit-learn/scikit-learn/teams","hooks_url":"https://api.github.com/repos/scikit-learn/scikit-learn/hooks","issue_events_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/events{/number}","events_url":"https://api.github.com/repos/scikit-learn/scikit-learn/events","assignees_url":"https://api.github.com/repos/scikit-learn/scikit-learn/assignees{/user}","branches_url":"https://api.github.com/repos/scikit-learn/scikit-learn/branches{/branch}","tags_url":"https://api.github.com/repos/scikit-learn/scikit-learn/tags","blobs_url":"https://api.github.com/repos/scikit-learn/scikit-learn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scikit-learn/scikit-learn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scikit-learn/scikit-learn/git/refs{/sha}","trees_url":"https://api.github.com/repos/scikit-learn/scikit-learn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scikit-learn/scikit-learn/statuses/{sha}","languages_url":"https://api.github.com/repos/scikit-learn/scikit-learn/languages","stargazers_url":"https://api.github.com/repos/scikit-learn/scikit-learn/stargazers","contributors_url":"https://api.github.com/repos/scikit-learn/scikit-learn/contributors","subscribers_url":"https://api.github.com/repos/scikit-learn/scikit-learn/subscribers","subscription_url":"https://api.github.com/repos/scikit-learn/scikit-learn/subscription","commits_url":"https://api.github.com/repos/scikit-learn/scikit-learn/commits{/sha}","git_commits_url":"https://api.github.com/repos/scikit-learn/scikit-learn/git/commits{/sha}","comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/comments{/number}","issue_comment_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/comments{/number}","contents_url":"https://api.github.com/repos/scikit-learn/scikit-learn/contents/{+path}","compare_url":"https://api.github.com/repos/scikit-learn/scikit-learn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scikit-learn/scikit-learn/merges","archive_url":"https://api.github.com/repos/scikit-learn/scikit-learn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scikit-learn/scikit-learn/downloads","issues_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues{/number}","pulls_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls{/number}","milestones_url":"https://api.github.com/repos/scikit-learn/scikit-learn/milestones{/number}","notifications_url":"https://api.github.com/repos/scikit-learn/scikit-learn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scikit-learn/scikit-learn/labels{/name}","releases_url":"https://api.github.com/repos/scikit-learn/scikit-learn/releases{/id}","created_at":"2010-08-17T09:43:38Z","updated_at":"2015-10-27T16:57:22Z","pushed_at":"2015-10-27T16:56:44Z","git_url":"git://github.com/scikit-learn/scikit-learn.git","ssh_url":"git@github.com:scikit-learn/scikit-learn.git","clone_url":"https://github.com/scikit-learn/scikit-learn.git","svn_url":"https://github.com/scikit-learn/scikit-learn","homepage":"http://scikit-learn.org","size":141185,"stargazers_count":8004,"watchers_count":8004,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4777,"mirror_url":null,"open_issues_count":793,"forks":4777,"open_issues":793,"watchers":8004,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/5414"},"html":{"href":"https://github.com/scikit-learn/scikit-learn/pull/5414"},"issue":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/5414"},"comments":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/5414/comments"},"review_comments":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/5414/comments"},"review_comment":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/5414/commits"},"statuses":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/statuses/fee7ec62b3f28e1f2a21ac431e9bdfe91af0858e"}}}}