Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Preparing a Dataset for Machine Learning | Section
Feature Engineering with PySpark
Section 1. Chapter 9
single

single

Challenge: Preparing a Dataset for Machine Learning

Swipe to show menu

Task

Swipe to start coding

You are given a flights dataset as a list of rows. Load it into a DataFrame using createDataFrame and prepare it for a binary classification task – predicting 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 binary label column LABEL1 if Delay == 1, otherwise 0;
  3. Add IS_WEEKEND1 if DayOfWeek >= 6, otherwise 0;
  4. Apply StringIndexer to AirlineAIRLINE_IDX;
  5. Assemble Length, Time, IS_WEEKEND, and AIRLINE_IDX into a vector column FEATURES;
  6. Store the final DataFrame in ml_df and count its rows in ml_count.

Print ml_count and show all rows of LABEL, AIRLINE_IDX, FEATURES.

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 1. Chapter 9
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

some-alt