UNQ_C9: Class 'TLearner' - method 'predict' is incorrect

The auto grader keeps giving me the error:

UNQ_C9: Class 'TLearner' - method 'predict' is incorrect.

The code seems pretty straightforward:

def predict(self, X):
        risk_control = self.control_estimator.predict(X)
        risk_treatment = self.treatment_estimator.predict(X)
        # the predicted risk reduction is control risk minus the treatment risk
        pred_risk_reduction =  np.subtract(risk_control, risk_treatment)
        return pred_risk_reduction

Any hints on what I am missing?

Hi @wdduncan . I quick hint for you: We are trying to predict the probabilities of X. Hope that helps!

Thanks. That helped! My UNQ_C9 is now graded as “correct” :slight_smile:

@Samuel_Chazy @wdduncan

I have the same problem, except I did a regular subtract (minus) and used a predict_proba method on the estimators that seem to be RandomForestClassifiers.

Unfortunately did not quite follow Samuel’s hint. Brain’s a little slow :wink: Need some help.

Thanks folks.

Hi @getjaidev,
I think I know what the problem is, but I can’t be sure since I haven’t seen your code. The hint is: go back a bit in time through the course and check how the predict probabilities function should be called. I think it is missing something in the code. Let me know if that works!

Thanks @Samuel_Chazy for the help and explanation of the functions used. Very lucid.