Sektion 1. Kapitel 9
single
Challenge: Preparing a Dataset for Machine Learning
Stryg for at vise menuen
Opgave
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:
- Fill nulls in
DelayandLengthwith0; - Add a binary label column
LABEL–1ifDelay == 1, otherwise0; - Add
IS_WEEKEND–1ifDayOfWeek >= 6, otherwise0; - Apply
StringIndexertoAirline→AIRLINE_IDX; - Assemble
Length,Time,IS_WEEKEND, andAIRLINE_IDXinto a vector columnFEATURES; - Store the final DataFrame in
ml_dfand count its rows inml_count.
Print ml_count and show all rows of LABEL, AIRLINE_IDX, FEATURES.
Løsning
Var alt klart?
Tak for dine kommentarer!
Sektion 1. Kapitel 9
single
Spørg AI
Spørg AI
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat