{"action":"created","issue":{"url":"https://api.github.com/repos/dfdx/NaiveBayes.jl/issues/9","repository_url":"https://api.github.com/repos/dfdx/NaiveBayes.jl","labels_url":"https://api.github.com/repos/dfdx/NaiveBayes.jl/issues/9/labels{/name}","comments_url":"https://api.github.com/repos/dfdx/NaiveBayes.jl/issues/9/comments","events_url":"https://api.github.com/repos/dfdx/NaiveBayes.jl/issues/9/events","html_url":"https://github.com/dfdx/NaiveBayes.jl/issues/9","id":164774477,"number":9,"title":"Improve NB model creation","user":{"login":"JoshChristie","id":7004868,"avatar_url":"https://avatars.githubusercontent.com/u/7004868?v=3","gravatar_id":"","url":"https://api.github.com/users/JoshChristie","html_url":"https://github.com/JoshChristie","followers_url":"https://api.github.com/users/JoshChristie/followers","following_url":"https://api.github.com/users/JoshChristie/following{/other_user}","gists_url":"https://api.github.com/users/JoshChristie/gists{/gist_id}","starred_url":"https://api.github.com/users/JoshChristie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JoshChristie/subscriptions","organizations_url":"https://api.github.com/users/JoshChristie/orgs","repos_url":"https://api.github.com/users/JoshChristie/repos","events_url":"https://api.github.com/users/JoshChristie/events{/privacy}","received_events_url":"https://api.github.com/users/JoshChristie/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-07-11T07:19:32Z","updated_at":"2016-07-11T20:05:34Z","closed_at":null,"body":"Creating a model is rather annoying requiring us to specify the unique labels and the number of features. \r\n\r\nThe current method of the package is to do the following:\r\n```julia\r\ny = [1,2,2]\r\nx = [1.0, 2.5, 3.2; \r\n        4.0  4.5  5.0]\r\nmodel = GaussianNB(unique(y), size(x,1))\r\nfit(model, x, label)\r\npredict(m, xtest)\r\n```\r\n\r\nCould we instead pass in the desired naive bayes type into `fit()`. We could easily derive the unique labels and the number of features from the input data `x` and labels `y`. \r\n```julia\r\nmodel = fit(GaussianNB, x, y)\r\nprediction = predict(model, xtest)\r\n\r\n# so the function definitions would look something like\r\nfunction fit(::Type{GaussianNB}, x::Vector{Vector{Any}}, label::Vector)\r\n    # fit models to data and create the GaussianNB type\r\n    GaussianNB(...)\r\nend\r\n\r\nfunction fit(::Type{MultinomialNB}, X, y)\r\n     # fit models to data and create the GaussianNB type\r\n     MultinomialNB(....)\r\nend\r\n```\r\n\r\nWe could then deprecate the existing usage. What are peoples thoughts on this?\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/dfdx/NaiveBayes.jl/issues/comments/231848362","html_url":"https://github.com/dfdx/NaiveBayes.jl/issues/9#issuecomment-231848362","issue_url":"https://api.github.com/repos/dfdx/NaiveBayes.jl/issues/9","id":231848362,"user":{"login":"dfdx","id":428171,"avatar_url":"https://avatars.githubusercontent.com/u/428171?v=3","gravatar_id":"","url":"https://api.github.com/users/dfdx","html_url":"https://github.com/dfdx","followers_url":"https://api.github.com/users/dfdx/followers","following_url":"https://api.github.com/users/dfdx/following{/other_user}","gists_url":"https://api.github.com/users/dfdx/gists{/gist_id}","starred_url":"https://api.github.com/users/dfdx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dfdx/subscriptions","organizations_url":"https://api.github.com/users/dfdx/orgs","repos_url":"https://api.github.com/users/dfdx/repos","events_url":"https://api.github.com/users/dfdx/events{/privacy}","received_events_url":"https://api.github.com/users/dfdx/received_events","type":"User","site_admin":false},"created_at":"2016-07-11T20:05:34Z","updated_at":"2016-07-11T20:05:34Z","body":"One of the design goals of this package is to support online learning. To do so, `MultinomialNB` and `GaussianNB` implement `fit` in such a way that it may be called multiple times on the same model but different batches. For obvious reasons, if we change it to `fit(::Type{SomeNB}, X, y)`, we will lose this possibility. \r\n\r\nIn general, I see a particular split between machine learning and statistics communities in Julia. Stats guys tend to use signature you proposed, i.e. `fit(::Type{Model}, ...)`, but ML guys seem to prefer `fit(::Model, ...)` (note that the name \"fit\" may be changed to \"train\" or \"learn\", see discussion at JuliaML/Roadmap.jl#8). \r\n\r\nNote, that in theory it's still possible to automatically determine the number of labels by dynamically adding them, but this requires some experimenting that I don't really have time for at the moment. PR is welcome, though.  "}}
{"actor":{"display_login":"dfdx"}}