coursera_2026_06
Community Article
Community articles are authored by SitePoint Premium contributors. Content is screened before publication, and SitePoint reserves the right to moderate or remove articles that violate our guidelines. Views expressed are those of the authors and do not necessarily reflect those of SitePoint.

From Survey Responses to Consumer Insights: Building a Medicaid Consumer Segmentation Pipeline with Python, K-Means, and Tableau

SZ
Shilei Zhang
Published in

Share this article

From Survey Responses to Consumer Insights: Building a Medicaid Consumer Segmentation Pipeline with Python, K-Means, and Tableau
SitePoint Premium
Stay Relevant and Grow Your Career in Tech
  • Premium Results
  • Publish articles on SitePoint
  • Daily curated jobs
  • Learning Paths
  • Discounts to dev tools
Start Free Trial

7 Day Free Trial. Cancel Anytime.

From Survey Responses to Consumer Insights: Building a Medicaid Consumer Segmentation Pipeline with Python, K-Means, and Tableau

Introduction

Healthcare organizations collect enormous amounts of consumer experience data, but much of it is still analyzed using simple averages and summary reports.

One of the most valuable sources of consumer feedback is the Consumer Assessment of Healthcare Providers and Systems (CAHPS) survey. Used by Medicaid managed care organizations, Medicare Advantage plans, and other healthcare programs, CAHPS measures members' experiences with their health plans, providers, customer service, and access to care.

Most organizations build dashboards that answer questions such as:

What is our average Overall Rating?

How many members completed the survey?

Which county has the highest satisfaction score?

While these metrics are useful, they rarely answer a more important question:

Do different groups of members have different healthcare needs?

For example, two members may both rate their health plan a "7," but for completely different reasons.

One may be satisfied with clinical care but frustrated by customer service.

Another may struggle to find providers within the network.

A third may simply need more education about available benefits.

If we treat every member the same, outreach campaigns become less effective.

Instead, we can use machine learning to identify natural groups of consumers and tailor communication based on their characteristics.

In this tutorial, we'll build a simple consumer segmentation pipeline using Python, Scikit-learn, and K-Means clustering, then prepare the results for visualization in Tableau.

Why Consumer Segmentation Matters

Healthcare organizations spend significant resources on member outreach:

Preventive care reminders

Renewal notices

Wellness campaigns

Care management

Customer service follow-up

However, sending identical communications to every member rarely produces the best results.

Consumer segmentation allows organizations to answer questions such as:

Which members are highly engaged?

Which members require additional education?

Which members frequently contact customer service?

Which populations may benefit from care management?

Rather than creating one campaign for everyone, organizations can create personalized engagement strategies for each consumer segment.

Understanding the Dataset

For this example, we'll use a simplified CAHPS-style dataset.

import pandas as pd

df = pd.DataFrame({

    "Member_ID":[1001,1002,1003,1004,1005,1006,1007,1008,1009,1010],

    "Age":[26,58,44,67,31,52,61,37,49,29],

    "Overall_Rating":[10,6,8,5,9,7,6,9,8,10],

    "Provider_Communication":[10,5,9,4,9,7,5,8,8,10],

    "Customer_Service":[9,4,8,3,8,6,4,8,7,9],

    "Access_To_Care":[9,5,8,4,9,7,5,8,7,9],

    "Portal_Logins":[18,2,10,1,15,5,2,12,8,20],

    "Call_Center_Contacts":[1,7,3,8,1,4,6,2,3,1]

})

Each row represents a Medicaid member who completed a CAHPS survey.

Our variables include:

VariableDescription
AgeMember age
Overall_RatingOverall health plan rating (0–10)
Provider_CommunicationSatisfaction with providers
Customer_ServiceSatisfaction with customer service
Access_To_CareEase of obtaining healthcare
Portal_LoginsNumber of member portal logins
Call_Center_ContactsNumber of customer service interactions

Although simplified, these variables resemble the types of data healthcare analysts commonly work with.

Step 1: Exploring the Data

Before building any machine learning model, we should understand the dataset.

print(df.info())

print(df.describe())

Check for missing values.

print(df.isnull().sum())

Healthcare survey datasets often contain unanswered questions or incomplete responses.

One common strategy is to replace missing values using the median.

from sklearn.impute import SimpleImputer

imputer = SimpleImputer(strategy="median")

numeric_columns = df.columns.drop("Member_ID")

df[numeric_columns] = imputer.fit_transform(df[numeric_columns])

Step 2: Feature Scaling

Machine learning algorithms perform better when variables are on similar scales.

For example:

Age ranges from 18–90.

Portal logins may range from 0–50.

Survey ratings range from 0–10.

Without normalization, variables with larger values dominate the clustering process.

from sklearn.preprocessing import StandardScaler

features = [

    "Age",

    "Overall_Rating",

    "Provider_Communication",

    "Customer_Service",

    "Access_To_Care",

    "Portal_Logins",

    "Call_Center_Contacts"

]

