Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer Challenge: Predicting Flight Delays | Section
Machine Learning with PySpark
Sectie 1. Hoofdstuk 5
single

single

Challenge: Predicting Flight Delays

Veeg om het menu te tonen

Taak

Veeg om te beginnen met coderen

You are given a flights dataset as a list of rows. Load it into a DataFrame using createDataFrame and train a binary classification model to predict whether a flight is delayed (Delay == 1). Complete all steps and store results in the specified variables:

  1. Fill nulls in Delay and Length with 0;
  2. Add a LABEL column – 1.0 if Delay == 1, otherwise 0.0;
  3. Add IS_WEEKEND1 if DayOfWeek >= 6, otherwise 0;
  4. Split into train (80%) and test (20%) with seed=42;
  5. Build a Pipeline with StringIndexer on Airline, VectorAssembler on ["Length", "Time", "IS_WEEKEND", "AIRLINE_IDX"], and RandomForestClassifier with numTrees=10, maxDepth=3, seed=42;
  6. Fit the pipeline and generate predictions on the test set – store in predictions;
  7. Compute AUC-ROC – store in auc_roc (rounded to 4 decimal places);
  8. Compute accuracy – store in accuracy (rounded to 4 decimal places).

Print both metrics.

Oplossing

Switch to desktopSchakel over naar desktop voor praktijkervaringGa verder vanaf waar je bent met een van de onderstaande opties
Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 1. Hoofdstuk 5
single

single

Vraag AI

expand

Vraag AI

ChatGPT

Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.

some-alt