Sezione 1. Capitolo 9
single
Challenge: Customer Segmentation
Scorri per mostrare il menu
Compito
Scorri per iniziare a programmare
You are given a flights dataset as a list of rows. Load it into a DataFrame using createDataFrame and segment airlines by their operational profile using K-Means clustering. Complete all steps and store results in the specified variables:
- Fill nulls in
DelayandLengthwith0; - Aggregate by
Airlineto compute:AVG_DELAY– averageDelay;AVG_LENGTH– averageLength;TOTAL_FLIGHTS– count of flights. Store the result inairline_df;
- Build a Pipeline with
VectorAssembleron["AVG_DELAY", "AVG_LENGTH", "TOTAL_FLIGHTS"]andKMeanswithk=3,seed=42,maxIter=5– no scaling needed; - Fit the pipeline and transform
airline_df– store the result inclustered_df; - Store the number of rows per cluster as a list of tuples
[(cluster_id, count), ...]sorted bycluster_idincluster_counts.
Print cluster_counts and show clustered_df sorted by prediction.
Soluzione
Tutto è chiaro?
Grazie per i tuoi commenti!
Sezione 1. Capitolo 9
single
Chieda ad AI
Chieda ad AI
Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione