Seksjon 1. Kapittel 9
single
Challenge: Preparing a Dataset for Machine Learning
Sveip for å vise menyen
Oppgave
Sveip for å begynne å kode
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
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 1. Kapittel 9
single
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår