{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaML/Losses.jl/issues/27","repository_url":"https://api.github.com/repos/JuliaML/Losses.jl","labels_url":"https://api.github.com/repos/JuliaML/Losses.jl/issues/27/labels{/name}","comments_url":"https://api.github.com/repos/JuliaML/Losses.jl/issues/27/comments","events_url":"https://api.github.com/repos/JuliaML/Losses.jl/issues/27/events","html_url":"https://github.com/JuliaML/Losses.jl/issues/27","id":169031208,"number":27,"title":"Adding scale parameter to losses","user":{"login":"ahwillia","id":636625,"avatar_url":"https://avatars.githubusercontent.com/u/636625?v=3","gravatar_id":"","url":"https://api.github.com/users/ahwillia","html_url":"https://github.com/ahwillia","followers_url":"https://api.github.com/users/ahwillia/followers","following_url":"https://api.github.com/users/ahwillia/following{/other_user}","gists_url":"https://api.github.com/users/ahwillia/gists{/gist_id}","starred_url":"https://api.github.com/users/ahwillia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahwillia/subscriptions","organizations_url":"https://api.github.com/users/ahwillia/orgs","repos_url":"https://api.github.com/users/ahwillia/repos","events_url":"https://api.github.com/users/ahwillia/events{/privacy}","received_events_url":"https://api.github.com/users/ahwillia/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":31,"created_at":"2016-08-03T02:08:40Z","updated_at":"2016-08-03T18:06:39Z","closed_at":null,"body":"Suppose I'm working on a dataset with `n` observations of `p` measured features. For simplicity let's say all measurements are real-valued and I want to use `L2DistLoss`. However, each feature has a difference variance, which could happen for a variety of reasons.\r\n\r\nAs a result, I want to scale the loss of each feature so that errors in the noisier features are penalized less. For example, if `p = 2` I might calculate the full objective function like this:\r\n\r\n```julia\r\nfor n = 1:nobs\r\n    # penalty for first feature with scale 1.0\r\n    objective += 1.0*value(L2DistLoss(), actual[n,1] - prediction[n,1])\r\n    # penalty for second feature with scale 2.0\r\n    objective += 2.0*value(L2DistLoss(), actual[n,2]  - prediction[n,2])\r\nend\r\n```\r\n\r\nMy question is whether it would be useful to define a new type called something like `ScaledLoss` so that the calculation becomes:\r\n\r\n```julia\r\nfor n = 1:nobs\r\n    # penalty for first feature with scale 1.0\r\n    objective += value(ScaledLoss{L2DistLoss,1.0}(), actual[n,1] - prediction[n,1])\r\n    # penalty for second feature with scale 2.0\r\n    objective += value(ScaledLoss{L2DistLoss,2.0}(), actual[n,2]  - prediction[n,2])\r\nend\r\n```\r\n\r\nThe advantage being that this scaling can be passed through when calculating gradients, etc.\r\n\r\n**Note:**  these loops are really just for demonstration. I wouldn't actually calculate the objective this way, but I think it illustrates the point."},"comment":{"url":"https://api.github.com/repos/JuliaML/Losses.jl/issues/comments/237319399","html_url":"https://github.com/JuliaML/Losses.jl/issues/27#issuecomment-237319399","issue_url":"https://api.github.com/repos/JuliaML/Losses.jl/issues/27","id":237319399,"user":{"login":"Evizero","id":10854026,"avatar_url":"https://avatars.githubusercontent.com/u/10854026?v=3","gravatar_id":"","url":"https://api.github.com/users/Evizero","html_url":"https://github.com/Evizero","followers_url":"https://api.github.com/users/Evizero/followers","following_url":"https://api.github.com/users/Evizero/following{/other_user}","gists_url":"https://api.github.com/users/Evizero/gists{/gist_id}","starred_url":"https://api.github.com/users/Evizero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Evizero/subscriptions","organizations_url":"https://api.github.com/users/Evizero/orgs","repos_url":"https://api.github.com/users/Evizero/repos","events_url":"https://api.github.com/users/Evizero/events{/privacy}","received_events_url":"https://api.github.com/users/Evizero/received_events","type":"User","site_admin":false},"created_at":"2016-08-03T18:06:39Z","updated_at":"2016-08-03T18:06:39Z","body":"I just looked at `sumvalue` and `meanvalue` a little closer. They seriously need some revision concerning type stability *note_to_self*."}}
{"actor":{"display_login":"Evizero"}}