Osio 1. Luku 9
single
Challenge: Customer Segmentation
Pyyhkäise näyttääksesi valikon
Tehtävä
Pyyhkäise aloittaaksesi koodauksen
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.
Ratkaisu
Oliko kaikki selvää?
Kiitos palautteestasi!
Osio 1. Luku 9
single
Kysy tekoälyä
Kysy tekoälyä
Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme