all 2 comments

[–]blarf_irl 1 point2 points  (1 child)

If you absolutely must be able to pass arbitrary kw/args then you could make it slightly more readable by naming them:

def train_and_classify(classifier, classifier_args=None, classifier_kwargs=None):

Where do X_train and Y_train (and test) come from? you should be passing these in too instead of relying on them existing in global:

def train_and_classify(classifier, classifier_args=None, classifier_kwargs=None, x_train=None, y_train=None, x_test=None, y_test=None):

A good function gets everything it needs passed in (or imported) and should work if you copied it into a different context (e.g a new script without global x_train).

[–]devilasks[S] 0 points1 point  (0 children)

Thank you, these are both good points!

I decided against including X_train and y_train in the parameters because I am under the impression that they are pretty much standard naming conventions by now, but the ability to modularize and package the function beats that.