SECTION 1: LEARNING OBJECTIVES

By the end of this lesson, you will be able to:

  • Define AI-powered personalisation and its role in banking.

  • Understand the personalisation maturity model in banking.

  • Implement recommendation systems for banking products.

  • Apply next-best-action (NBA) for customer engagement.

  • Use real-time personalisation across channels.

  • Measure personalisation effectiveness using key metrics.

  • Understand the technology stack for personalisation.

  • Develop a personalisation strategy for a bank.


SECTION 2: WHAT IS AI-POWERED PERSONALISATION?

2.1 Definition

AI-powered personalisation is the use of artificial intelligence and machine learning to deliver tailored experiences, products, and communications to individual customers based on their behaviour, preferences, and needs.

2.2 The Personalisation Maturity Model
text
┌─────────────────────────────────────────────────────────────────────────────┐
│                    PERSONALISATION MATURITY MODEL                         │
├─────────────────────────────────────────────────────────────────────────────┤
│                                                                             │
│  Level 1           Level 2           Level 3           Level 4             │
│  ┌─────────┐      ┌─────────┐      ┌─────────┐      ┌─────────┐          │
│  │ Basic   │      │ Segmented│      │ Behavioural│   │ Predictive│        │
│  └─────────┘      └─────────┘      └─────────┘      └─────────┘          │
│                                                                             │
│  Level 5           Level 6           Level 7                              │
│  ┌─────────┐      ┌─────────┐      ┌─────────┐                          │
│  │ Contextual│    │ Hyper-   │    │ Autonomous│                         │
│  │          │    │ Personalised│  │           │                         │
│  └─────────┘      └─────────┘      └─────────┘                          │
│                                                                             │
│  • Name-based   • Segment-based  • Behaviour     • AI-driven              │
│  • Generic      • Demographics   • Real-time     • Predictive             │
│  • One-size     • Targeted       • Adaptive      • Individualised         │
│                                                                             │
└─────────────────────────────────────────────────────────────────────────────┘
2.3 Personalisation Use Cases in Banking
 
 
Use Case Description Example
Product Recommendations Suggest relevant products. “Customers like you also use our savings account.”
Personalised Offers Targeted promotions. “0% interest on balance transfers for 12 months.”
Content Personalisation Customised app/website content. Personalised dashboard, relevant articles.
Next-Best-Action Proactive recommendations. “Based on your spending, you could save $50/month.”
Personalised Pricing Dynamic pricing based on risk/value. Customised interest rates, fees.
Customer Journeys Personalised onboarding and journeys. Tailored welcome experience.

SECTION 3: RECOMMENDATION SYSTEMS

3.1 Types of Recommendation Systems
 
 
Type Description Banking Example
Content-Based Recommend similar products. Recommend savings account based on current account.
Collaborative Filtering Recommend based on similar customers. “Customers like you also liked…”
Hybrid Combination of approaches. More accurate recommendations.
Rule-Based Business rules. “If customer has salary account, offer savings account.”
AI/ML-Based Machine learning predictions. Next-best-action predictions.
3.2 Recommendation System Architecture
text
┌─────────────────────────────────────────────────────────────────────────────┐
│                    RECOMMENDATION SYSTEM ARCHITECTURE                     │
├─────────────────────────────────────────────────────────────────────────────┤
│                                                                             │
│  ┌──────────────────────────────────────────────────────────────────────┐   │
│  │                    DATA LAYER                                       │   │
│  │  Customer data, product data, transaction data, behavioural data    │   │
│  └──────────────────────────────────────────────────────────────────────┘   │
│                                    │                                        │
│                                    v                                        │
│  ┌──────────────────────────────────────────────────────────────────────┐   │
│  │                    FEATURE ENGINEERING                              │   │
│  │  Customer features, product features, historical interactions       │   │
│  └──────────────────────────────────────────────────────────────────────┘   │
│                                    │                                        │
│                                    v                                        │
│  ┌──────────────────────────────────────────────────────────────────────┐   │
│  │                    MODEL TRAINING                                   │   │
│  │  Collaborative filtering, content-based, hybrid, ML models          │   │
│  └──────────────────────────────────────────────────────────────────────┘   │
│                                    │                                        │
│                                    v                                        │
│  ┌──────────────────────────────────────────────────────────────────────┐   │
│  │                    REAL-TIME INFERENCE                              │   │
│  │  Generate recommendations in real-time                             │   │
│  └──────────────────────────────────────────────────────────────────────┘   │
│                                    │                                        │
│                                    v                                        │
│  ┌──────────────────────────────────────────────────────────────────────┐   │
│  │                    PRESENTATION                                    │   │
│  │  App, web, email, push notifications                                │   │
│  └──────────────────────────────────────────────────────────────────────┘   │
│                                                                             │
└─────────────────────────────────────────────────────────────────────────────┘

