Comprehensive Exercise on Segmentation Analysis#
One extremely helpful application of Machine Learning is in data exploration and segementation analysis. Clustering algorithms help us find fundamental structures in data that is unknown to us, e.g., whether individual data points have any similarities that we do not yet recognize.
Let’s try this out on a dataset about demographics, health metrics, and engagement patterns of patients.
We will use the Patient Segmentation Dataset from Kaggle (CC0: Public Domain).
The dataset contains 2000 patient records with comprehensive information including:
Demographics like age, gender, geographic location
Health metrics like height, weight, chronic conditions
Healthcare utilization like annual visit frequency
Insurance & engagement like insurance type, preventive care participation flag
The goal is to apply clustering on the patient data for a so-called Segmentation Analysis for identifying distinct patient personas (e.g., “High-risk seniors”, “Young healthy adults”, “Chronic disease patients”).
Your tasks:
Load the data from the file patient_segmentation_dataset.csv
Inspect the data and make yourself familiar with its content, data types, distributions, etc.
Decide for a fitting clustering algorithm based on your data insights (e.g., can KMeans be used for this specific data?)
Prepare the data for clustering and apply the clustering algorithm. Compare different clustering algorithms.
Explore the clusters (patient segments) to gain helpful insights
Use of the AI assistant
It’s best to approach this analysis in a structured way:
Provide the assistant with an overview and your overall analysis goal
Ask for an analysis plan with separate steps
Then, use the assistant to tackle each step, always provide sufficient context
# Import bia-bob as a helpful Python & Medical AI expert
from bia_bob import bob
import os
bob.initialize(
endpoint='https://kiara.sc.uni-leipzig.de/api/v1',
model="vllm-llama-4-scout-17b-16e-instruct",
system_prompt=os.getenv('SYSTEM_PROMPT_MEDICAL_AI')
)
%bob Who are you ? Just 1 sentence!
# ToDo