{"action":"created","comment":{"url":"https://api.github.com/repos/nilearn/nilearn/pulls/comments/44082070","id":44082070,"diff_hunk":"@@ -0,0 +1,275 @@\n+\"\"\"\n+Dictionary learning estimator: Perform a map learning algorithm by learning\n+a temporal dense dictionary along with sparse spatial loadings, that\n+constitutes output maps\n+\"\"\"\n+\n+# Author: Arthur Mensch\n+# License: BSD 3 clause\n+\n+from __future__ import division\n+\n+import warnings\n+from distutils.version import LooseVersion\n+\n+import numpy as np\n+import sklearn\n+from sklearn.base import TransformerMixin\n+from sklearn.decomposition import dict_learning_online\n+from sklearn.externals.joblib import Memory\n+from sklearn.linear_model import Ridge\n+\n+from .base import BaseDecomposition, mask_and_reduce\n+from .canica import CanICA\n+from .._utils.cache_mixin import CacheMixin\n+\n+if LooseVersion(sklearn.__version__) >= LooseVersion('0.17'):\n+    # check_input=False is an optimization available only in sklearn >=0.17\n+    sparse_encode_args = {'check_input': False}\n+\n+\n+def _compute_loadings(components, data):\n+    ridge = Ridge(fit_intercept=None, alpha=1e-8)\n+    ridge.fit(components.T, np.asarray(data.T))\n+    loadings = ridge.coef_.T\n+\n+    S = np.sqrt(np.sum(loadings ** 2, axis=0))\n+    S[S == 0] = 1\n+    loadings /= S[np.newaxis, :]\n+    return loadings\n+\n+\n+class DictLearning(BaseDecomposition, TransformerMixin, CacheMixin):\n+    \"\"\"Perform a map learning algorithm based on component sparsity,\n+     over a CanICA initialization.  This yields more stable maps than CanICA.","path":"nilearn/decomposition/dict_learning.py","position":44,"original_position":44,"commit_id":"cd3cd7ad781f2865d7876b81f757850a3882a7fa","original_commit_id":"cd3cd7ad781f2865d7876b81f757850a3882a7fa","user":{"login":"banilo","id":3907396,"avatar_url":"https://avatars.githubusercontent.com/u/3907396?v=3","gravatar_id":"","url":"https://api.github.com/users/banilo","html_url":"https://github.com/banilo","followers_url":"https://api.github.com/users/banilo/followers","following_url":"https://api.github.com/users/banilo/following{/other_user}","gists_url":"https://api.github.com/users/banilo/gists{/gist_id}","starred_url":"https://api.github.com/users/banilo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/banilo/subscriptions","organizations_url":"https://api.github.com/users/banilo/orgs","repos_url":"https://api.github.com/users/banilo/repos","events_url":"https://api.github.com/users/banilo/events{/privacy}","received_events_url":"https://api.github.com/users/banilo/received_events","type":"User","site_admin":false},"body":"Bach & Co usually like to distinguish \"fixed\" and non-\"fixed\" dictionaries in DL appraoches.\r\nBesides a reminder to be explicit about wether the map coeffients/loadings (typical sparse DL) or weights (closer to SparsePCA) are what will be sparse.","created_at":"2015-11-05T22:54:01Z","updated_at":"2015-11-05T22:54:01Z","html_url":"https://github.com/nilearn/nilearn/pull/693#discussion_r44082070","pull_request_url":"https://api.github.com/repos/nilearn/nilearn/pulls/693","_links":{"self":{"href":"https://api.github.com/repos/nilearn/nilearn/pulls/comments/44082070"},"html":{"href":"https://github.com/nilearn/nilearn/pull/693#discussion_r44082070"},"pull_request":{"href":"https://api.github.com/repos/nilearn/nilearn/pulls/693"}}},"pull_request":{"url":"https://api.github.com/repos/nilearn/nilearn/pulls/693","id":40142833,"html_url":"https://github.com/nilearn/nilearn/pull/693","diff_url":"https://github.com/nilearn/nilearn/pull/693.diff","patch_url":"https://github.com/nilearn/nilearn/pull/693.patch","issue_url":"https://api.github.com/repos/nilearn/nilearn/issues/693","number":693,"state":"open","locked":false,"title":"[MRG] Dictionary learning + nilearn.decomposition refactoring","user":{"login":"arthurmensch","id":4078691,"avatar_url":"https://avatars.githubusercontent.com/u/4078691?v=3","gravatar_id":"","url":"https://api.github.com/users/arthurmensch","html_url":"https://github.com/arthurmensch","followers_url":"https://api.github.com/users/arthurmensch/followers","following_url":"https://api.github.com/users/arthurmensch/following{/other_user}","gists_url":"https://api.github.com/users/arthurmensch/gists{/gist_id}","starred_url":"https://api.github.com/users/arthurmensch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arthurmensch/subscriptions","organizations_url":"https://api.github.com/users/arthurmensch/orgs","repos_url":"https://api.github.com/users/arthurmensch/repos","events_url":"https://api.github.com/users/arthurmensch/events{/privacy}","received_events_url":"https://api.github.com/users/arthurmensch/received_events","type":"User","site_admin":false},"body":"Decomposition estimators (`DictLearning` / `MultiPCA`) now inherit a  `DecompositionEstimator`.\r\n\r\nLoading of data is made through a `PCAMultiNiftiMasker`, which loads data from files and compress it.\r\n\r\nPotentially, the function check_masker could solve issue #688, as it factorizes the input checking of estimator to which you provide either a masker or parameters for a mask. It is tuned to be able to use `PCAMultiNiftiMasker`","created_at":"2015-07-16T15:36:20Z","updated_at":"2015-11-05T22:54:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6b72ef70396424ca548cc13c6fc7cc3c5bb71759","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/nilearn/nilearn/pulls/693/commits","review_comments_url":"https://api.github.com/repos/nilearn/nilearn/pulls/693/comments","review_comment_url":"https://api.github.com/repos/nilearn/nilearn/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nilearn/nilearn/issues/693/comments","statuses_url":"https://api.github.com/repos/nilearn/nilearn/statuses/cd3cd7ad781f2865d7876b81f757850a3882a7fa","head":{"label":"arthurmensch:l1_dict_learning_composition_mask","ref":"l1_dict_learning_composition_mask","sha":"cd3cd7ad781f2865d7876b81f757850a3882a7fa","user":{"login":"arthurmensch","id":4078691,"avatar_url":"https://avatars.githubusercontent.com/u/4078691?v=3","gravatar_id":"","url":"https://api.github.com/users/arthurmensch","html_url":"https://github.com/arthurmensch","followers_url":"https://api.github.com/users/arthurmensch/followers","following_url":"https://api.github.com/users/arthurmensch/following{/other_user}","gists_url":"https://api.github.com/users/arthurmensch/gists{/gist_id}","starred_url":"https://api.github.com/users/arthurmensch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arthurmensch/subscriptions","organizations_url":"https://api.github.com/users/arthurmensch/orgs","repos_url":"https://api.github.com/users/arthurmensch/repos","events_url":"https://api.github.com/users/arthurmensch/events{/privacy}","received_events_url":"https://api.github.com/users/arthurmensch/received_events","type":"User","site_admin":false},"repo":{"id":37450678,"name":"nilearn","full_name":"arthurmensch/nilearn","owner":{"login":"arthurmensch","id":4078691,"avatar_url":"https://avatars.githubusercontent.com/u/4078691?v=3","gravatar_id":"","url":"https://api.github.com/users/arthurmensch","html_url":"https://github.com/arthurmensch","followers_url":"https://api.github.com/users/arthurmensch/followers","following_url":"https://api.github.com/users/arthurmensch/following{/other_user}","gists_url":"https://api.github.com/users/arthurmensch/gists{/gist_id}","starred_url":"https://api.github.com/users/arthurmensch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arthurmensch/subscriptions","organizations_url":"https://api.github.com/users/arthurmensch/orgs","repos_url":"https://api.github.com/users/arthurmensch/repos","events_url":"https://api.github.com/users/arthurmensch/events{/privacy}","received_events_url":"https://api.github.com/users/arthurmensch/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/arthurmensch/nilearn","description":"Machine learning for NeuroImaging in Python","fork":true,"url":"https://api.github.com/repos/arthurmensch/nilearn","forks_url":"https://api.github.com/repos/arthurmensch/nilearn/forks","keys_url":"https://api.github.com/repos/arthurmensch/nilearn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/arthurmensch/nilearn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/arthurmensch/nilearn/teams","hooks_url":"https://api.github.com/repos/arthurmensch/nilearn/hooks","issue_events_url":"https://api.github.com/repos/arthurmensch/nilearn/issues/events{/number}","events_url":"https://api.github.com/repos/arthurmensch/nilearn/events","assignees_url":"https://api.github.com/repos/arthurmensch/nilearn/assignees{/user}","branches_url":"https://api.github.com/repos/arthurmensch/nilearn/branches{/branch}","tags_url":"https://api.github.com/repos/arthurmensch/nilearn/tags","blobs_url":"https://api.github.com/repos/arthurmensch/nilearn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/arthurmensch/nilearn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/arthurmensch/nilearn/git/refs{/sha}","trees_url":"https://api.github.com/repos/arthurmensch/nilearn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/arthurmensch/nilearn/statuses/{sha}","languages_url":"https://api.github.com/repos/arthurmensch/nilearn/languages","stargazers_url":"https://api.github.com/repos/arthurmensch/nilearn/stargazers","contributors_url":"https://api.github.com/repos/arthurmensch/nilearn/contributors","subscribers_url":"https://api.github.com/repos/arthurmensch/nilearn/subscribers","subscription_url":"https://api.github.com/repos/arthurmensch/nilearn/subscription","commits_url":"https://api.github.com/repos/arthurmensch/nilearn/commits{/sha}","git_commits_url":"https://api.github.com/repos/arthurmensch/nilearn/git/commits{/sha}","comments_url":"https://api.github.com/repos/arthurmensch/nilearn/comments{/number}","issue_comment_url":"https://api.github.com/repos/arthurmensch/nilearn/issues/comments{/number}","contents_url":"https://api.github.com/repos/arthurmensch/nilearn/contents/{+path}","compare_url":"https://api.github.com/repos/arthurmensch/nilearn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/arthurmensch/nilearn/merges","archive_url":"https://api.github.com/repos/arthurmensch/nilearn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/arthurmensch/nilearn/downloads","issues_url":"https://api.github.com/repos/arthurmensch/nilearn/issues{/number}","pulls_url":"https://api.github.com/repos/arthurmensch/nilearn/pulls{/number}","milestones_url":"https://api.github.com/repos/arthurmensch/nilearn/milestones{/number}","notifications_url":"https://api.github.com/repos/arthurmensch/nilearn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/arthurmensch/nilearn/labels{/name}","releases_url":"https://api.github.com/repos/arthurmensch/nilearn/releases{/id}","created_at":"2015-06-15T07:39:54Z","updated_at":"2015-06-15T07:39:55Z","pushed_at":"2015-11-04T15:41:31Z","git_url":"git://github.com/arthurmensch/nilearn.git","ssh_url":"git@github.com:arthurmensch/nilearn.git","clone_url":"https://github.com/arthurmensch/nilearn.git","svn_url":"https://github.com/arthurmensch/nilearn","homepage":"http://nilearn.github.io","size":9423,"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":"nilearn:master","ref":"master","sha":"43d0006984acfbb1554303da6966efadcfa73920","user":{"login":"nilearn","id":4646912,"avatar_url":"https://avatars.githubusercontent.com/u/4646912?v=3","gravatar_id":"","url":"https://api.github.com/users/nilearn","html_url":"https://github.com/nilearn","followers_url":"https://api.github.com/users/nilearn/followers","following_url":"https://api.github.com/users/nilearn/following{/other_user}","gists_url":"https://api.github.com/users/nilearn/gists{/gist_id}","starred_url":"https://api.github.com/users/nilearn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nilearn/subscriptions","organizations_url":"https://api.github.com/users/nilearn/orgs","repos_url":"https://api.github.com/users/nilearn/repos","events_url":"https://api.github.com/users/nilearn/events{/privacy}","received_events_url":"https://api.github.com/users/nilearn/received_events","type":"Organization","site_admin":false},"repo":{"id":1235740,"name":"nilearn","full_name":"nilearn/nilearn","owner":{"login":"nilearn","id":4646912,"avatar_url":"https://avatars.githubusercontent.com/u/4646912?v=3","gravatar_id":"","url":"https://api.github.com/users/nilearn","html_url":"https://github.com/nilearn","followers_url":"https://api.github.com/users/nilearn/followers","following_url":"https://api.github.com/users/nilearn/following{/other_user}","gists_url":"https://api.github.com/users/nilearn/gists{/gist_id}","starred_url":"https://api.github.com/users/nilearn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nilearn/subscriptions","organizations_url":"https://api.github.com/users/nilearn/orgs","repos_url":"https://api.github.com/users/nilearn/repos","events_url":"https://api.github.com/users/nilearn/events{/privacy}","received_events_url":"https://api.github.com/users/nilearn/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nilearn/nilearn","description":"Machine learning for NeuroImaging in Python","fork":false,"url":"https://api.github.com/repos/nilearn/nilearn","forks_url":"https://api.github.com/repos/nilearn/nilearn/forks","keys_url":"https://api.github.com/repos/nilearn/nilearn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nilearn/nilearn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nilearn/nilearn/teams","hooks_url":"https://api.github.com/repos/nilearn/nilearn/hooks","issue_events_url":"https://api.github.com/repos/nilearn/nilearn/issues/events{/number}","events_url":"https://api.github.com/repos/nilearn/nilearn/events","assignees_url":"https://api.github.com/repos/nilearn/nilearn/assignees{/user}","branches_url":"https://api.github.com/repos/nilearn/nilearn/branches{/branch}","tags_url":"https://api.github.com/repos/nilearn/nilearn/tags","blobs_url":"https://api.github.com/repos/nilearn/nilearn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nilearn/nilearn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nilearn/nilearn/git/refs{/sha}","trees_url":"https://api.github.com/repos/nilearn/nilearn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nilearn/nilearn/statuses/{sha}","languages_url":"https://api.github.com/repos/nilearn/nilearn/languages","stargazers_url":"https://api.github.com/repos/nilearn/nilearn/stargazers","contributors_url":"https://api.github.com/repos/nilearn/nilearn/contributors","subscribers_url":"https://api.github.com/repos/nilearn/nilearn/subscribers","subscription_url":"https://api.github.com/repos/nilearn/nilearn/subscription","commits_url":"https://api.github.com/repos/nilearn/nilearn/commits{/sha}","git_commits_url":"https://api.github.com/repos/nilearn/nilearn/git/commits{/sha}","comments_url":"https://api.github.com/repos/nilearn/nilearn/comments{/number}","issue_comment_url":"https://api.github.com/repos/nilearn/nilearn/issues/comments{/number}","contents_url":"https://api.github.com/repos/nilearn/nilearn/contents/{+path}","compare_url":"https://api.github.com/repos/nilearn/nilearn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nilearn/nilearn/merges","archive_url":"https://api.github.com/repos/nilearn/nilearn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nilearn/nilearn/downloads","issues_url":"https://api.github.com/repos/nilearn/nilearn/issues{/number}","pulls_url":"https://api.github.com/repos/nilearn/nilearn/pulls{/number}","milestones_url":"https://api.github.com/repos/nilearn/nilearn/milestones{/number}","notifications_url":"https://api.github.com/repos/nilearn/nilearn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nilearn/nilearn/labels{/name}","releases_url":"https://api.github.com/repos/nilearn/nilearn/releases{/id}","created_at":"2011-01-09T19:02:23Z","updated_at":"2015-11-01T23:42:20Z","pushed_at":"2015-11-05T22:42:42Z","git_url":"git://github.com/nilearn/nilearn.git","ssh_url":"git@github.com:nilearn/nilearn.git","clone_url":"https://github.com/nilearn/nilearn.git","svn_url":"https://github.com/nilearn/nilearn","homepage":"http://nilearn.github.io","size":14794,"stargazers_count":120,"watchers_count":120,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":87,"mirror_url":null,"open_issues_count":95,"forks":87,"open_issues":95,"watchers":120,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nilearn/nilearn/pulls/693"},"html":{"href":"https://github.com/nilearn/nilearn/pull/693"},"issue":{"href":"https://api.github.com/repos/nilearn/nilearn/issues/693"},"comments":{"href":"https://api.github.com/repos/nilearn/nilearn/issues/693/comments"},"review_comments":{"href":"https://api.github.com/repos/nilearn/nilearn/pulls/693/comments"},"review_comment":{"href":"https://api.github.com/repos/nilearn/nilearn/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nilearn/nilearn/pulls/693/commits"},"statuses":{"href":"https://api.github.com/repos/nilearn/nilearn/statuses/cd3cd7ad781f2865d7876b81f757850a3882a7fa"}}}}