SECTION 4: NEXT-BEST-ACTION (NBA)

4.1 What is Next-Best-Action?

Next-Best-Action (NBA) is an AI-driven approach that predicts the most appropriate action to take with a customer at any given moment to achieve a specific business outcome (e.g., retention, cross-sell, engagement).

4.2 NBA Framework
text
┌─────────────────────────────────────────────────────────────────────────────┐
│                    NEXT-BEST-ACTION FRAMEWORK                             │
├─────────────────────────────────────────────────────────────────────────────┤
│                                                                             │
│  ┌──────────────────────────────────────────────────────────────────────┐   │
│  │                    CUSTOMER INSIGHTS                                │   │
│  │  (Behaviour, preferences, lifecycle stage, risk profile)            │   │
│  └──────────────────────────────────────────────────────────────────────┘   │
│                                    │                                        │
│                                    v                                        │
│  ┌──────────────────────────────────────────────────────────────────────┐   │
│  │                    BUSINESS OBJECTIVES                              │   │
│  │  (Retention, cross-sell, engagement, revenue)                       │   │
│  └──────────────────────────────────────────────────────────────────────┘   │
│                                    │                                        │
│                                    v                                        │
│  ┌──────────────────────────────────────────────────────────────────────┐   │
│  │                    ACTION SELECTION                                 │   │
│  │  (AI-driven prediction of best action)                              │   │
│  └──────────────────────────────────────────────────────────────────────┘   │
│                                    │                                        │
│                                    v                                        │
│  ┌──────────────────────────────────────────────────────────────────────┐   │
│  │                    CHANNEL DELIVERY                                 │   │
│  │  (App, web, email, push, SMS, branch)                              │   │
│  └──────────────────────────────────────────────────────────────────────┘   │
│                                    │                                        │
│                                    v                                        │
│  ┌──────────────────────────────────────────────────────────────────────┐   │
│  │                    MEASURE & OPTIMISE                               │   │
│  │  (Track outcomes, A/B test, continuous improvement)                 │   │
│  └──────────────────────────────────────────────────────────────────────┘   │
│                                                                             │
└─────────────────────────────────────────────────────────────────────────────┘

SECTION 5: IMPLEMENTATION IN PYTHON – PERSONALISATION

python
# ===================================================================
# MODULE 4, LESSON 4: AI-POWERED PERSONALISATION
# ===================================================================

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.metrics.pairwise import cosine_similarity
from sklearn.preprocessing import StandardScaler
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
import warnings
warnings.filterwarnings('ignore')

print("="*70)
print("AI-POWERED PERSONALISATION IN DIGITAL BANKING")
print("="*70)

# ----------------------------------------------------------------
# PART A: GENERATE CUSTOMER AND PRODUCT DATA
# ----------------------------------------------------------------

print("\n" + "-"*60)
print("PART A: Customer and Product Data")
print("-"*60)

np.random.seed(42)
n_customers = 1000
n_products = 10

# Customer features
customers = pd.DataFrame({
    'customer_id': range(1, n_customers + 1),
    'age': np.random.normal(45, 15, n_customers).clip(18, 80).astype(int),
    'income': np.random.gamma(5, 20, n_customers) + 20,
    'account_balance': np.random.gamma(3, 100, n_customers).clip(0, 50000),
    'tenure_months': np.random.gamma(2, 30, n_customers).clip(1, 240).astype(int),
    'num_products': np.random.choice([1, 2, 3, 4, 5], n_customers, p=[0.2, 0.3, 0.25, 0.15, 0.1]),
    'tx_count': np.random.poisson(15, n_customers).clip(0, 50),
    'app_visits': np.random.poisson(8, n_customers).clip(0, 30)
})

