60 Mins

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.

Operator Note: Always check for column data types before applying mean imputation to ensure you aren't calculating averages on string categorical IDs.
Python 3
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.

Operator Note: Scaling should be performed after handling missing values to avoid errors caused by null entries during min/max calculation.
Python 3
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.

Operator Note: Remember to drop the original categorical column after encoding to prevent multicollinearity and redundant feature overhead.
Python 3
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)
Lab Overview

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?

Previous
6. Feature Selection Techniques
Locked
Complete Challenge to Unlock
Back