In our first lesson, we established a conceptual bridge connecting your predictive maintenance project to the familiar territory of actuarial risk modeling. Now, it's time to move from theory to practice and get our hands on the data.
This lesson is your first direct encounter with the EVIoT dataset. We will load it into a Python environment and perform an initial "health check." This process, known as data profiling, is the foundational step of any data science project. You will learn to inspect the dataset's overall structure, verify the types of data it contains, and generate high-level statistical summaries. By the end of this lesson, you will have a clear, quantitative understanding of the data you'll be working with for your thesis.
Step 1: Loading and Initial Inspection
Before we can analyze anything, we need to load the data into a structure that Python can manipulate. The universally adopted tool for this in Python is the pandas library, which provides a powerful object called a DataFrame. A DataFrame is essentially a table, much like a spreadsheet or a database table, that is optimized for data analysis.
Let's begin by loading the EVIoT dataset and performing the most basic checks: its size and column names.
Exploratory Data Analysis with Pandas Python
This video from Rob Mulla's "Exploratory Data Analysis with Pandas Python" series provides a concise walkthrough of the first steps in data inspection.
Please watch the segment from loading and initial inspection. It covers: Loading a CSV file with pd.read_csv(). Checking the dimensions (rows, columns) with .shape. Viewing the first few rows with .head(). Listing all column names with .columns.
Now, let's apply this to your project. Assuming you have downloaded the EVIoT dataset from Kaggle and placed it in your working directory as eviot_dataset.csv, you can start your analysis.
# Import the pandas library
import pandas as pd
import numpy as np # Often imported with pandas for numerical operations
# Load the dataset into a pandas DataFrame
# We'll name our DataFrame 'df' by convention
df = pd.read_csv('eviot_dataset.csv')
# 1. Check the shape of the DataFrame
print("Dataset Shape:", df.shape)
# 2. Display the first 5 rows to see what the data looks like
print("\nFirst 5 Rows:")
print(df.head())
# 3. List all the column names
print("\nColumn Names:")
print(df.columns)
Running this code should confirm that you have 175,393 records (rows) and a set of features (columns), just as described in the research literature you'll be referencing.
Step 2: Understanding the Data Structure with .info()
The .head() command gives us a glimpse, but we need a more systematic summary. Specifically, we need to know what kind of data each column holds (e.g., numbers, text, dates) and whether any data is missing. The .info() method in pandas is perfect for this. It provides a concise summary of the DataFrame, including the data type (Dtype) of each column and the count of non-null values.
Exploratory Data Analysis with Python | PANDAS
The video "Exploratory Data Analysis with Python | PANDAS" by Mo Chen has an excellent, clear explanation of how to use and interpret the output of the .info() method.
Watch the segment from using the .info() function. The presenter effectively breaks down what each part of the output means, especially the Non-Null Count and Dtype.
Let's run this on our EVIoT dataset.
# Get a concise summary of the DataFrame
df.info()
The output of df.info() is dense with crucial information.
- Dtype: This tells you how pandas "sees" each column. You'll see types like
float64(decimal numbers),int64(whole numbers), andobject(typically strings/text). Verifying these is critical. For example, ifbattery_temperature_cwere anobject, you couldn't perform mathematical calculations on it. - Non-Null Count: This is your first look at data quality. If a column's non-null count is less than the total number of entries (175,393), it means you have missing data to deal with—a topic we'll tackle in the next lesson.
Step 3: Generating Descriptive Statistics
Now that we understand the dataset's structure, let's get a feel for the values within it. For numerical columns, we want to understand their central tendency (mean, median), spread (standard deviation), and range (min, max). This is second nature in actuarial work when analyzing loss data or policy information. The .describe() method provides all of this in one go.
Exploratory Data Analysis with Pandas Python
Let's return to Rob Mulla's video. He gives a great practical demonstration of the .describe() method.
Watch the portion of the video from covering the describe function. He explains how it provides key statistics for all numerical columns.
Applying this to our data:
# Generate descriptive statistics for numerical columns
# Using .T transposes the output, making it easier to read with many columns
df.describe().T
Actuarial Connection:
Think of the output of .describe() as a portfolio summary.
count: The number of exposures or policies.mean: The average value, like average motor temperature or average State of Health (SoH).std(Standard Deviation): A measure of volatility or risk. A highstdinmotor_vibration_dbmight indicate a wide range of operating conditions or signal potential instability.minandmax: The range of your data. Looking at themaxfor a feature likebattery_temperature_ccan quickly tell you about extreme events in your data, analogous to looking for the largest claim in a loss history. The25%,50%(median), and75%values give you a sense of the distribution's shape.
For a more complete picture, you can also use .describe() on the non-numeric columns.
# Generate descriptive statistics for categorical ('object') columns
df.describe(include=['object']).T
This will show you the number of unique values (unique), the most frequent value (top), and its frequency (freq) for any text-based columns.
Step 4: Profiling the Target Variables
Your thesis focuses on predicting Failure_Probability_FP and RUL. Let's profile them specifically. Since Failure_Probability_FP is likely a score or a binary indicator, .value_counts() is an excellent tool to see its distribution. For the continuous RUL variable, .describe() is more appropriate.
# Profile the 'Failure_Probability_FP' target variable
print("Distribution of Failure Probability:")
print(df['Failure_Probability_FP'].value_counts(normalize=True)) # normalize=True gives percentages
# Profile the 'RUL' target variable
print("\nSummary Statistics for RUL:")
print(df['RUL'].describe())
When you run the value_counts() for failure probability, you will likely observe a significant class imbalance. This means that failure events are rare compared to normal operation. This is a critical finding. In actuarial science, this is the norm; for example, the number of insurance policies that result in a total-loss claim is a tiny fraction of the total portfolio. This imbalance has major implications for how you'll build and evaluate your models later in this course.
For a more comprehensive guide that recaps all the steps we've covered, you can refer to the following article.
Exploratory Data Analysis (EDA) Using Python
This article from Analytics Vidhya provides a step-by-step guide to the fundamentals of Exploratory Data Analysis (EDA) using Python. It covers the core concepts we've put into practice.
Read through the introductory sections to solidify your understanding of EDA. Then, focus on the code and explanations in: Step 1, which shows the standard library imports. Step 2, which covers loading data and using .head(), .info(), and .isnull().sum() for initial checks. Step 8, which details the use of .describe() for statistical summaries.
Practice Exercise
Now it's your turn to apply these functions. Your task is to perform a mini-profiling of the battery-related features in the dataset.
Instructions:
- Create a new DataFrame containing only the following columns:
vehicle_id,State_of_Health,battery_temperature_c,battery_voltage_v,battery_current_a. - Display the
.info()summary for this new, smaller DataFrame. - Generate the descriptive statistics for this subset using
.describe(). - Count the number of unique values in the
State_of_Healthcolumn. - Print the mean value of the
battery_temperature_ccolumn.
# Your code here
# 1. Create a subset DataFrame
battery_df = df[['vehicle_id', 'State_of_Health', 'battery_temperature_c', 'battery_voltage_v', 'battery_current_a']]
# 2. Display info summary
battery_df.info()
# 3. Generate descriptive statistics
print("\nBattery Stats:")
print(battery_df.describe())
# 4. Count unique SoH values
print("\nUnique SoH values:", battery_df['State_of_Health'].nunique())
# 5. Print mean battery temperature
print("\nMean Battery Temperature:", battery_df['battery_temperature_c'].mean())
Conclusion
In this lesson, you took the crucial first step from theory to practice. You loaded the EVIoT dataset and used fundamental pandas commands to conduct an initial investigation, much like an actuary would perform an initial review of a new data portfolio.
Key Takeaways:
- Data Loading & Inspection: You can now use
pd.read_csv(),.shape,.head(), and.columnsto get your data into Python and see its basic structure. - Data Profiling: You are able to use
.info()to check data types and null counts, and.describe()to get a statistical summary of your numerical and categorical features. - Target Variable Analysis: You've seen how to use
.value_counts()and.describe()to profile your specific target variables (Failure_Probability_FP,RUL) and have identified the critical concept of class imbalance.
Our initial profiling with .info() has already hinted at the presence of missing values in some columns. In the next lesson, we will address this head-on, exploring strategies to identify and handle these missing data points, which is a critical step in preparing a clean dataset for modeling.