# Product catalogue
products = pd.DataFrame({
    'product_id': range(1, n_products + 1),
    'product_name': [
        'Savings Account', 'Checking Account', 'Credit Card', 'Personal Loan',
        'Mortgage', 'Investment Account', 'Insurance', 'Business Account',
        'Student Account', 'Premium Card'
    ],
    'category': ['Deposit', 'Deposit', 'Credit', 'Loan', 'Loan', 'Investment', 
                 'Insurance', 'Deposit', 'Deposit', 'Credit'],
    'min_income': [0, 0, 20, 30, 50, 40, 25, 60, 10, 35],
    'min_balance': [0, 0, 0, 0, 10000, 5000, 0, 10000, 0, 5000]
})

print(f"Customers: {len(customers)}")
print(f"Products: {len(products)}")
print(products.to_string(index=False))

# ----------------------------------------------------------------
# PART B: PRODUCT RECOMMENDATION SYSTEM
# ----------------------------------------------------------------

print("\n" + "-"*60)
print("PART B: Product Recommendation System")
print("-"*60)

# Simulate customer-product interactions (owned products)
np.random.seed(42)
interactions = np.zeros((n_customers, n_products))

for i, customer in customers.iterrows():
    # Number of products owned
    n_owned = customer['num_products']
    owned = np.random.choice(n_products, n_owned, replace=False)
    interactions[i, owned] = 1

# Collaborative filtering recommendations
def get_collaborative_recommendations(customer_id, interactions, products, top_n=3):
    """Get product recommendations based on collaborative filtering."""
    customer_idx = customer_id - 1
    customer_vector = interactions[customer_idx].reshape(1, -1)
    
    # Calculate similarity with all customers
    similarities = cosine_similarity(customer_vector, interactions)
    similar_customers = np.argsort(similarities[0])[-6:-1]  # Top 5 similar customers
    
    # Get products owned by similar customers
    similar_products = interactions[similar_customers].sum(axis=0)
    
    # Remove products already owned by the customer
    owned = interactions[customer_idx] == 1
    similar_products[owned] = 0
    
    # Get top recommendations
    recommended_indices = np.argsort(similar_products)[-top_n:][::-1]
    recommended_products = products.iloc[recommended_indices]['product_name'].tolist()
    
    return recommended_products

# Get recommendations for a sample customer
sample_customer = 42
recommendations = get_collaborative_recommendations(sample_customer, interactions, products)

owned_products = products.iloc[interactions[sample_customer-1] == 1]['product_name'].tolist()

print(f"Customer {sample_customer}:")
print(f"  Owned Products: {owned_products}")
print(f"  Recommended Products: {recommendations}")

# ----------------------------------------------------------------
# PART C: NEXT-BEST-ACTION MODELLING
# ----------------------------------------------------------------

print("\n" + "-"*60)
print("PART C: Next-Best-Action Modelling")
print("-"*60)

# Generate synthetic NBA data
np.random.seed(42)
n_actions = 10000

action_data = pd.DataFrame({
    'customer_id': np.random.choice(range(1, n_customers + 1), n_actions),
    'action_type': np.random.choice(['Deposit', 'Withdrawal', 'Transfer', 'Payment', 
                                     'Account Opening', 'Loan Application', 
                                     'Investment', 'Insurance Quote'], n_actions),
    'amount': np.random.gamma(3, 50, n_actions),
    'channel': np.random.choice(['App', 'Web', 'Branch', 'ATM'], n_actions, 
                                p=[0.5, 0.2, 0.15, 0.15]),
    'timestamp': [datetime.now() - timedelta(days=np.random.randint(0, 90)) for _ in range(n_actions)]
})

# Feature engineering for NBA
customer_actions = action_data.groupby('customer_id').agg({
    'action_type': lambda x: x.mode()[0] if len(x) > 0 else 'Unknown',
    'amount': 'mean',
    'timestamp': 'count'
}).reset_index()
customer_actions.columns = ['customer_id', 'most_frequent_action', 'avg_amount', 'action_count']

# Merge with customer data
customer_nba = customers.merge(customer_actions, on='customer_id', how='left')
customer_nba.fillna({'most_frequent_action': 'Unknown', 'avg_amount': 0, 'action_count': 0}, inplace=True)

# Generate NBA recommendations (simplified)
def generate_nba(row):
    """Generate next-best-action based on customer profile."""
    if row['num_products'] < 3:
        return 'Increase product adoption'
    elif row['action_count'] < 10:
        return 'Increase transaction activity'
    elif row['account_balance'] > 30000:
        return 'Investment advice'
    elif row['age'] > 55:
        return 'Retirement planning'
    else:
        return 'General engagement'

customer_nba['nba'] = customer_nba.apply(generate_nba, axis=1)

