{"action":"created","comment":{"url":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/comments/55992531","id":55992531,"diff_hunk":"@@ -0,0 +1,49 @@\n+=======================\n+Linear Ridge Regression\n+=======================\n+\n+A linear ridge regression model can be defined as :math:`y_i = \\bf{w}^\\top\\bf{x_i}` where :math:`y_i` is the predicted value, :math:`\\bf{x_i}` is a feature vector and :math:`\\bf{w}` is the weight vector. We aim to find the linear function that best explains the data, i.e. minimizes the error or loss function :math:`E(\\bf{w})` by finding appropriate :math:`\\bf{w}`.\n+\n+.. math::\n+    E({\\bf{w}}) = \\sum_{i=1}^N(y_i-{\\bf w}^\\top {\\bf x}_i)^2 + \\tau||{\\bf w}||^2\n+\n+One can show the solution can be written as:\n+\n+.. math::\n+    {\\bf w} = \\left(\\tau {\\bf I}+ \\sum_{i=1}^N{\\bf x}_i{\\bf x}_i^\\top\\right)^{-1}\\left(\\sum_{i=1}^N y_i{\\bf x}_i\\right)\n+\n+where :math:`N` is the number of training samples.\n+\n+A bias term, which is the squared empirical error, can also be calculated.\n+\n+For the special case when :math:`\\tau = 0`, a wrapper class is defined over :sgclass:`CLinearRidgeRegression` called :sgclass:`CLeastSquaresRegression`.\n+\n+-------\n+Example\n+-------\n+\n+Imagine we have files with training and test data. We create `CDenseFeatures` (here 64 bit floats aka RealFeatures) and :sgclass:`CRegressionLabels` as\n+\n+.. sgexample:: linear_ridge_regression.sg:create_features\n+\n+We create an instance of :sgclass:`CLinearRidgeRegression` classifier, passing it training data and labels.","path":"doc/cookbook/source/examples/regression/linear_ridge_regression.rst","position":29,"original_position":29,"commit_id":"cbdbb335010353edc98a37ebc2713fc0bdf00762","original_commit_id":"cbdbb335010353edc98a37ebc2713fc0bdf00762","user":{"login":"karlnapf","id":699071,"avatar_url":"https://avatars.githubusercontent.com/u/699071?v=3","gravatar_id":"","url":"https://api.github.com/users/karlnapf","html_url":"https://github.com/karlnapf","followers_url":"https://api.github.com/users/karlnapf/followers","following_url":"https://api.github.com/users/karlnapf/following{/other_user}","gists_url":"https://api.github.com/users/karlnapf/gists{/gist_id}","starred_url":"https://api.github.com/users/karlnapf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karlnapf/subscriptions","organizations_url":"https://api.github.com/users/karlnapf/orgs","repos_url":"https://api.github.com/users/karlnapf/repos","events_url":"https://api.github.com/users/karlnapf/events{/privacy}","received_events_url":"https://api.github.com/users/karlnapf/received_events","type":"User","site_admin":false},"body":"just mention that you pass \\tau. See knn http://buildbot.shogun-toolbox.org/cookbook_pr/cbdbb335010353edc98a37ebc2713fc0bdf00762/examples/classifier/knn.html","created_at":"2016-03-14T12:28:27Z","updated_at":"2016-03-14T12:28:27Z","html_url":"https://github.com/shogun-toolbox/shogun/pull/3064#discussion_r55992531","pull_request_url":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/3064","_links":{"self":{"href":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/comments/55992531"},"html":{"href":"https://github.com/shogun-toolbox/shogun/pull/3064#discussion_r55992531"},"pull_request":{"href":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/3064"}}},"pull_request":{"url":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/3064","id":62643403,"html_url":"https://github.com/shogun-toolbox/shogun/pull/3064","diff_url":"https://github.com/shogun-toolbox/shogun/pull/3064.diff","patch_url":"https://github.com/shogun-toolbox/shogun/pull/3064.patch","issue_url":"https://api.github.com/repos/shogun-toolbox/shogun/issues/3064","number":3064,"state":"open","locked":false,"title":"add least squares regression cookbook","user":{"login":"sanuj","id":4343847,"avatar_url":"https://avatars.githubusercontent.com/u/4343847?v=3","gravatar_id":"","url":"https://api.github.com/users/sanuj","html_url":"https://github.com/sanuj","followers_url":"https://api.github.com/users/sanuj/followers","following_url":"https://api.github.com/users/sanuj/following{/other_user}","gists_url":"https://api.github.com/users/sanuj/gists{/gist_id}","starred_url":"https://api.github.com/users/sanuj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sanuj/subscriptions","organizations_url":"https://api.github.com/users/sanuj/orgs","repos_url":"https://api.github.com/users/sanuj/repos","events_url":"https://api.github.com/users/sanuj/events{/privacy}","received_events_url":"https://api.github.com/users/sanuj/received_events","type":"User","site_admin":false},"body":"I'm not sure if i should add the shogun-data subproject thing in this commit.\r\n@karlnapf Please review.","created_at":"2016-03-12T15:03:29Z","updated_at":"2016-03-14T12:28:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"baabaf314b3c2d8b4c0d187d70c64d8c92e4b8e1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/3064/commits","review_comments_url":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/3064/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/3064/comments","statuses_url":"https://api.github.com/repos/shogun-toolbox/shogun/statuses/cbdbb335010353edc98a37ebc2713fc0bdf00762","head":{"label":"sanuj:cookbook","ref":"cookbook","sha":"cbdbb335010353edc98a37ebc2713fc0bdf00762","user":{"login":"sanuj","id":4343847,"avatar_url":"https://avatars.githubusercontent.com/u/4343847?v=3","gravatar_id":"","url":"https://api.github.com/users/sanuj","html_url":"https://github.com/sanuj","followers_url":"https://api.github.com/users/sanuj/followers","following_url":"https://api.github.com/users/sanuj/following{/other_user}","gists_url":"https://api.github.com/users/sanuj/gists{/gist_id}","starred_url":"https://api.github.com/users/sanuj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sanuj/subscriptions","organizations_url":"https://api.github.com/users/sanuj/orgs","repos_url":"https://api.github.com/users/sanuj/repos","events_url":"https://api.github.com/users/sanuj/events{/privacy}","received_events_url":"https://api.github.com/users/sanuj/received_events","type":"User","site_admin":false},"repo":{"id":27362302,"name":"shogun","full_name":"sanuj/shogun","owner":{"login":"sanuj","id":4343847,"avatar_url":"https://avatars.githubusercontent.com/u/4343847?v=3","gravatar_id":"","url":"https://api.github.com/users/sanuj","html_url":"https://github.com/sanuj","followers_url":"https://api.github.com/users/sanuj/followers","following_url":"https://api.github.com/users/sanuj/following{/other_user}","gists_url":"https://api.github.com/users/sanuj/gists{/gist_id}","starred_url":"https://api.github.com/users/sanuj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sanuj/subscriptions","organizations_url":"https://api.github.com/users/sanuj/orgs","repos_url":"https://api.github.com/users/sanuj/repos","events_url":"https://api.github.com/users/sanuj/events{/privacy}","received_events_url":"https://api.github.com/users/sanuj/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sanuj/shogun","description":"The Shogun Machine Learning Toolbox (Source Code)","fork":true,"url":"https://api.github.com/repos/sanuj/shogun","forks_url":"https://api.github.com/repos/sanuj/shogun/forks","keys_url":"https://api.github.com/repos/sanuj/shogun/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sanuj/shogun/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sanuj/shogun/teams","hooks_url":"https://api.github.com/repos/sanuj/shogun/hooks","issue_events_url":"https://api.github.com/repos/sanuj/shogun/issues/events{/number}","events_url":"https://api.github.com/repos/sanuj/shogun/events","assignees_url":"https://api.github.com/repos/sanuj/shogun/assignees{/user}","branches_url":"https://api.github.com/repos/sanuj/shogun/branches{/branch}","tags_url":"https://api.github.com/repos/sanuj/shogun/tags","blobs_url":"https://api.github.com/repos/sanuj/shogun/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sanuj/shogun/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sanuj/shogun/git/refs{/sha}","trees_url":"https://api.github.com/repos/sanuj/shogun/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sanuj/shogun/statuses/{sha}","languages_url":"https://api.github.com/repos/sanuj/shogun/languages","stargazers_url":"https://api.github.com/repos/sanuj/shogun/stargazers","contributors_url":"https://api.github.com/repos/sanuj/shogun/contributors","subscribers_url":"https://api.github.com/repos/sanuj/shogun/subscribers","subscription_url":"https://api.github.com/repos/sanuj/shogun/subscription","commits_url":"https://api.github.com/repos/sanuj/shogun/commits{/sha}","git_commits_url":"https://api.github.com/repos/sanuj/shogun/git/commits{/sha}","comments_url":"https://api.github.com/repos/sanuj/shogun/comments{/number}","issue_comment_url":"https://api.github.com/repos/sanuj/shogun/issues/comments{/number}","contents_url":"https://api.github.com/repos/sanuj/shogun/contents/{+path}","compare_url":"https://api.github.com/repos/sanuj/shogun/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sanuj/shogun/merges","archive_url":"https://api.github.com/repos/sanuj/shogun/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sanuj/shogun/downloads","issues_url":"https://api.github.com/repos/sanuj/shogun/issues{/number}","pulls_url":"https://api.github.com/repos/sanuj/shogun/pulls{/number}","milestones_url":"https://api.github.com/repos/sanuj/shogun/milestones{/number}","notifications_url":"https://api.github.com/repos/sanuj/shogun/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sanuj/shogun/labels{/name}","releases_url":"https://api.github.com/repos/sanuj/shogun/releases{/id}","deployments_url":"https://api.github.com/repos/sanuj/shogun/deployments","created_at":"2014-12-01T04:19:55Z","updated_at":"2016-02-21T03:45:13Z","pushed_at":"2016-03-14T08:57:24Z","git_url":"git://github.com/sanuj/shogun.git","ssh_url":"git@github.com:sanuj/shogun.git","clone_url":"https://github.com/sanuj/shogun.git","svn_url":"https://github.com/sanuj/shogun","homepage":"http://www.shogun-toolbox.org","size":58581,"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":"edd688be75ffa2d5a9905c72114264318c7ee0b2","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-03-12T18:38:00Z","pushed_at":"2016-03-14T10:05:52Z","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":180141,"stargazers_count":1001,"watchers_count":1001,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":540,"mirror_url":null,"open_issues_count":407,"forks":540,"open_issues":407,"watchers":1001,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/3064"},"html":{"href":"https://github.com/shogun-toolbox/shogun/pull/3064"},"issue":{"href":"https://api.github.com/repos/shogun-toolbox/shogun/issues/3064"},"comments":{"href":"https://api.github.com/repos/shogun-toolbox/shogun/issues/3064/comments"},"review_comments":{"href":"https://api.github.com/repos/shogun-toolbox/shogun/pulls/3064/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/3064/commits"},"statuses":{"href":"https://api.github.com/repos/shogun-toolbox/shogun/statuses/cbdbb335010353edc98a37ebc2713fc0bdf00762"}}}}