Dataset Preparation by Example
California Fire Incidents
Hands-on data exploration and feature engineering
© 2026 WayUp
Exploring Data and understanding the features
MajorIncident - Target (boolean)Latitude / LongitudeCounties - Geographic regionAcresBurned - Fire sizeStarted / ExtinguishedPersonnelInvolvedEngines, HelicoptersStructuresDestroyedWhat is the composition of this dataset?
MajorIncidentfrom Orange.data.pandas_compat import table_from_frame, table_to_frame
df = table_to_frame(in_data)
df = df.drop_duplicates()
out_data = table_from_frame(df)
What is the balance between the two labels?
When one class dominates the other, the model becomes biased:
Drop random data from the majority class:
import pandas as pd
from Orange.data.pandas_compat import table_from_frame, table_to_frame
df = table_to_frame(in_data)
# Separate by class
major = df[df['MajorIncident'] == True]
non_major = df[df['MajorIncident'] == False]
# Undersample majority class
non_major_sampled = non_major.sample(n=len(major), random_state=42)
# Combine
out_data = table_from_frame(pd.concat([major, non_major_sampled]))
3 main strategies:
# Custom imputation
df['AcresBurned'] = df['AcresBurned'].fillna(df['AcresBurned'].median())
df['Counties'] = df['Counties'].fillna('Unknown')
Extract useful features instead of using raw dates:
import pandas as pd
df['Started'] = pd.to_datetime(df['Started'])
# Extract useful features
df['Month'] = df['Started'].dt.month
df['DayOfWeek'] = df['Started'].dt.dayofweek
df['Season'] = df['Month'].map({12:1, 1:1, 2:1, 3:2, 4:2, 5:2,
6:3, 7:3, 8:3, 9:4, 10:4, 11:4})
# Drop original date column
df = df.drop(columns=['Started'])
Enrich with: California Weather Data (1998-2020)
Dataset Preparation
Next: Data Formats
© 2026 WayUp - way-up.io