Enrollments closing soon for Post Graduate Certificate Program in Applied Data Science & AI By IIT Roorkee | 3 Seats Left

  Apply Now

Python Project - Churn Emails

4 / 7

Python Project - Churn Emails - Find Average Spam Confidence

In the previous exercise, we saw a couple of examples of startswith. Let's do one more hands-on with startswith

INSTRUCTIONS
  • Define a function average_spam_confidence which calculates the average spam confidence and returns it
  • Open the file mbox-short.txt which is located at /cxldata/datasets/project/mbox-short.txt
  • Loop through the file handle
  • Select only those lines starts with X-DSPAM-Confidence:
  • Split the lines at : and take the float value which is spam confidence
  • Find the average of this spam confidence in the entire file and return it.

PS - If your logic is correct then the correct spam confidence score should be 0.7507185185185187. You can use "Hint" and "See Answer" if you are stuck.



Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...