Milestone 3: Data Cleaning & Preprocessing Pipeline
Data Ingestion and Null Handling
In this mission, you are working with the raw Casford Telemetry logs containing intermittent signal loss, resulting in missing entries. Your task is to implement an automated cleaning layer within the Casford Analytics Engine.
Your first objective is to load the raw telemetry data and apply a standard imputation strategy. You must replace numerical missing values (NaN) with the column mean and drop rows where critical status IDs are missing.
import pandas as pd import numpy as np data = {'signal_strength': [10.5, np.nan, 12.3, 11.2, np.nan], 'status_id': [1, 2, np.nan, 4, 5]} df = pd.DataFrame(data) df['signal_strength'] = df['signal_strength'].fillna(df['signal_strength'].mean()) df = df.dropna(subset=['status_id']) print(df)
Feature Scaling for Telemetry Metrics
Telemetry data often spans multiple orders of magnitude. The Casford engine requires normalized inputs to prevent gradient instability during model training.
You are required to implement a Min-Max scaling approach for the signal_strength column, transforming values to a strict range of 0 to 1 based on the minimum and maximum observed in the current session batch.
import pandas as pd df = pd.DataFrame({'signal_strength': [10.0, 20.0, 30.0]}) min_val = df['signal_strength'].min() max_val = df['signal_strength'].max() df['scaled_signal'] = (df['signal_strength'] - min_val) / (max_val - min_val) print(df)
Categorical Encoding for Operational States
The Casford logs include device_type labels (e.g., Sensor_A, Sensor_B, Gateway_X) which are non-numeric strings. The machine learning model cannot process these raw text inputs.
You must apply One-Hot Encoding to the device_type column to convert these states into a binary vector format suitable for neural network layers.
import pandas as pd df = pd.DataFrame({'device_type': ['Sensor_A', 'Sensor_B', 'Sensor_A', 'Gateway_X']}) encoded_df = pd.get_dummies(df['device_type'], prefix='dev') df = pd.concat([df, encoded_df], axis=1) print(df)
Objectives & Tasks
Review the tasks below and follow the interactive instructions to complete this module.
Knowledge Check
Ready to test your understanding of Milestone 3: Data Cleaning & Preprocessing Pipeline?