I am making a Machine Learning pipeline repository. I have a BasePipeline
class and 2 child class - TabularPipeline
and ImagePipeline
. Both the child classes have a function named enable_cross_validation()
. Since the cross-validation techniques differ, the parameters of both the enable_cross_validation function differ.
TabularPipeline has 4 arguments namely method, metrics, n_split, validation_split
whereas ImagePipeline has only validation_split
.
Now I have a few design strategies but each has its own flaws. First, I used all four arguments in the Base class and only one argument in the Image class. This approach shows that the signature doesn't match (Just a convention issue, not a technical issue). Secondly, I used *args
and **kwargs
in the Base and define specific parameters in the child class function, but the coding guidelines say that we should always define the function signature and not keep the arguments dynamic. The third might be to keep the signature the same but don't use arguments in Image class, which doesn't sound good.
I know none of them is technically wrong but the design isn't good. I need a suggestion on better design or handling parameter variations in a subclass. Please note that there might be another parameter in Image that won't be there in the Base or Tabular class.
Aucun commentaire:
Enregistrer un commentaire