{"action":"created","comment":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments/29876335","id":29876335,"diff_hunk":"@@ -0,0 +1,629 @@\n+\"\"\"Extreme Learning Machines\n+\"\"\"\n+\n+# Author: Issam H. Laradji <issam.laradji@gmail.com>\n+# Licence: BSD 3 clause\n+\n+\n+from abc import ABCMeta, abstractmethod\n+\n+import numpy as np\n+from scipy import linalg\n+\n+from ..base import BaseEstimator, ClassifierMixin, RegressorMixin\n+from .base import logistic, softmax, ACTIVATIONS\n+from ..externals import six\n+from ..preprocessing import LabelBinarizer\n+from ..metrics import mean_squared_error\n+from ..linear_model.ridge import ridge_regression\n+from ..utils import gen_batches, check_random_state\n+from ..utils import check_array, check_X_y, column_or_1d\n+from ..utils.extmath import safe_sparse_dot\n+from ..utils.class_weight import compute_sample_weight\n+\n+\n+def _multiply_weights(X, sample_weight):\n+    \"\"\"Return W*X if sample_weight is not None.\"\"\"\n+    if sample_weight is None:\n+        return X\n+    else:\n+        return X * sample_weight[:, np.newaxis]\n+\n+\n+class BaseELM(six.with_metaclass(ABCMeta, BaseEstimator)):\n+    \"\"\"Base class for ELM classification and regression.\n+\n+    Warning: This class should not be used directly.\n+    Use derived classes instead.\n+    \"\"\"\n+    @abstractmethod\n+    def __init__(self, n_hidden, activation, C, class_weight,\n+                 weight_scale, batch_size, verbose, warm_start,\n+                 random_state):\n+        self.C = C\n+        self.activation = activation\n+        self.class_weight = class_weight\n+        self.weight_scale = weight_scale\n+        self.batch_size = batch_size\n+        self.n_hidden = n_hidden\n+        self.verbose = verbose\n+        self.warm_start = warm_start\n+        self.random_state = random_state\n+\n+    def _init_weights(self, n_features):\n+        \"\"\"Initialize the parameter weights.\"\"\"\n+        rng = check_random_state(self.random_state)\n+\n+        # Use the initialization method recommended by Glorot et al.\n+        weight_init_bound = np.sqrt(6. / (n_features + self.n_hidden))\n+\n+        self.coef_hidden_ = rng.uniform(-weight_init_bound,\n+                                        weight_init_bound, (n_features,\n+                                                            self.n_hidden))\n+        self.intercept_hidden_ = rng.uniform(-weight_init_bound,\n+                                             weight_init_bound,\n+                                             self.n_hidden)\n+        if self.weight_scale != 1:\n+            self.coef_hidden_ *= self.weight_scale\n+            self.intercept_hidden_ *= self.weight_scale\n+\n+    def _compute_hidden_activations(self, X):\n+        \"\"\"Compute the hidden activations.\"\"\"\n+\n+        hidden_activations = safe_sparse_dot(X, self.coef_hidden_)\n+        hidden_activations += self.intercept_hidden_\n+\n+        # Apply the activation method\n+        activation = ACTIVATIONS[self.activation]\n+        hidden_activations = activation(hidden_activations)","path":"sklearn/neural_network/extreme_learning_machines.py","position":78,"original_position":78,"commit_id":"8ceefafe8ca72952e2a61d60138cd1610cebca86","original_commit_id":"8ceefafe8ca72952e2a61d60138cd1610cebca86","user":{"login":"mblondel","id":233706,"avatar_url":"https://avatars.githubusercontent.com/u/233706?v=3","gravatar_id":"","url":"https://api.github.com/users/mblondel","html_url":"https://github.com/mblondel","followers_url":"https://api.github.com/users/mblondel/followers","following_url":"https://api.github.com/users/mblondel/following{/other_user}","gists_url":"https://api.github.com/users/mblondel/gists{/gist_id}","starred_url":"https://api.github.com/users/mblondel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mblondel/subscriptions","organizations_url":"https://api.github.com/users/mblondel/orgs","repos_url":"https://api.github.com/users/mblondel/repos","events_url":"https://api.github.com/users/mblondel/events{/privacy}","received_events_url":"https://api.github.com/users/mblondel/received_events","type":"User","site_admin":false},"body":"I wanted to do the same comment. Directly return here.","created_at":"2015-05-07T17:42:29Z","updated_at":"2015-05-07T17:42:29Z","html_url":"https://github.com/scikit-learn/scikit-learn/pull/3306#discussion_r29876335","pull_request_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/3306","_links":{"self":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/comments/29876335"},"html":{"href":"https://github.com/scikit-learn/scikit-learn/pull/3306#discussion_r29876335"},"pull_request":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/3306"}}},"pull_request":{"url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/3306","id":17446637,"html_url":"https://github.com/scikit-learn/scikit-learn/pull/3306","diff_url":"https://github.com/scikit-learn/scikit-learn/pull/3306.diff","patch_url":"https://github.com/scikit-learn/scikit-learn/pull/3306.patch","issue_url":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/3306","number":3306,"state":"open","locked":false,"title":"[MRG] GSoC 2014: Standard Extreme Learning Machines","user":{"login":"IssamLaradji","id":3382128,"avatar_url":"https://avatars.githubusercontent.com/u/3382128?v=3","gravatar_id":"","url":"https://api.github.com/users/IssamLaradji","html_url":"https://github.com/IssamLaradji","followers_url":"https://api.github.com/users/IssamLaradji/followers","following_url":"https://api.github.com/users/IssamLaradji/following{/other_user}","gists_url":"https://api.github.com/users/IssamLaradji/gists{/gist_id}","starred_url":"https://api.github.com/users/IssamLaradji/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IssamLaradji/subscriptions","organizations_url":"https://api.github.com/users/IssamLaradji/orgs","repos_url":"https://api.github.com/users/IssamLaradji/repos","events_url":"https://api.github.com/users/IssamLaradji/events{/privacy}","received_events_url":"https://api.github.com/users/IssamLaradji/received_events","type":"User","site_admin":false},"body":"Finished implementing the standard extreme learning machines (ELMs). I am getting the following results with 550 hidden neurons against the digits datasets,\r\n\r\nTraining accuracy using the logistic activation function: 0.999444\r\nTraining accuracy using the tanh activation function: 1.000000\r\n\r\nFortunately, this algorithm is much easier to implement and debug than multi-layer perceptron :).\r\nI will push a test file soon.\r\n\r\n@ogrisel , @larsmans","created_at":"2014-06-22T08:34:21Z","updated_at":"2015-05-07T17:42:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b03b37b2058373885668c09da3abe2299b6262bc","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/3306/commits","review_comments_url":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/3306/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/3306/comments","statuses_url":"https://api.github.com/repos/scikit-learn/scikit-learn/statuses/8ceefafe8ca72952e2a61d60138cd1610cebca86","head":{"label":"IssamLaradji:Extreme-Learning-Machines","ref":"Extreme-Learning-Machines","sha":"8ceefafe8ca72952e2a61d60138cd1610cebca86","user":{"login":"IssamLaradji","id":3382128,"avatar_url":"https://avatars.githubusercontent.com/u/3382128?v=3","gravatar_id":"","url":"https://api.github.com/users/IssamLaradji","html_url":"https://github.com/IssamLaradji","followers_url":"https://api.github.com/users/IssamLaradji/followers","following_url":"https://api.github.com/users/IssamLaradji/following{/other_user}","gists_url":"https://api.github.com/users/IssamLaradji/gists{/gist_id}","starred_url":"https://api.github.com/users/IssamLaradji/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IssamLaradji/subscriptions","organizations_url":"https://api.github.com/users/IssamLaradji/orgs","repos_url":"https://api.github.com/users/IssamLaradji/repos","events_url":"https://api.github.com/users/IssamLaradji/events{/privacy}","received_events_url":"https://api.github.com/users/IssamLaradji/received_events","type":"User","site_admin":false},"repo":{"id":10518207,"name":"scikit-learn","full_name":"IssamLaradji/scikit-learn","owner":{"login":"IssamLaradji","id":3382128,"avatar_url":"https://avatars.githubusercontent.com/u/3382128?v=3","gravatar_id":"","url":"https://api.github.com/users/IssamLaradji","html_url":"https://github.com/IssamLaradji","followers_url":"https://api.github.com/users/IssamLaradji/followers","following_url":"https://api.github.com/users/IssamLaradji/following{/other_user}","gists_url":"https://api.github.com/users/IssamLaradji/gists{/gist_id}","starred_url":"https://api.github.com/users/IssamLaradji/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IssamLaradji/subscriptions","organizations_url":"https://api.github.com/users/IssamLaradji/orgs","repos_url":"https://api.github.com/users/IssamLaradji/repos","events_url":"https://api.github.com/users/IssamLaradji/events{/privacy}","received_events_url":"https://api.github.com/users/IssamLaradji/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/IssamLaradji/scikit-learn","description":"scikit-learn: machine learning in Python","fork":true,"url":"https://api.github.com/repos/IssamLaradji/scikit-learn","forks_url":"https://api.github.com/repos/IssamLaradji/scikit-learn/forks","keys_url":"https://api.github.com/repos/IssamLaradji/scikit-learn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/IssamLaradji/scikit-learn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/IssamLaradji/scikit-learn/teams","hooks_url":"https://api.github.com/repos/IssamLaradji/scikit-learn/hooks","issue_events_url":"https://api.github.com/repos/IssamLaradji/scikit-learn/issues/events{/number}","events_url":"https://api.github.com/repos/IssamLaradji/scikit-learn/events","assignees_url":"https://api.github.com/repos/IssamLaradji/scikit-learn/assignees{/user}","branches_url":"https://api.github.com/repos/IssamLaradji/scikit-learn/branches{/branch}","tags_url":"https://api.github.com/repos/IssamLaradji/scikit-learn/tags","blobs_url":"https://api.github.com/repos/IssamLaradji/scikit-learn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/IssamLaradji/scikit-learn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/IssamLaradji/scikit-learn/git/refs{/sha}","trees_url":"https://api.github.com/repos/IssamLaradji/scikit-learn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/IssamLaradji/scikit-learn/statuses/{sha}","languages_url":"https://api.github.com/repos/IssamLaradji/scikit-learn/languages","stargazers_url":"https://api.github.com/repos/IssamLaradji/scikit-learn/stargazers","contributors_url":"https://api.github.com/repos/IssamLaradji/scikit-learn/contributors","subscribers_url":"https://api.github.com/repos/IssamLaradji/scikit-learn/subscribers","subscription_url":"https://api.github.com/repos/IssamLaradji/scikit-learn/subscription","commits_url":"https://api.github.com/repos/IssamLaradji/scikit-learn/commits{/sha}","git_commits_url":"https://api.github.com/repos/IssamLaradji/scikit-learn/git/commits{/sha}","comments_url":"https://api.github.com/repos/IssamLaradji/scikit-learn/comments{/number}","issue_comment_url":"https://api.github.com/repos/IssamLaradji/scikit-learn/issues/comments{/number}","contents_url":"https://api.github.com/repos/IssamLaradji/scikit-learn/contents/{+path}","compare_url":"https://api.github.com/repos/IssamLaradji/scikit-learn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/IssamLaradji/scikit-learn/merges","archive_url":"https://api.github.com/repos/IssamLaradji/scikit-learn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/IssamLaradji/scikit-learn/downloads","issues_url":"https://api.github.com/repos/IssamLaradji/scikit-learn/issues{/number}","pulls_url":"https://api.github.com/repos/IssamLaradji/scikit-learn/pulls{/number}","milestones_url":"https://api.github.com/repos/IssamLaradji/scikit-learn/milestones{/number}","notifications_url":"https://api.github.com/repos/IssamLaradji/scikit-learn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/IssamLaradji/scikit-learn/labels{/name}","releases_url":"https://api.github.com/repos/IssamLaradji/scikit-learn/releases{/id}","created_at":"2013-06-06T03:31:53Z","updated_at":"2015-04-20T12:12:15Z","pushed_at":"2015-01-04T23:56:58Z","git_url":"git://github.com/IssamLaradji/scikit-learn.git","ssh_url":"git@github.com:IssamLaradji/scikit-learn.git","clone_url":"https://github.com/IssamLaradji/scikit-learn.git","svn_url":"https://github.com/IssamLaradji/scikit-learn","homepage":"http://scikit-learn.org","size":63007,"stargazers_count":2,"watchers_count":2,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":2,"default_branch":"master"}},"base":{"label":"scikit-learn:master","ref":"master","sha":"67ca4efefea561ca2575d3c241e1f0591956f7aa","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-05-07T17:29:52Z","pushed_at":"2015-05-07T17:40:47Z","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":125836,"stargazers_count":5924,"watchers_count":5924,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3539,"mirror_url":null,"open_issues_count":647,"forks":3539,"open_issues":647,"watchers":5924,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/3306"},"html":{"href":"https://github.com/scikit-learn/scikit-learn/pull/3306"},"issue":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/3306"},"comments":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/issues/3306/comments"},"review_comments":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/pulls/3306/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/3306/commits"},"statuses":{"href":"https://api.github.com/repos/scikit-learn/scikit-learn/statuses/8ceefafe8ca72952e2a61d60138cd1610cebca86"}}}}