# C3\_W1 UNQ\_C9 - initialize T Learner

**URL:** <https://community.deeplearning.ai/t/c3-w1-unq-c9-initialize-t-learner/538907>\
**Category:** AI For Medical Treatment\
**Tags:** week-module-1\
**Created:** [January 8, 2024, 4:44pm UTC](https://community.deeplearning.ai/t/c3-w1-unq-c9-initialize-t-learner/538907 "2024-01-08T16:44:44Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![jimtarrant5](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/jimtarrant5/32/39158_2.png) [@jimtarrant5](https://community.deeplearning.ai/u/jimtarrant5)\
**Post date:** [January 8, 2024, 4:44pm UTC](https://community.deeplearning.ai/t/c3-w1-unq-c9-initialize-t-learner/538907/1 "2024-01-08T16:44:44Z")

</div>

I am completely lost in cell UNQ\_C9 - how do I # set the treatment estimator?

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/165831_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [January 8, 2024, 5:44pm UTC](https://community.deeplearning.ai/t/c3-w1-unq-c9-initialize-t-learner/538907/2 "2024-01-08T17:44:44Z")

</div>

Hello @jimtarrant5,

Can you explain a little more on how to help you with your issue?

Are you getting any error, then kindly share a image of your error without sharing any codes at the public post as it is against community guidelines.

Also you mentioned UNQ\_C9 but week 3 has only UNQ\_C4 cells to grade?

Can you be a little more specific? probably an image!!!

Regards  
DP

---

<div class="post-metadata">

**Author:** ![jimtarrant5](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/jimtarrant5/32/39158_2.png) [@jimtarrant5](https://community.deeplearning.ai/u/jimtarrant5)\
**Post date:** [January 8, 2024, 5:56pm UTC](https://community.deeplearning.ai/t/c3-w1-unq-c9-initialize-t-learner/538907/3 "2024-01-08T17:56:21Z")

</div>

Whoops, I meant C3\_W1! Sorry!

This is the code. I just don’t know where to start to set the estimator.

 ![image](https://global.discourse-cdn.com/dlai/original/3X/0/6/065d930a0f3cf3bbdca1b209e9c6f288f5e2682b.png)

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/165831_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [January 8, 2024, 6:15pm UTC](https://community.deeplearning.ai/t/c3-w1-unq-c9-initialize-t-learner/538907/4 "2024-01-08T18:15:40Z")

</div>

Hello @jimtarrant5,

The below instructions tells you to recall the treatment estimator and control estimator according to def **init** (self, treatment\_estimator, control\_estimator):

The constructor ` __init__ ()` sets the treatment and control estimators based on the given inputs to the constructor.

So use the same term without self

Regards  
DP

---

<div class="post-metadata">

**Author:** ![jimtarrant5](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/jimtarrant5/32/39158_2.png) [@jimtarrant5](https://community.deeplearning.ai/u/jimtarrant5)\
**Post date:** [January 8, 2024, 6:28pm UTC](https://community.deeplearning.ai/t/c3-w1-unq-c9-initialize-t-learner/538907/5 "2024-01-08T18:28:27Z")

</div>

Thank you for engaging, Deepti. Are you saying it as simple as I have shown below?

It seems the TLearner is still not functioning correctly. Later I get an error when I call the quantile\_benefit() function on the results of the Tlearner.

 ![image](https://global.discourse-cdn.com/dlai/original/3X/3/a/3a2b5d6a86cffb37417616ea97ad51caceb80b8a.png)

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/165831_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [January 8, 2024, 6:45pm UTC](https://community.deeplearning.ai/t/c3-w1-unq-c9-initialize-t-learner/538907/6 "2024-01-08T18:45:04Z")

</div>

Hello @jimtarrant5,

your code needs a bit correction with the second part of the code,

The `predict` function takes the featuers and uses each estimator to predit the risk of death. Then it calculates the risk of death for the control estimator minus the risk of death from the treatment estimator, and returns this as the predicted risk reduction.

Return should be preds (np.array): predicted risk reduction for each row of X

Regards  
DP

---

<div class="post-metadata">

**Author:** ![jimtarrant5](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/jimtarrant5/32/39158_2.png) [@jimtarrant5](https://community.deeplearning.ai/u/jimtarrant5)\
**Post date:** [January 8, 2024, 6:49pm UTC](https://community.deeplearning.ai/t/c3-w1-unq-c9-initialize-t-learner/538907/7 "2024-01-08T18:49:52Z")

</div>

Thanks, again, Deepti.

The predicted risk reduction is what I intend to return, but the last few lines were cut off in the previous image

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/165831_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [January 8, 2024, 6:58pm UTC](https://community.deeplearning.ai/t/c3-w1-unq-c9-initialize-t-learner/538907/8 "2024-01-08T18:58:41Z")

</div>

Hello @jimtarrant5,

predict the risk of death using the control estimator  
risk\_control = self.control\_estimator.predict\_proba(X)(you need to add a code matrix here)

predict the risk of death using the treatment estimator  
risk\_treatment = self.treatment\_estimator.predict\_proba(X)(you need to add a code matrix here)

the predicted risk reduction is control risk minus the treatment risk  
pred\_risk\_reduction = don’t use numpy here. just use the arithmetic way.

Regards  
DP

---

<div class="post-metadata">

**Author:** ![jimtarrant5](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/jimtarrant5/32/39158_2.png) [@jimtarrant5](https://community.deeplearning.ai/u/jimtarrant5)\
**Post date:** [January 8, 2024, 7:21pm UTC](https://community.deeplearning.ai/t/c3-w1-unq-c9-initialize-t-learner/538907/9 "2024-01-08T19:21:33Z")

</div>

Thanks for your help, Deepti!

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/165831_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [January 10, 2024, 8:27am UTC](https://community.deeplearning.ai/t/c3-w1-unq-c9-initialize-t-learner/538907/10 "2024-01-10T08:27:37Z")

</div>

Issue resolved??
