{"action":"created","issue":{"url":"https://api.github.com/repos/topsframework/tops-refactoring/issues/10","labels_url":"https://api.github.com/repos/topsframework/tops-refactoring/issues/10/labels{/name}","comments_url":"https://api.github.com/repos/topsframework/tops-refactoring/issues/10/comments","events_url":"https://api.github.com/repos/topsframework/tops-refactoring/issues/10/events","html_url":"https://github.com/topsframework/tops-refactoring/issues/10","id":86275822,"number":10,"title":"Trainers","user":{"login":"renatocf","id":1621752,"avatar_url":"https://avatars.githubusercontent.com/u/1621752?v=3","gravatar_id":"","url":"https://api.github.com/users/renatocf","html_url":"https://github.com/renatocf","followers_url":"https://api.github.com/users/renatocf/followers","following_url":"https://api.github.com/users/renatocf/following{/other_user}","gists_url":"https://api.github.com/users/renatocf/gists{/gist_id}","starred_url":"https://api.github.com/users/renatocf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/renatocf/subscriptions","organizations_url":"https://api.github.com/users/renatocf/orgs","repos_url":"https://api.github.com/users/renatocf/repos","events_url":"https://api.github.com/users/renatocf/events{/privacy}","received_events_url":"https://api.github.com/users/renatocf/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/topsframework/tops-refactoring/labels/ready","name":"ready","color":"006b75"},{"url":"https://api.github.com/repos/topsframework/tops-refactoring/labels/refactoring","name":"refactoring","color":"0052cc"}],"state":"open","locked":false,"assignee":{"login":"renatocf","id":1621752,"avatar_url":"https://avatars.githubusercontent.com/u/1621752?v=3","gravatar_id":"","url":"https://api.github.com/users/renatocf","html_url":"https://github.com/renatocf","followers_url":"https://api.github.com/users/renatocf/followers","following_url":"https://api.github.com/users/renatocf/following{/other_user}","gists_url":"https://api.github.com/users/renatocf/gists{/gist_id}","starred_url":"https://api.github.com/users/renatocf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/renatocf/subscriptions","organizations_url":"https://api.github.com/users/renatocf/orgs","repos_url":"https://api.github.com/users/renatocf/repos","events_url":"https://api.github.com/users/renatocf/events{/privacy}","received_events_url":"https://api.github.com/users/renatocf/received_events","type":"User","site_admin":false},"milestone":null,"comments":8,"created_at":"2015-06-08T18:06:26Z","updated_at":"2015-08-12T00:14:25Z","closed_at":null,"body":"New front-end for training algorithms, which act as a builder (GoF design pattern) of probabilistic models."},"comment":{"url":"https://api.github.com/repos/topsframework/tops-refactoring/issues/comments/130117584","html_url":"https://github.com/topsframework/tops-refactoring/issues/10#issuecomment-130117584","issue_url":"https://api.github.com/repos/topsframework/tops-refactoring/issues/10","id":130117584,"user":{"login":"renatocf","id":1621752,"avatar_url":"https://avatars.githubusercontent.com/u/1621752?v=3","gravatar_id":"","url":"https://api.github.com/users/renatocf","html_url":"https://github.com/renatocf","followers_url":"https://api.github.com/users/renatocf/followers","following_url":"https://api.github.com/users/renatocf/following{/other_user}","gists_url":"https://api.github.com/users/renatocf/gists{/gist_id}","starred_url":"https://api.github.com/users/renatocf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/renatocf/subscriptions","organizations_url":"https://api.github.com/users/renatocf/orgs","repos_url":"https://api.github.com/users/renatocf/repos","events_url":"https://api.github.com/users/renatocf/events{/privacy}","received_events_url":"https://api.github.com/users/renatocf/received_events","type":"User","site_admin":false},"created_at":"2015-08-12T00:14:25Z","updated_at":"2015-08-12T00:14:25Z","body":"@igorbonadio,\r\n\r\nTo formalize and publicly document our idea:\r\n\r\n`Trainer` is a front-end that can be of two kinds: \"fixed\", whose parameters are set in its construction, through a previously created model; and \"plain\" (the best name I could think), whose parameters are estimated from its data. The `Trainer` interface will have an `add_training_set` method (to act as a [Builder](https://en.wikipedia.org/wiki/Builder_pattern)) and a `train` method, whose first parameter will be an enum of training algorithms.\r\n\r\nAt the same time, we identified that a `Trainer` can be a `Trainer` for sequences or labels (as `Generator` and `Estimator`).\r\n\r\nThis way, we will have 4 different methods to create trainers:\r\n\r\n|                  |            Sequence             |             Labeling            |\r\n| ------------- | ------------------------------- | ------------------------------|\r\n| **Fixed**    | sequence_fixed_trainer() | labeling_fixed_trainer() |\r\n| **Plain**    | sequence_plain_trainer() | labeling_fixed_trainer() |\r\n\r\nWith the following usage:\r\n\r\n```c++\r\n/* Creating and training an iid */\r\nauto iid_t = IID::sequenceFixedTrainer();\r\niid_t->addTrainingSet(dataset);\r\nmodel = iid_t->train(IID::sequence_training_algorithm::Burge);\r\n\r\n/* Two types of trainers: fixed and plain */\r\nauto iid_trainer_obs = IID::sequenceFixedTrainer(iid_t); /* return fixed trainer */\r\nauto iid_trainer_dur = IID::sequencePlainTrainer();      /* return plain trainer */\r\n\r\n/* An example of observation and label */\r\nauto lab = Sequence{ 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1 };\r\nauto obs = Sequence { 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1 };\r\n\r\n/* Creating and training a HMM */\r\nauto hmm_sequence_trainer = GHMM::sequencePlainTrainer { state1, state2, ... };\r\nhmm_sequence_trainer->add_training_set(obs);\r\nauto hmm1 = hmm_sequence_trainer->train(GHMM::sequence_training_algorithm::BaumWelch);\r\n\r\nauto hmm_labeling_trainer = GHMM::labelingPlainTrainer { state1, state2, ... };\r\nhmm_labeling_trainer->add_training_set(Labeling<Sequence>(obs, lab));\r\nauto hmm2 = hmm_labeling_trainer->train(GHMM::labeling_training_algorithm::MaximumLikehood);\r\n\r\n/* Creating and training a GHMM */\r\nauto ghmm_labeling_trainer = GHMM::labelingPlainTrainer { state1, state2, ... };\r\nghmm_labeling_trainer->add_training_set(Labeling<Sequence>(obs, lab));\r\nauto ghmm = ghmm_labeling_trainer->train(GHMM::labeling_training_algorithm::MaximumLikehood);\r\n```\r\n\r\nI'm not sure if I like this design, but I could not come up with anything better for now. `Evaluator`s have a simple / cached version, and we decide which one to return through a boolean parameter in their creator methods. This can be done because `SimpleEvaluator` and `CachedEvaluator` have the same constructor parameters. However, `PlainTrainer` and `FixedTrainer` would have different constructors, wouldn't they? The first would have no parameters and the second would accept a model. Do you believe we could mix them in a way they behave like `Evaluator`s?\r\n\r\nIf we agree with a good final design, I'll try to implement it in tops-architecture to create the structure and then put it here."}}