Skip to main content
PYSPARK โ€ข LESSON 295

Capstone Part 5: Multi-Tier Categorization & Risk Scoring

How can we compute customer transaction risk scores using multi-condition when/otherwise business logic?

Productionโฑ 3 Minutesโญ 840 XP
๐Ÿค” THE QUESTION

How can we compute customer transaction risk scores using multi-condition when/otherwise business logic?

๐Ÿ’ก WHAT IS IT?

Evaluating amount thresholds, user tier, and region simultaneously assigns risk categories (HIGH, MEDIUM, LOW).

๐ŸŽฏ WHAT IS IT USED FOR?

Automated fraud scoring and compliance risk classification in financial engineering.

๐Ÿ’ป EXAMPLE
df_scored = df_enriched.withColumn("risk_level", when((col("amount") > 10000) & (col("tier") == "BASIC"), "HIGH").when(col("amount") > 5000, "MEDIUM").otherwise("LOW"))

๐ŸŽฏ Mission Objectives

Practice typing production-grade PySpark code for Capstone Part 5: Multi-Tier Categorization & Risk Scoring.

  • โœ“ Multi-condition when() scoring
  • โœ“ Risk tier classification
  • โœ“ Compliance rule evaluation