-
Notifications
You must be signed in to change notification settings - Fork 1.9k
WIP Introduce I*PredictionKind*TrainerFactory and propagate them #670
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -24,7 +24,7 @@ public abstract class ArgumentsBase | |||
{ | |||
[Argument(ArgumentType.Multiple, HelpText = "Base predictor", ShortName = "p", SortOrder = 1, SignatureType = typeof(SignatureBinaryClassifierTrainer))] | |||
[TGUI(Label = "Predictor Type", Description = "Type of underlying binary predictor")] | |||
public IComponentFactory<TScalarTrainer> PredictorType; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the comment here #622 (comment) why I didn't do it this way to begin with. I don't think we should be closing off this interface to a sub-interface, because it limits what kinds of classes can implement the interface.
return Args.PredictorType != null ? | ||
Args.PredictorType.CreateComponent(Host) : | ||
new LinearSvm(Host, new LinearSvm.Arguments()); | ||
return Args.PredictorType.CreateComponent(Host); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if someone sets Args.PredictorType
to null?
I see we are propagating the pattern the
var ovaArgs = new Ova.Arguments();
ovaArgs.PredictorType = new FastTreeBinaryClassificationTrainer.Arguments();
var ova = new Ova(env, ovaArgs); IMO it is unintuitive to set |
I also find the Arugments behaving as a factory confusing. Factories should take arguments, not be arguments. If something is going to produce types it shouldn't be called arguments, its actually a "configured" factory. @eerhardt can you formalize the alternative so that we can see the difference? |
My proposed alternative is 2 fold:
var ovaArgs = new Ova.Arguments();
ovaArgs.PredictorType = new SimpleComponentFactory<ITrainer<IPredictorProducing<float>>>(
(e) => new FastTreeBinaryClassificationTrainer(e, new FastTreeBinaryClassificationTrainer.Arguments()));
var ova = new Ova(env, ovaArgs); This is a bit verbose, so in the places where we want a stream-lined API, we could have (2).
var ovaArgs = new Ova.Arguments();
ovaArgs.PredictorType = new BinaryClassifierFactory(
(e) => new FastTreeBinaryClassificationTrainer(e, new FastTreeBinaryClassificationTrainer.Arguments()));
var ova = new Ova(env, ovaArgs); Or even if we really want to stream-line it, have a factory for the specific component: var ovaArgs = new Ova.Arguments();
ovaArgs.PredictorType = new FastTreeBinaryClassificationFactory(new FastTreeBinaryClassificationTrainer.Arguments());
var ova = new Ova(env, ovaArgs); |
Fixes #669.
Need to kill all LoadableClasses attributes, and figure out why command line parser throw assert.
@eerhardt this is related to comment in your PR regarding subcomponents, and I just don't want you to do same job since this is about 90% complete.