{"action":"created","comment":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments/75579726","id":75579726,"diff_hunk":"@@ -0,0 +1,284 @@\n+# -*- coding: utf-8 -*-\n+\"\"\"K-medoids clustering\"\"\"\n+\n+# Authors: Timo Erkkilä <timo.erkkila@gmail.com>\n+#          Antti Lehmussola <antti.lehmussola@gmail.com>\n+# License: BSD 3 clause\n+\n+import numpy as np\n+import warnings\n+\n+from ..base import BaseEstimator, ClusterMixin, TransformerMixin\n+from ..metrics.pairwise import PAIRWISE_DISTANCE_FUNCTIONS\n+from ..utils import check_array, check_random_state\n+from ..utils.validation import check_is_fitted\n+\n+\n+class KMedoids(BaseEstimator, ClusterMixin, TransformerMixin):\n+    \"\"\"\n+    k-medoids class.\n+\n+    Parameters\n+    ----------\n+    n_clusters : int, optional, default: 8\n+        How many medoids. Must be positive.\n+\n+    distance_metric : string, optional, default: 'euclidean'\n+        What distance metric to use.\n+\n+    clustering : {'pam'}, optional, default: 'pam'\n+        What clustering mode to use.\n+\n+    init : {'random', 'heuristic'}, optional, default: 'heuristic'\n+        Specify medoid initialization.\n+\n+    max_iter : int, optional, default : 300\n+        Specify the maximum number of iterations when fitting.\n+\n+    random_state : int, optional, default: None\n+        Specify random state for the random number generator.\n+    \"\"\"\n+\n+    # Supported clustering methods\n+    CLUSTERING_METHODS = ['pam']\n+\n+    # Supported initialization methods\n+    INIT_METHODS = ['random', 'heuristic']\n+\n+    def __init__(self, n_clusters=8, distance_metric='euclidean',\n+                 clustering_method='pam', init='heuristic',\n+                 max_iter=300, random_state=None):\n+\n+        self.n_clusters = n_clusters\n+","path":"sklearn/cluster/k_medoids_.py","position":53,"original_position":53,"commit_id":"ce62299beeef71775accf888dd4413d01d3eed26","original_commit_id":"223fa78581bb46c0f48d86c0d2a361387b29aaf3","user":{"login":"agramfort","id":161052,"avatar_url":"https://avatars.githubusercontent.com/u/161052?v=3","gravatar_id":"","url":"https://api.github.com/users/agramfort","html_url":"https://github.com/agramfort","followers_url":"https://api.github.com/users/agramfort/followers","following_url":"https://api.github.com/users/agramfort/following{/other_user}","gists_url":"https://api.github.com/users/agramfort/gists{/gist_id}","starred_url":"https://api.github.com/users/agramfort/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agramfort/subscriptions","organizations_url":"https://api.github.com/users/agramfort/orgs","repos_url":"https://api.github.com/users/agramfort/repos","events_url":"https://api.github.com/users/agramfort/events{/privacy}","received_events_url":"https://api.github.com/users/agramfort/received_events","type":"User","site_admin":false},"body":"+1","created_at":"2016-08-20T14:41:26Z","updated_at":"2016-08-20T14:41:26Z","html_url":"https://github.com/scikit-learn/scikit-learn/pull/5085#discussion_r75579726","pull_request_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/5085","_links":{"self":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments/75579726"},"html":{"href":"https://github.com/scikit-learn/scikit-learn/pull/5085#discussion_r75579726"},"pull_request":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/5085"}}},"pull_request":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/5085","id":41605122,"html_url":"https://github.com/scikit-learn/scikit-learn/pull/5085","diff_url":"https://github.com/scikit-learn/scikit-learn/pull/5085.diff","patch_url":"https://github.com/scikit-learn/scikit-learn/pull/5085.patch","issue_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/5085","number":5085,"state":"open","locked":false,"title":"Adding K-Medoids clustering algorithm ","user":{"login":"terkkila","id":1221677,"avatar_url":"https://avatars.githubusercontent.com/u/1221677?v=3","gravatar_id":"","url":"https://api.github.com/users/terkkila","html_url":"https://github.com/terkkila","followers_url":"https://api.github.com/users/terkkila/followers","following_url":"https://api.github.com/users/terkkila/following{/other_user}","gists_url":"https://api.github.com/users/terkkila/gists{/gist_id}","starred_url":"https://api.github.com/users/terkkila/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/terkkila/subscriptions","organizations_url":"https://api.github.com/users/terkkila/orgs","repos_url":"https://api.github.com/users/terkkila/repos","events_url":"https://api.github.com/users/terkkila/events{/privacy}","received_events_url":"https://api.github.com/users/terkkila/received_events","type":"User","site_admin":false},"body":"Added K-Medoids clustering algorithm\r\n- Introducing new KMedoids class, which is derived from the BaseEstimator\r\n- Unit test coverage 91%\r\n- Unit tests passing: `nosetests -v sklearn/cluster/tests/test_k_medoids.py`\r\n- Code is documented\r\n- Example script: `python examples/cluster/plot_kmedoids_digits.py`\r\n","created_at":"2015-08-04T19:02:55Z","updated_at":"2016-08-20T14:41:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b3b8515623b99b4f7aae391976b8ba7d7ab1c443","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/5085/commits","review_comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/5085/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/5085/comments","statuses_url":"https://api.github.com/repos/scikit-learn/scikit-learn/statuses/ce62299beeef71775accf888dd4413d01d3eed26","head":{"label":"terkkila:kmedoids","ref":"kmedoids","sha":"ce62299beeef71775accf888dd4413d01d3eed26","user":{"login":"terkkila","id":1221677,"avatar_url":"https://avatars.githubusercontent.com/u/1221677?v=3","gravatar_id":"","url":"https://api.github.com/users/terkkila","html_url":"https://github.com/terkkila","followers_url":"https://api.github.com/users/terkkila/followers","following_url":"https://api.github.com/users/terkkila/following{/other_user}","gists_url":"https://api.github.com/users/terkkila/gists{/gist_id}","starred_url":"https://api.github.com/users/terkkila/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/terkkila/subscriptions","organizations_url":"https://api.github.com/users/terkkila/orgs","repos_url":"https://api.github.com/users/terkkila/repos","events_url":"https://api.github.com/users/terkkila/events{/privacy}","received_events_url":"https://api.github.com/users/terkkila/received_events","type":"User","site_admin":false},"repo":{"id":40009472,"name":"scikit-learn","full_name":"terkkila/scikit-learn","owner":{"login":"terkkila","id":1221677,"avatar_url":"https://avatars.githubusercontent.com/u/1221677?v=3","gravatar_id":"","url":"https://api.github.com/users/terkkila","html_url":"https://github.com/terkkila","followers_url":"https://api.github.com/users/terkkila/followers","following_url":"https://api.github.com/users/terkkila/following{/other_user}","gists_url":"https://api.github.com/users/terkkila/gists{/gist_id}","starred_url":"https://api.github.com/users/terkkila/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/terkkila/subscriptions","organizations_url":"https://api.github.com/users/terkkila/orgs","repos_url":"https://api.github.com/users/terkkila/repos","events_url":"https://api.github.com/users/terkkila/events{/privacy}","received_events_url":"https://api.github.com/users/terkkila/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/terkkila/scikit-learn","description":"scikit-learn: machine learning in Python","fork":true,"url":"https://api.github.com/repos/terkkila/scikit-learn","forks_url":"https://api.github.com/repos/terkkila/scikit-learn/forks","keys_url":"https://api.github.com/repos/terkkila/scikit-learn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/terkkila/scikit-learn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/terkkila/scikit-learn/teams","hooks_url":"https://api.github.com/repos/terkkila/scikit-learn/hooks","issue_events_url":"https://api.github.com/repos/terkkila/scikit-learn/issues/events{/number}","events_url":"https://api.github.com/repos/terkkila/scikit-learn/events","assignees_url":"https://api.github.com/repos/terkkila/scikit-learn/assignees{/user}","branches_url":"https://api.github.com/repos/terkkila/scikit-learn/branches{/branch}","tags_url":"https://api.github.com/repos/terkkila/scikit-learn/tags","blobs_url":"https://api.github.com/repos/terkkila/scikit-learn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/terkkila/scikit-learn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/terkkila/scikit-learn/git/refs{/sha}","trees_url":"https://api.github.com/repos/terkkila/scikit-learn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/terkkila/scikit-learn/statuses/{sha}","languages_url":"https://api.github.com/repos/terkkila/scikit-learn/languages","stargazers_url":"https://api.github.com/repos/terkkila/scikit-learn/stargazers","contributors_url":"https://api.github.com/repos/terkkila/scikit-learn/contributors","subscribers_url":"https://api.github.com/repos/terkkila/scikit-learn/subscribers","subscription_url":"https://api.github.com/repos/terkkila/scikit-learn/subscription","commits_url":"https://api.github.com/repos/terkkila/scikit-learn/commits{/sha}","git_commits_url":"https://api.github.com/repos/terkkila/scikit-learn/git/commits{/sha}","comments_url":"https://api.github.com/repos/terkkila/scikit-learn/comments{/number}","issue_comment_url":"https://api.github.com/repos/terkkila/scikit-learn/issues/comments{/number}","contents_url":"https://api.github.com/repos/terkkila/scikit-learn/contents/{+path}","compare_url":"https://api.github.com/repos/terkkila/scikit-learn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/terkkila/scikit-learn/merges","archive_url":"https://api.github.com/repos/terkkila/scikit-learn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/terkkila/scikit-learn/downloads","issues_url":"https://api.github.com/repos/terkkila/scikit-learn/issues{/number}","pulls_url":"https://api.github.com/repos/terkkila/scikit-learn/pulls{/number}","milestones_url":"https://api.github.com/repos/terkkila/scikit-learn/milestones{/number}","notifications_url":"https://api.github.com/repos/terkkila/scikit-learn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/terkkila/scikit-learn/labels{/name}","releases_url":"https://api.github.com/repos/terkkila/scikit-learn/releases{/id}","deployments_url":"https://api.github.com/repos/terkkila/scikit-learn/deployments","created_at":"2015-07-31T14:35:48Z","updated_at":"2016-04-18T17:37:18Z","pushed_at":"2016-03-13T21:32:43Z","git_url":"git://github.com/terkkila/scikit-learn.git","ssh_url":"git@github.com:terkkila/scikit-learn.git","clone_url":"https://github.com/terkkila/scikit-learn.git","svn_url":"https://github.com/terkkila/scikit-learn","homepage":"http://scikit-learn.org","size":66643,"stargazers_count":3,"watchers_count":3,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":0,"forks":3,"open_issues":0,"watchers":3,"default_branch":"master"}},"base":{"label":"scikit-learn:master","ref":"master","sha":"aadaf0f3d5d5da6861770e6033e5ab85e7f90872","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}","deployments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/deployments","created_at":"2010-08-17T09:43:38Z","updated_at":"2016-08-20T13:20:32Z","pushed_at":"2016-08-20T14:37:55Z","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":122779,"stargazers_count":12911,"watchers_count":12911,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7468,"mirror_url":null,"open_issues_count":1256,"forks":7468,"open_issues":1256,"watchers":12911,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/5085"},"html":{"href":"https://github.com/scikit-learn/scikit-learn/pull/5085"},"issue":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/5085"},"comments":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/5085/comments"},"review_comments":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/5085/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/5085/commits"},"statuses":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/statuses/ce62299beeef71775accf888dd4413d01d3eed26"}}}}
{"actor":{"display_login":"agramfort"}}