print("NBA Distribution:")
print(customer_nba['nba'].value_counts())

# ----------------------------------------------------------------
# PART D: REAL-TIME PERSONALISATION DASHBOARD
# ----------------------------------------------------------------

print("\n" + "-"*60)
print("PART D: Real-Time Personalisation Dashboard")
print("-"*60)

def display_personalised_dashboard(customer_id, customers, products, interactions, customer_nba):
    """Display a personalised dashboard for a customer."""
    customer = customers[customers['customer_id'] == customer_id]
    if len(customer) == 0:
        print(f"Customer {customer_id} not found")
        return
    
    # Get customer data
    row = customer.iloc[0]
    customer_data = customer_nba[customer_nba['customer_id'] == customer_id]
    
    # Get owned products
    owned_products = products.iloc[interactions[customer_id-1] == 1]['product_name'].tolist()
    
    # Get recommendations
    recs = get_collaborative_recommendations(customer_id, interactions, products)
    
    print(f"\n--- PERSONALISED DASHBOARD FOR {customer_id} ---")
    print("\n1. CUSTOMER PROFILE:")
    print(f"   Age: {row['age']}, Income: ${row['income']:.2f}")
    print(f"   Balance: ${row['account_balance']:.2f}, Tenure: {row['tenure_months']} months")
    print(f"   Products: {row['num_products']}, Transactions: {row['tx_count']}")
    
    print("\n2. OWNED PRODUCTS:")
    for product in owned_products:
        print(f"   • {product}")
    
    print("\n3. RECOMMENDED PRODUCTS:")
    for rec in recs:
        print(f"   • {rec}")
    
    print("\n4. NEXT-BEST-ACTION:")
    if len(customer_data) > 0:
        print(f"   {customer_data.iloc[0]['nba']}")

# Display personalised dashboard for a sample customer
display_personalised_dashboard(42, customers, products, interactions, customer_nba)

# ----------------------------------------------------------------
# PART E: PERSONALISATION METRICS
# ----------------------------------------------------------------

print("\n" + "-"*60)
print("PART E: Personalisation Metrics")
print("-"*60)

personalisation_metrics = pd.DataFrame({
    'Metric': [
        'Personalisation Rate',
        'Recommendation Click-Through Rate',
        'Conversion Rate (Personalised)',
        'Conversion Rate (Non-Personalised)',
        'Revenue Uplift',
        'Customer Engagement Score',
        'Personalisation Reach',
        'A/B Test Win Rate'
    ],
    'Current Value': [
        '35%',
        '4.2%',
        '12.5%',
        '6.8%',
        '15%',
        '72',
        '45%',
        '68%'
    ],
    'Target Value': [
        '> 70%',
        '> 8%',
        '> 18%',
        '> 10%',
        '> 25%',
        '> 85',
        '> 80%',
        '> 75%'
    ],
    'Status': ['🔴', '🔴', '🟡', '🟡', '🟡', '🟡', '🔴', '🟡']
})

print("Personalisation Metrics:")
print(personalisation_metrics.to_string(index=False))

# ----------------------------------------------------------------
# PART F: PERSONALISATION TECHNOLOGY STACK
# ----------------------------------------------------------------

print("\n" + "-"*60)
print("PART F: Personalisation Technology Stack")
print("-"*60)

tech_stack = {
    "Customer Data": {
        "Technologies": ["CDP", "Data Lake", "CRM"],
        "Capabilities": ["Data ingestion", "Identity resolution", "Customer profiles"]
    },
    "AI/ML": {
        "Technologies": ["TensorFlow", "PyTorch", "Scikit-learn", "XGBoost"],
        "Capabilities": ["Recommendation algorithms", "Propensity modelling", "NBA"]
    },
    "Decision Engine": {
        "Technologies": ["Pega", "Adobe Experience Platform", "Salesforce Einstein"],
        "Capabilities": ["Real-time decisions", "Rules engine", "Orchestration"]
    },
    "Delivery Channels": {
        "Technologies": ["Mobile App", "Web", "Email", "Push"],
        "Capabilities": ["Multi-channel delivery", "Personalised content"]
    },
    "Measurement": {
        "Technologies": ["Google Analytics", "Mixpanel", "Amplitude"],
        "Capabilities": ["A/B testing", "Analytics", "Optimisation"]
    }
}

print("Personalisation Technology Stack:")
for layer, details in tech_stack.items():
    print(f"\n{layer}:")
    print(f"  Technologies: {', '.join(details['Technologies'])}")
    print(f"  Capabilities: {', '.join(details['Capabilities'])}")

