PDF is a practical output format for automated reports: it packages pipeline metrics, model performance measurements, charts, and feature distributions into a shareable document. section 12.1 section 12.1.2
A Python-generated PDF report can contain:
- Data-upload metrics such as uploaded rows, missing values, and upload timestamps. section 12.1.1
- Model precision and recall plotted over time. section 12.1.2
- Input-feature distribution plots assembled alongside titles and other report components. section 12.1.2
Generate a pipeline report
Install reportlab, create a Canvas with a chosen filepath and page size, set a font, draw metric strings, and save the resulting PDF. section 12.1.1
Listing 12.2 In this code, we use Python’s reportlab library to generate a PDF file. This file contains summary information about running the customer churn pipeline.
from datetime import datetime #1
from reportlab.lib.pagesizes import letter #1
from reportlab.pdfgen import canvas #1
def create_report(rows_uploaded, #2
missing_values,
report_path): #2
c = canvas.Canvas(report_path, #3
pagesize = letter)
c.setFont("Helvetica", 12) #4
c.drawString(50,
750,
"Data upload metrics") #5
c.drawString(50, #6
700,
"Upload date: {}".\
format(datetime.now().\
strftime('%Y-%m-%d %H:%M:%S')))
c.drawString(50, #7
650,
"Number of Rows Uploaded: {}".\
format(rows_uploaded))
c.drawString(50, #8
600,
"Number of Missing Values: {}".\
format(missing_values))
c.showPage() #9
c.save() #9
print("""File has been #10
saved succesfully""",
report_path)
report_path = "ch12/reports/dataset_upload_report.pdf"
create_report(rows_uploaded = 1000, #11
missing_values = 50,
report_path)
Inspect a focused reportlab example that writes upload metrics and a timestamp into a PDF file. section 12.1.1


