{"action":"created","issue":{"url":"https://api.github.com/repos/mlr-org/mlr3pipelines/issues/12","repository_url":"https://api.github.com/repos/mlr-org/mlr3pipelines","labels_url":"https://api.github.com/repos/mlr-org/mlr3pipelines/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/mlr-org/mlr3pipelines/issues/12/comments","events_url":"https://api.github.com/repos/mlr-org/mlr3pipelines/issues/12/events","html_url":"https://github.com/mlr-org/mlr3pipelines/issues/12","id":375003807,"node_id":"MDU6SXNzdWUzNzUwMDM4MDc=","number":12,"title":"Use case: Bagging","user":{"login":"zzawadz","id":3474533,"node_id":"MDQ6VXNlcjM0NzQ1MzM=","avatar_url":"https://avatars2.githubusercontent.com/u/3474533?v=4","gravatar_id":"","url":"https://api.github.com/users/zzawadz","html_url":"https://github.com/zzawadz","followers_url":"https://api.github.com/users/zzawadz/followers","following_url":"https://api.github.com/users/zzawadz/following{/other_user}","gists_url":"https://api.github.com/users/zzawadz/gists{/gist_id}","starred_url":"https://api.github.com/users/zzawadz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zzawadz/subscriptions","organizations_url":"https://api.github.com/users/zzawadz/orgs","repos_url":"https://api.github.com/users/zzawadz/repos","events_url":"https://api.github.com/users/zzawadz/events{/privacy}","received_events_url":"https://api.github.com/users/zzawadz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-10-29T13:00:46Z","updated_at":"2018-11-14T11:07:23Z","closed_at":null,"author_association":"MEMBER","body":"------------------------------------------------------------------------------------------\r\n### Use case: Bagging\r\n------------------------------------------------------------------------------------------\r\n```\r\nk = 100\r\nop1 = PipeOpNULL$new()\r\nop2 = PipeOpDownSample$new(rate = 0.6)\r\nops2 = repop(k, op2) # Auto-set Ids? # replicate with s3?\r\nop3 = PipeOpLearner$new(\"classif.rpart\")\r\nops3 = repop(k, op3)\r\nop4 = PipeOpEnsembleAverage$new() # der muss halt wissen dass nur vorher learner nimmt als input\r\n\r\ng1 = GraphNode$new(op1)\r\ngs2 = lapply(ops2, GraphNode$new)\r\ngs3 = lapply(ops3, GraphNode$new)\r\n\r\ng1$set_next(gs2)\r\nfor (i in 1:k)\r\n  gs2[[i]]$set_next(gs3[[i]])\r\ng4$set_prev(gs3)\r\n```\r\n\r\n### can we write the above in a shorter, better way?\r\n\r\n```\r\nop1 = PipeOpNULL$new()\r\nop2 = PipeOpDownSample$new(rate = 0.6)\r\nop3 = PipeOpLearner$new(\"classif.rpart\")\r\nop4 = PipeOpEnsembleAverage$new()\r\n\r\nPipeline$new(list(op1, rep(k, op2), rep(k, op3), op4))\r\n```\r\n\r\n## My comments:\r\n\r\n\r\nI think this is a very important stuff for the whole project. I bet that making bagging easy to define using the pipeline will make the whole functionality easy to use.\r\n\r\nLet's start with `Pipeline$new(list(op1, rep(k, op2), rep(k, op3), op4))`. I think it would be better to rephrase this as:\r\n\r\n```\r\np1 <- Pipeline$new(list(op2, op3))\r\nPipeline$new(list(op1, rep(k, p1), op4))\r\n\r\n# or using some sugar\r\nop1 %>>% rep(k, op2 %>>% op3) %>>% op4\r\n```\r\nIt might be a bit easier to reason about because we know which part will be replicated, and we don't need to worry about the sizes of op2 and op3.\r\n\r\n```\r\n     B1->C1 \\\r\nA -> B2->C2 -> D\r\n     B3->C3 /\r\n```\r\n\r\nProbably we need to define what happens when the Node has multiple predecessors. For me, the most natural way is to bind their results together and send them to the next node (but what happens when one of the previous nodes returns SparseMatrix and the second data.frame? I don't know now).\r\n\r\nSo\r\n```\r\nA \\\r\nB --> D\r\nC /\r\n```\r\n\r\nSo in that case, `D` gets all the results from all previous nodes.\r\n\r\nThe more interesting problem is when there are multiple successors.\r\n\r\n```\r\nA \\   X\r\nB --> Y\r\nC /   Z\r\n```\r\n\r\nProbably the easiest solution is that each node `X, Y, Z` gets as input all results from previous nodes. So when the nodes lists of nodes will be concatenated it will set all the nodes from the first list as predecessors of the nodes from the second list.\r\n\r\nProbably the method name `set_prev` should be renamed to `add_prev`, because each node will be able to have multiple predecessors.\r\n\r\nSo we can rephrase the previous example in the pseudo code as a:\r\n\r\n```\r\np1 <- list(A, B, C)\r\np2 <- list(X, Y, Z)\r\nop3 <- ...\r\n\r\nPipeline$new(list(p1, p2, op3))\r\n## It will cause to call the\r\nX$add_prev(A); X$add_prev(B); X$add_prev(C)\r\nY$add_prev(A); Y$add_prev(B); Y$add_prev(C)\r\nZ$add_prev(A); Z$add_prev(B); Z$add_prev(C)\r\n... operations for op3\r\n\r\n# when the size of p1 is not equal to p2\r\n# it works the same way\r\np1 <- list(A, B, C)\r\np2 <- list(X, Y)\r\nop3 <- ...\r\n\r\nPipeline$new(list(p1, p2, op3))\r\nX$add_prev(A); X$add_prev(B); X$add_prev(C)\r\nY$add_prev(A); Y$add_prev(B); Y$add_prev(C)\r\n... operations for op3\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/mlr-org/mlr3pipelines/issues/comments/438625259","html_url":"https://github.com/mlr-org/mlr3pipelines/issues/12#issuecomment-438625259","issue_url":"https://api.github.com/repos/mlr-org/mlr3pipelines/issues/12","id":438625259,"node_id":"MDEyOklzc3VlQ29tbWVudDQzODYyNTI1OQ==","user":{"login":"berndbischl","id":1225974,"node_id":"MDQ6VXNlcjEyMjU5NzQ=","avatar_url":"https://avatars3.githubusercontent.com/u/1225974?v=4","gravatar_id":"","url":"https://api.github.com/users/berndbischl","html_url":"https://github.com/berndbischl","followers_url":"https://api.github.com/users/berndbischl/followers","following_url":"https://api.github.com/users/berndbischl/following{/other_user}","gists_url":"https://api.github.com/users/berndbischl/gists{/gist_id}","starred_url":"https://api.github.com/users/berndbischl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/berndbischl/subscriptions","organizations_url":"https://api.github.com/users/berndbischl/orgs","repos_url":"https://api.github.com/users/berndbischl/repos","events_url":"https://api.github.com/users/berndbischl/events{/privacy}","received_events_url":"https://api.github.com/users/berndbischl/received_events","type":"User","site_admin":false},"created_at":"2018-11-14T11:07:23Z","updated_at":"2018-11-14T11:07:23Z","author_association":"CONTRIBUTOR","body":"Zygmunt to what piece of pseudo code are you referring to exactly? I do not see a problem with my initial suggestion\r\n? And there we had a downsample operator not a resample operator... M"}}
{"actor":{"display_login":"berndbischl"}}