X = df[features]

scaler = StandardScaler()

X_scaled = scaler.fit_transform(X)

Step 3: Choosing the Number of Clusters

One challenge with K-Means is deciding how many clusters should be created.

A common approach is the Elbow Method.

from sklearn.cluster import KMeans
import matplotlib.pyplot as plt

inertia = []

for k in range(1,8):

    model = KMeans(
        n_clusters=k,
        random_state=42,
        n_init=10
    )

    model.fit(X_scaled)

    inertia.append(model.inertia_)

plt.plot(range(1,8), inertia, marker="o")

plt.xlabel("Number of Clusters")

plt.ylabel("Within Cluster Sum of Squares")

plt.title("Elbow Method")

plt.show()

The point where the curve begins to flatten suggests an appropriate number of clusters.

For this tutorial, we'll use four clusters.

Step 4: Building the K-Means Model

kmeans = KMeans(

    n_clusters=4,

    random_state=42,

    n_init=10

)

df["Cluster"] = kmeans.fit_predict(X_scaled)

Each member now belongs to one of four consumer segments.

View the assignments.

print(

df[

["Member_ID","Cluster"]

]

)

Step 5: Understanding Each Consumer Segment

Cluster numbers alone have little meaning.

Let's calculate the average characteristics for each group.

cluster_summary = df.groupby("Cluster")[features].mean()

print(cluster_summary.round(2))

Example interpretation:

Cluster 0 – Digital Champions

Frequent portal usage

High satisfaction

Rarely contacts customer service

Recommended strategy:

Wellness campaigns

Preventive care reminders

Mobile app enhancements

Cluster 1 – Care Coordination Members

Older population

Lower provider communication scores

Higher healthcare utilization

Recommended strategy:

Care management

Chronic disease support

Provider navigation

Cluster 2 – High Support Members

Low satisfaction

Frequent call center contacts

Lower access-to-care scores

Recommended strategy:

Proactive customer service

Case management

Member advocacy

Cluster 3 – Moderate Engagement Members

Average satisfaction

Moderate digital engagement

Occasional customer service interactions

Recommended strategy:

Benefit education

Annual wellness reminders

Digital engagement campaigns

Step 6: Creating Business-Friendly Personas

Business users rarely think in terms of "Cluster 0" or "Cluster 2."

Instead, convert the clusters into descriptive personas.

persona = {

0:"Digital Champions",

1:"Care Coordination",

2:"High Support",

3:"Moderate Engagement"

}

df["Persona"] = df["Cluster"].map(persona)

Now every member belongs to an easily understandable segment.

Step 7: Preparing Data for Tableau

Export the enriched dataset.

df.to_csv(

"Consumer_Segmentation.csv",

index=False

)

Tableau can now connect directly to this file.

Recommended dashboard layout:

Dashboard 1 – Consumer Overview

KPIs

Total Members

Number of Clusters

Average Overall Rating

Average Portal Logins

Dashboard 2 – Consumer Personas

Visualizations

Cluster Distribution (Bar Chart)

Persona Breakdown (Pie Chart)

Average Satisfaction by Persona

Average Portal Usage by Persona

Dashboard 3 – Geographic Analysis

Maps

Consumer Persona by County

Average Satisfaction by Region

Call Center Contacts by County

Dashboard 4 – Engagement Analysis

Charts

Portal Logins vs Overall Rating

Call Center Contacts vs Satisfaction

Provider Communication by Persona

Using Tableau filters, users can explore:

Age Group

County

Language

Health Plan

Consumer Persona

This allows business users to identify trends without writing SQL or Python.

From Analytics to Action

The goal of clustering is not simply to create groups—it is to improve decision-making.

Instead of sending identical outreach to every Medicaid member, organizations can tailor communication based on consumer needs.

For example:

PersonaRecommended Outreach
Digital ChampionsWellness programs, preventive care reminders
Care CoordinationChronic condition support, provider navigation
High SupportCustomer service follow-up, case management
Moderate EngagementBenefit education, annual renewal reminders

This transforms survey data into actionable consumer insights.

Conclusion

CAHPS survey data contains far more than satisfaction scores. Combined with machine learning, it can reveal meaningful patterns in consumer behavior that traditional dashboards often miss.

In this tutorial, we used Python to clean and prepare survey data, standardized the variables, applied K-Means clustering to identify consumer segments, interpreted those segments as business personas, and exported the results for visualization in Tableau.

The same workflow can be extended to larger healthcare datasets by incorporating enrollment information, demographic characteristics, healthcare utilization, and digital engagement metrics. As healthcare organizations continue to adopt data-driven decision-making, consumer segmentation provides a practical way to move beyond descriptive reporting and deliver more personalized, member-centered experiences.

© 2000 – 2026 SitePoint Pty. Ltd.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.