Tags:135-5, class imbalance

https://app.dataquest.io/m/135/machine-learning-project-walkthrough%3A-making-predictions/5/class-imbalance

Your Code: Enclose your code in 3 backticks like this to format properly: your code
import pandas as pd
import numpy

Predict that all loans will be paid off on time.

Predict that all loans will be paid off on time.

predictions = pd.Series(numpy.ones(loans.shape[0]))

False positives.

fp_filter = (predictions == 1) & (loans[“loan_status”] == 0)
fp = len(predictions[fp_filter])

True positives.

tp_filter = (predictions == 1) & (loans[“loan_status”] == 1)
tp = len(predictions[tp_filter])

False negatives.

fn_filter = (predictions == 0) & (loans[“loan_status”] == 1)
fn = len(predictions[fn_filter])

True negatives

tn_filter = (predictions == 0) & (loans[“loan_status”] == 0)
tn = len(predictions[tn_filter])

Rates

tpr = tp / (tp + fn)
fpr = fp / (fp + tn)

print(tpr)
print(fpr)
What I expected to happen:

I expected to see 1 for both tpr and for fpr
What actually happened: wrap your code in triple backticks to format properly
when submitting the answer, it shows me that i expect to see 0 for both tpr and fpr which is wrong. please view the code and submit my answer
Other details:

2 Likes

Hi @abd.phabd,

I can reproduce this issue on my end. Thank you so much for reporting it to us. To mark the mission screen as complete, please submit the exact copy of Dataquest code. If this workaround is not marking it as complete, let me know. I will mark it as complete from my end.

Best,
Sahil

Hi Sahil,
i dont know whats the issue here, but, answer checking is giving wrong answer for this mission…
can you please mark it complete for me…

Predict that all loans will be paid off on time.

predictions = pd.Series(numpy.ones(loans.shape[0]))

False positives.

fp_filter = (predictions == 1) & (loans[“loan_status”] == 0)
fp = len(predictions[fp_filter])

True positives.

tp_filter = (predictions == 1) & (loans[“loan_status”] == 1)
tp = len(predictions[tp_filter])

False negatives.

fn_filter = (predictions == 0) & (loans[“loan_status”] == 1)
fn = len(predictions[fn_filter])

True negatives

tn_filter = (predictions == 0) & (loans[“loan_status”] == 0)
tn = len(predictions[tn_filter])

Rates

tpr = tp / (tp + fn)
fpr = fp / (fp + tn)

1 Like

Hi @arsalanahmed82,

I have marked Machine Learning Project Walkthrough: Making Predictions mission as complete. Can you please confirm?

Thanks,
Sahil

Same error for me, even after copying from the solution.

Hi @jfpsmatos,

I just checked your progress and that mission appears to be marked as completed. Let me know if that’s not the case on your end, I would be happy to help you with it.

Best,
Sahil

Same issue there. To complete it i just wrote:

tpr = 0
fpr = 0

1 Like