Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Challenge: Customer Segmentation | Section
Machine Learning with PySpark
Seção 1. Capítulo 9
single

single

Challenge: Customer Segmentation

Deslize para mostrar o menu

Tarefa

Deslize para começar a programar

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:

  1. Fill nulls in Delay and Length with 0;
  2. Aggregate by Airline to compute:
    • AVG_DELAY – average Delay;
    • AVG_LENGTH – average Length;
    • TOTAL_FLIGHTS – count of flights. Store the result in airline_df;
  3. Build a Pipeline with VectorAssembler on ["AVG_DELAY", "AVG_LENGTH", "TOTAL_FLIGHTS"] and KMeans with k=3, seed=42, maxIter=5 – no scaling needed;
  4. Fit the pipeline and transform airline_df – store the result in clustered_df;
  5. Store the number of rows per cluster as a list of tuples [(cluster_id, count), ...] sorted by cluster_id in cluster_counts.

Print cluster_counts and show clustered_df sorted by prediction.

Solução

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 9
single

single

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

some-alt