{"action":"created","comment":{"url":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/comments/65110210","id":65110210,"diff_hunk":"@@ -0,0 +1,128 @@\n+\n+/*\n+ * Copyright (c) The Shogun Machine Learning Toolbox\n+ * Written (W) 2016 Fredrik Hallgren\n+ * All rights reserved.\n+ *\n+ * Redistribution and use in source and binary forms, with or without\n+ * modification, are permitted provided that the following conditions are met:\n+ *\n+ * 1. Redistributions of source code must retain the above copyright notice, this\n+ *    list of conditions and the following disclaimer.\n+ * 2. Redistributions in binary form must reproduce the above copyright notice,\n+ *    this list of conditions and the following disclaimer in the documentation\n+ *    and/or other materials provided with the distribution.\n+ *\n+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ *\n+ * The views and conclusions contained in the software and documentation are those\n+ * of the authors and should not be interpreted as representing official policies,\n+ * either expressed or implied, of the Shogun Development Team.\n+ */\n+\n+#include <cfloat>\n+#include <shogun/regression/KRRNystrom.h>\n+#include <shogun/labels/RegressionLabels.h>\n+#include <shogun/mathematics/eigen3.h>\n+#include <shogun/mathematics/Math.h>\n+\n+using namespace shogun;\n+using namespace Eigen;\n+\n+CKRRNystrom::CKRRNystrom() : CKernelRidgeRegression()\n+{\n+\tinit();\n+}\n+\n+CKRRNystrom::CKRRNystrom(float64_t tau, int32_t m, CKernel* k, CLabels* lab)\n+: CKernelRidgeRegression(tau, k, lab)\n+{\n+\tinit();\n+\n+\tm_num_rkhs_basis=m;\n+}\n+\n+void CKRRNystrom::init()\n+{\n+\tm_num_rkhs_basis=1000;\n+}\n+\n+SGVector<int32_t> CKRRNystrom::subsample_indices()\n+{\n+\tint32_t n=kernel->get_num_vec_lhs();\n+\tSGVector<int32_t> temp(n);\n+\ttemp.range_fill();\n+\tCMath::permute(temp);\n+\tSGVector<int32_t> col(m_num_rkhs_basis);\n+\tfor (auto i=0; i<m_num_rkhs_basis; ++i)\n+\t\tcol[i]=temp[i];\n+\tCMath::qsort(col.vector, m_num_rkhs_basis);\n+\n+\treturn col;\n+}\n+\n+bool CKRRNystrom::solve_krr_system()\n+{\n+\tint32_t n=kernel->get_num_vec_lhs();\n+\n+\tREQUIRE(m_num_rkhs_basis <= n, \"Number of sampled rows/columns must be less than total\\n\");\n+\n+\tSGVector<float64_t> y=((CRegressionLabels*)m_labels)->get_labels();\n+\tSGVector<int32_t> col=subsample_indices();\n+\tSGMatrix<float64_t> K_mm(m_num_rkhs_basis, m_num_rkhs_basis);\n+\tSGMatrix<float64_t> K_nm(n, m_num_rkhs_basis);\n+\tfor (index_t i=0; i<m_num_rkhs_basis; ++i)\n+\t{\n+\t\tfor (index_t j=0; j<m_num_rkhs_basis; ++j)\n+\t\t\tK_mm(i,j)=kernel->kernel(col[i],col[j]);\n+\t\tfor (index_t j=0; j<n; ++j)","path":"src/shogun/regression/KRRNystrom.cpp","position":87,"original_position":87,"commit_id":"7961325e5289fb6fe7f7977d73e3cfde9b0e2f9f","original_commit_id":"7961325e5289fb6fe7f7977d73e3cfde9b0e2f9f","user":{"login":"cfjhallgren","id":3390580,"avatar_url":"https://avatars.githubusercontent.com/u/3390580?v=3","gravatar_id":"","url":"https://api.github.com/users/cfjhallgren","html_url":"https://github.com/cfjhallgren","followers_url":"https://api.github.com/users/cfjhallgren/followers","following_url":"https://api.github.com/users/cfjhallgren/following{/other_user}","gists_url":"https://api.github.com/users/cfjhallgren/gists{/gist_id}","starred_url":"https://api.github.com/users/cfjhallgren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cfjhallgren/subscriptions","organizations_url":"https://api.github.com/users/cfjhallgren/orgs","repos_url":"https://api.github.com/users/cfjhallgren/repos","events_url":"https://api.github.com/users/cfjhallgren/events{/privacy}","received_events_url":"https://api.github.com/users/cfjhallgren/received_events","type":"User","site_admin":false},"body":"Cool","created_at":"2016-05-30T23:16:02Z","updated_at":"2016-05-30T23:16:02Z","html_url":"https://github.com/shogun-toolbox/shogun/pull/3172#discussion_r65110210","pull_request_url":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/3172","_links":{"self":{"href":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/comments/65110210"},"html":{"href":"https://github.com/shogun-toolbox/shogun/pull/3172#discussion_r65110210"},"pull_request":{"href":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/3172"}}},"pull_request":{"url":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/3172","id":66770366,"html_url":"https://github.com/shogun-toolbox/shogun/pull/3172","diff_url":"https://github.com/shogun-toolbox/shogun/pull/3172.diff","patch_url":"https://github.com/shogun-toolbox/shogun/pull/3172.patch","issue_url":"https://api.github.com/repos/shogun-toolbox/shogun/issues/3172","number":3172,"state":"open","locked":false,"title":"Implement the Nystrom approximate algorithm for KRR","user":{"login":"cfjhallgren","id":3390580,"avatar_url":"https://avatars.githubusercontent.com/u/3390580?v=3","gravatar_id":"","url":"https://api.github.com/users/cfjhallgren","html_url":"https://github.com/cfjhallgren","followers_url":"https://api.github.com/users/cfjhallgren/followers","following_url":"https://api.github.com/users/cfjhallgren/following{/other_user}","gists_url":"https://api.github.com/users/cfjhallgren/gists{/gist_id}","starred_url":"https://api.github.com/users/cfjhallgren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cfjhallgren/subscriptions","organizations_url":"https://api.github.com/users/cfjhallgren/orgs","repos_url":"https://api.github.com/users/cfjhallgren/repos","events_url":"https://api.github.com/users/cfjhallgren/events{/privacy}","received_events_url":"https://api.github.com/users/cfjhallgren/received_events","type":"User","site_admin":false},"body":"Hey here is my PR.\r\n\r\n#TODO's in the code should be attended to or removed.\r\n\r\nAdded a normal example in the meantime.\r\n","created_at":"2016-04-17T14:47:38Z","updated_at":"2016-05-30T23:16:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"120b2c5d3fb11e913b2b847c0d556297617bd5e0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/3172/commits","review_comments_url":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/3172/comments","review_comment_url":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/comments{/number}","comments_url":"https://api.github.com/repos/shogun-toolbox/shogun/issues/3172/comments","statuses_url":"https://api.github.com/repos/shogun-toolbox/shogun/statuses/7961325e5289fb6fe7f7977d73e3cfde9b0e2f9f","head":{"label":"cfjhallgren:nystrom_krr","ref":"nystrom_krr","sha":"7961325e5289fb6fe7f7977d73e3cfde9b0e2f9f","user":{"login":"cfjhallgren","id":3390580,"avatar_url":"https://avatars.githubusercontent.com/u/3390580?v=3","gravatar_id":"","url":"https://api.github.com/users/cfjhallgren","html_url":"https://github.com/cfjhallgren","followers_url":"https://api.github.com/users/cfjhallgren/followers","following_url":"https://api.github.com/users/cfjhallgren/following{/other_user}","gists_url":"https://api.github.com/users/cfjhallgren/gists{/gist_id}","starred_url":"https://api.github.com/users/cfjhallgren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cfjhallgren/subscriptions","organizations_url":"https://api.github.com/users/cfjhallgren/orgs","repos_url":"https://api.github.com/users/cfjhallgren/repos","events_url":"https://api.github.com/users/cfjhallgren/events{/privacy}","received_events_url":"https://api.github.com/users/cfjhallgren/received_events","type":"User","site_admin":false},"repo":{"id":53218981,"name":"shogun","full_name":"cfjhallgren/shogun","owner":{"login":"cfjhallgren","id":3390580,"avatar_url":"https://avatars.githubusercontent.com/u/3390580?v=3","gravatar_id":"","url":"https://api.github.com/users/cfjhallgren","html_url":"https://github.com/cfjhallgren","followers_url":"https://api.github.com/users/cfjhallgren/followers","following_url":"https://api.github.com/users/cfjhallgren/following{/other_user}","gists_url":"https://api.github.com/users/cfjhallgren/gists{/gist_id}","starred_url":"https://api.github.com/users/cfjhallgren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cfjhallgren/subscriptions","organizations_url":"https://api.github.com/users/cfjhallgren/orgs","repos_url":"https://api.github.com/users/cfjhallgren/repos","events_url":"https://api.github.com/users/cfjhallgren/events{/privacy}","received_events_url":"https://api.github.com/users/cfjhallgren/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cfjhallgren/shogun","description":"The Shogun Machine Learning Toolbox (Source Code)","fork":true,"url":"https://api.github.com/repos/cfjhallgren/shogun","forks_url":"https://api.github.com/repos/cfjhallgren/shogun/forks","keys_url":"https://api.github.com/repos/cfjhallgren/shogun/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cfjhallgren/shogun/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cfjhallgren/shogun/teams","hooks_url":"https://api.github.com/repos/cfjhallgren/shogun/hooks","issue_events_url":"https://api.github.com/repos/cfjhallgren/shogun/issues/events{/number}","events_url":"https://api.github.com/repos/cfjhallgren/shogun/events","assignees_url":"https://api.github.com/repos/cfjhallgren/shogun/assignees{/user}","branches_url":"https://api.github.com/repos/cfjhallgren/shogun/branches{/branch}","tags_url":"https://api.github.com/repos/cfjhallgren/shogun/tags","blobs_url":"https://api.github.com/repos/cfjhallgren/shogun/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cfjhallgren/shogun/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cfjhallgren/shogun/git/refs{/sha}","trees_url":"https://api.github.com/repos/cfjhallgren/shogun/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cfjhallgren/shogun/statuses/{sha}","languages_url":"https://api.github.com/repos/cfjhallgren/shogun/languages","stargazers_url":"https://api.github.com/repos/cfjhallgren/shogun/stargazers","contributors_url":"https://api.github.com/repos/cfjhallgren/shogun/contributors","subscribers_url":"https://api.github.com/repos/cfjhallgren/shogun/subscribers","subscription_url":"https://api.github.com/repos/cfjhallgren/shogun/subscription","commits_url":"https://api.github.com/repos/cfjhallgren/shogun/commits{/sha}","git_commits_url":"https://api.github.com/repos/cfjhallgren/shogun/git/commits{/sha}","comments_url":"https://api.github.com/repos/cfjhallgren/shogun/comments{/number}","issue_comment_url":"https://api.github.com/repos/cfjhallgren/shogun/issues/comments{/number}","contents_url":"https://api.github.com/repos/cfjhallgren/shogun/contents/{+path}","compare_url":"https://api.github.com/repos/cfjhallgren/shogun/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cfjhallgren/shogun/merges","archive_url":"https://api.github.com/repos/cfjhallgren/shogun/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cfjhallgren/shogun/downloads","issues_url":"https://api.github.com/repos/cfjhallgren/shogun/issues{/number}","pulls_url":"https://api.github.com/repos/cfjhallgren/shogun/pulls{/number}","milestones_url":"https://api.github.com/repos/cfjhallgren/shogun/milestones{/number}","notifications_url":"https://api.github.com/repos/cfjhallgren/shogun/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cfjhallgren/shogun/labels{/name}","releases_url":"https://api.github.com/repos/cfjhallgren/shogun/releases{/id}","deployments_url":"https://api.github.com/repos/cfjhallgren/shogun/deployments","created_at":"2016-03-05T19:23:07Z","updated_at":"2016-03-05T19:23:15Z","pushed_at":"2016-05-29T13:44:07Z","git_url":"git://github.com/cfjhallgren/shogun.git","ssh_url":"git@github.com:cfjhallgren/shogun.git","clone_url":"https://github.com/cfjhallgren/shogun.git","svn_url":"https://github.com/cfjhallgren/shogun","homepage":"http://www.shogun-toolbox.org","size":59660,"stargazers_count":0,"watchers_count":0,"language":"C++","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":"develop"}},"base":{"label":"shogun-toolbox:develop","ref":"develop","sha":"f1e2e7f3fd80a845e5931526eda2b0e95cc94cca","user":{"login":"shogun-toolbox","id":690673,"avatar_url":"https://avatars.githubusercontent.com/u/690673?v=3","gravatar_id":"","url":"https://api.github.com/users/shogun-toolbox","html_url":"https://github.com/shogun-toolbox","followers_url":"https://api.github.com/users/shogun-toolbox/followers","following_url":"https://api.github.com/users/shogun-toolbox/following{/other_user}","gists_url":"https://api.github.com/users/shogun-toolbox/gists{/gist_id}","starred_url":"https://api.github.com/users/shogun-toolbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shogun-toolbox/subscriptions","organizations_url":"https://api.github.com/users/shogun-toolbox/orgs","repos_url":"https://api.github.com/users/shogun-toolbox/repos","events_url":"https://api.github.com/users/shogun-toolbox/events{/privacy}","received_events_url":"https://api.github.com/users/shogun-toolbox/received_events","type":"Organization","site_admin":false},"repo":{"id":1555094,"name":"shogun","full_name":"shogun-toolbox/shogun","owner":{"login":"shogun-toolbox","id":690673,"avatar_url":"https://avatars.githubusercontent.com/u/690673?v=3","gravatar_id":"","url":"https://api.github.com/users/shogun-toolbox","html_url":"https://github.com/shogun-toolbox","followers_url":"https://api.github.com/users/shogun-toolbox/followers","following_url":"https://api.github.com/users/shogun-toolbox/following{/other_user}","gists_url":"https://api.github.com/users/shogun-toolbox/gists{/gist_id}","starred_url":"https://api.github.com/users/shogun-toolbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shogun-toolbox/subscriptions","organizations_url":"https://api.github.com/users/shogun-toolbox/orgs","repos_url":"https://api.github.com/users/shogun-toolbox/repos","events_url":"https://api.github.com/users/shogun-toolbox/events{/privacy}","received_events_url":"https://api.github.com/users/shogun-toolbox/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/shogun-toolbox/shogun","description":"The Shogun Machine Learning Toolbox (Source Code)","fork":false,"url":"https://api.github.com/repos/shogun-toolbox/shogun","forks_url":"https://api.github.com/repos/shogun-toolbox/shogun/forks","keys_url":"https://api.github.com/repos/shogun-toolbox/shogun/keys{/key_id}","collaborators_url":"https://api.github.com/repos/shogun-toolbox/shogun/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/shogun-toolbox/shogun/teams","hooks_url":"https://api.github.com/repos/shogun-toolbox/shogun/hooks","issue_events_url":"https://api.github.com/repos/shogun-toolbox/shogun/issues/events{/number}","events_url":"https://api.github.com/repos/shogun-toolbox/shogun/events","assignees_url":"https://api.github.com/repos/shogun-toolbox/shogun/assignees{/user}","branches_url":"https://api.github.com/repos/shogun-toolbox/shogun/branches{/branch}","tags_url":"https://api.github.com/repos/shogun-toolbox/shogun/tags","blobs_url":"https://api.github.com/repos/shogun-toolbox/shogun/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/shogun-toolbox/shogun/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/shogun-toolbox/shogun/git/refs{/sha}","trees_url":"https://api.github.com/repos/shogun-toolbox/shogun/git/trees{/sha}","statuses_url":"https://api.github.com/repos/shogun-toolbox/shogun/statuses/{sha}","languages_url":"https://api.github.com/repos/shogun-toolbox/shogun/languages","stargazers_url":"https://api.github.com/repos/shogun-toolbox/shogun/stargazers","contributors_url":"https://api.github.com/repos/shogun-toolbox/shogun/contributors","subscribers_url":"https://api.github.com/repos/shogun-toolbox/shogun/subscribers","subscription_url":"https://api.github.com/repos/shogun-toolbox/shogun/subscription","commits_url":"https://api.github.com/repos/shogun-toolbox/shogun/commits{/sha}","git_commits_url":"https://api.github.com/repos/shogun-toolbox/shogun/git/commits{/sha}","comments_url":"https://api.github.com/repos/shogun-toolbox/shogun/comments{/number}","issue_comment_url":"https://api.github.com/repos/shogun-toolbox/shogun/issues/comments{/number}","contents_url":"https://api.github.com/repos/shogun-toolbox/shogun/contents/{+path}","compare_url":"https://api.github.com/repos/shogun-toolbox/shogun/compare/{base}...{head}","merges_url":"https://api.github.com/repos/shogun-toolbox/shogun/merges","archive_url":"https://api.github.com/repos/shogun-toolbox/shogun/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/shogun-toolbox/shogun/downloads","issues_url":"https://api.github.com/repos/shogun-toolbox/shogun/issues{/number}","pulls_url":"https://api.github.com/repos/shogun-toolbox/shogun/pulls{/number}","milestones_url":"https://api.github.com/repos/shogun-toolbox/shogun/milestones{/number}","notifications_url":"https://api.github.com/repos/shogun-toolbox/shogun/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/shogun-toolbox/shogun/labels{/name}","releases_url":"https://api.github.com/repos/shogun-toolbox/shogun/releases{/id}","deployments_url":"https://api.github.com/repos/shogun-toolbox/shogun/deployments","created_at":"2011-04-01T10:44:32Z","updated_at":"2016-05-30T20:32:33Z","pushed_at":"2016-05-30T23:12:56Z","git_url":"git://github.com/shogun-toolbox/shogun.git","ssh_url":"git@github.com:shogun-toolbox/shogun.git","clone_url":"https://github.com/shogun-toolbox/shogun.git","svn_url":"https://github.com/shogun-toolbox/shogun","homepage":"http://www.shogun-toolbox.org","size":192497,"stargazers_count":1073,"watchers_count":1073,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":583,"mirror_url":null,"open_issues_count":427,"forks":583,"open_issues":427,"watchers":1073,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/3172"},"html":{"href":"https://github.com/shogun-toolbox/shogun/pull/3172"},"issue":{"href":"https://api.github.com/repos/shogun-toolbox/shogun/issues/3172"},"comments":{"href":"https://api.github.com/repos/shogun-toolbox/shogun/issues/3172/comments"},"review_comments":{"href":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/3172/comments"},"review_comment":{"href":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/3172/commits"},"statuses":{"href":"https://api.github.com/repos/shogun-toolbox/shogun/statuses/7961325e5289fb6fe7f7977d73e3cfde9b0e2f9f"}}}}
{"actor":{"display_login":"cfjhallgren"}}