# ----------------------------------------------------------------
# PART G: PERSONALISATION ROADMAP
# ----------------------------------------------------------------

print("\n" + "-"*60)
print("PART G: Personalisation Roadmap")
print("-"*60)

roadmap = {
    "Phase 1 (0-6 months) – Foundation": {
        "Focus": "Build data foundation and basic personalisation.",
        "Activities": [
            "Implement CDP for unified customer data.",
            "Build basic recommendation system.",
            "Implement segmentation-based personalisation.",
            "Enable personalised email campaigns."
        ],
        "Success Metrics": ["Personalisation rate > 30%", "Customer data unified"]
    },
    "Phase 2 (6-12 months) – AI-Driven": {
        "Focus": "Implement AI-driven personalisation.",
        "Activities": [
            "Build AI-powered recommendation engine.",
            "Implement next-best-action models.",
            "Enable real-time personalisation.",
            "Deploy A/B testing framework."
        ],
        "Success Metrics": ["Personalisation rate > 60%", "CTR > 5%"]
    },
    "Phase 3 (12-24 months) – Predictive": {
        "Focus": "Predictive and contextual personalisation.",
        "Activities": [
            "Implement predictive personalisation.",
            "Enable contextual personalisation (location, time).",
            "Build personalised customer journeys.",
            "Integrate with all channels."
        ],
        "Success Metrics": ["Personalisation rate > 80%", "Revenue uplift > 20%"]
    },
    "Phase 4 (24+ months) – Autonomous": {
        "Focus": "Autonomous personalisation.",
        "Activities": [
            "Enable self-optimising personalisation.",
            "Implement generative AI for content creation.",
            "Build autonomous customer journeys.",
            "Achieve industry-leading personalisation."
        ],
        "Success Metrics": ["Industry-leading personalisation", "Continuous optimisation"]
    }
}

for phase, details in roadmap.items():
    print(f"\n{phase}:")
    print(f"  Focus: {details['Focus']}")
    print("  Activities:")
    for activity in details['Activities']:
        print(f"    • {activity}")
    print("  Success Metrics:")
    for metric in details['Success Metrics']:
        print(f"    • {metric}")

# ----------------------------------------------------------------
# PART H: SUMMARY AND RECOMMENDATIONS
# ----------------------------------------------------------------

print("\n" + "="*70)
print("PART H: Summary and Recommendations")
print("="*70)

print("""
AI-Powered Personalisation – Key Takeaways:

1. Personalisation is essential for customer engagement and revenue growth.
2. Maturity levels: basic → segmented → behavioural → predictive → contextual → hyper → autonomous.
3. Recommendation systems suggest relevant products to customers.
4. Next-best-action predicts the best action for each customer.
5. Real-time personalisation delivers tailored experiences at the moment.
6. Key metrics: personalisation rate, CTR, conversion rate, revenue uplift.
7. Technology stack: CDP, AI/ML, decision engine, delivery channels, measurement.

Recommendations:
  - Build a unified customer data foundation.
  - Implement AI-powered recommendation systems.
  - Deploy next-best-action models.
  - Enable real-time personalisation.
  - Measure and optimise continuously.
  - Start with high-impact use cases.
""")

print("="*70)
print("END OF LESSON 4 – MODULE 4")
print("="*70)

SECTION 6: SUMMARY FOR THE DATA PRACTITIONER

  • AI-powered personalisation delivers tailored experiences based on customer behaviour and preferences.

  • Maturity levels progress from basic (name-based) to autonomous (self-optimising).

  • Recommendation systems (collaborative filtering, content-based, hybrid) suggest relevant products.

  • Next-Best-Action (NBA) predicts the best action for each customer at any moment.

  • Real-time personalisation enables immediate, context-aware responses.

  • Key metrics include personalisation rate, click-through rate, conversion rate, and revenue uplift.

  • Technology stack includes CDP, AI/ML models, decision engines, delivery channels, and measurement tools.


SECTION 7: RECOMMENDED NEXT STEPS

  1. Build a unified customer data foundation (CDP).

  2. Implement AI-powered recommendation systems.

  3. Deploy next-best-action models.

  4. Enable real-time personalisation.

  5. Measure and optimise continuously.

  6. Start with high-impact use cases.

  7. Prepare for Lesson 5: Fraud Detection and AML with AI.