I will run a set of experiments. The main method evaluated has the following signature:
[Model threshold] = detect(...
TrainNeg, TrainPos, nf, nT, factors, ...
removeEachStage, applyEstEachStage, removeFeatures);
where removeEachStage, applyEstEachStage, and removeFeatures are booleans. You can see that if I reverse the order of any of these boolean parameters I may get wrong results.
Is there a method in MATLAB that allows better organization in order to minimize this kind of error? Or is there any tool I can use to protect me against these errors?
Organization with a struct
You could input a
structthat has these parameters as it’s fields.For example a structure with fields
That way when you set the fields it is clear what the field is, unlike a function call where you have to remember the order of the parameters.
Then your function call becomes
and your function definition would be something like
Then simply replace the occurrences of e.g.
paramwithsetts.param.Mixed approach
You can also mix this approach with your current one if you prefer, e.g.
if you wanted to still explicitly include
in1andin2, and bundle the rest intosetts.OOP approach
Another option is to turn detect into a class. The benefit to this is that a
detectobject would then have member variables with fixed names, as opposed to structs where if you make a typo when setting a field you just create a new field with the misspelled name.For example