I am trying to override the predict_proba method of a classifier class. The easiest approach as far as I have seen and if applicable is preprocessing the input to the base class method or postprocessing its output.
class RandomForestClassifierWrapper(RandomForestClassifier):
def predict_proba(self, X):
pre_process(X)
ret = super(RandomForestClassifierWrapper, self).predict_proba(X)
return post_process(ret)
However, what I want to do is copying a variable which is locally created in the base class method, processed and garbage-collected when the method returns. I am intending to process the intermediate result stored in this variable. Is there a straightforward way to do this without messing with the base class internals?
Try overriding: