- Lab
-
Libraries: If you want this lab, consider one of these libraries.
- Data
Analyze Relationships in Data using Correlation
In this lab, you'll explore how numeric variables relate in a real dataset using scatter plots, Pearson correlation, and correlation matrices. You'll learn to read visual and numeric evidence together, recognize relationships that deserve caution, and judge which variable pairs are worth further modeling work.
Lab Info
Table of Contents
-
Challenge
Step 1: Load and inspect the dataset
Correlation analysis starts with clean, well-understood data. In this lab, you will build a Python script that loads employee operational metrics, inspects the table structure, and isolates the numeric columns you will analyze later.
The lab's codebase lives in the
applicationdirectory. You will work primarily inanalysis.py, which already contains function stubs, anddata/metrics.csv, which holds the dataset.The first row lists the dataset's column names, followed by a sample of the employee operational metrics you will analyze.
By the end of this step, the CSV will be loaded into a pandas DataFrame, and you will have a definitive list of numeric columns for correlation work.
Note: The functions in
analysis.pyare intentionally incomplete. For each task, implement the required functionality and replace the existingraise NotImplementedError(...)statement.info> Feeling stuck? Check out the matching
solution/stepN/folder for the step you're on to see a working implementation. Give it a try on your own first. The solution folder is your safety net, not your starting point. The dataset is located atapplication/data/metrics.csv. Before loading it with pandas, inspect the first few rows to become familiar with its columns.In the Terminal, run:
cd /home/ps-user/workspace/application head data/metrics.csvThe first row lists the dataset's column names, followed by a sample of the employee operational metrics you will analyze.
-
Challenge
Step 2: Visualize variable pairs with scatter plots
With the dataset loaded and the numeric columns identified, you can inspect relationships visually. A scatter plot reveals the direction and strength of a relationship and helps you determine whether a linear pattern is plausible before you compute a correlation coefficient.
Here, you'll add plotting support with
matplotliband save scatter plots for two variable pairs the analytics team wants to analyze: income versus performance, and tenure versus support call volume. -
Challenge
Step 3: Calculate Pearson correlation coefficients
Visual patterns are useful, but Pearson correlation puts a numeric value on linear association. Values range from -1 to 1, where values near 1 or -1 indicate strong linear relationships and values near 0 indicate weak linear relationships.
In this step, you will compute Pearson coefficients for the same variable pairs you plotted so your visual read can be checked against a standard metric.
-
Challenge
Step 4: Build and interpret a correlation matrix
Individual pair coefficients answer targeted questions, but a correlation matrix shows every numeric relationship at once. Heatmaps make it easy to spot clusters of strong positive or negative associations across all variables.
Here, you will build a full matrix from your numeric columns and save a seaborn heatmap for quick visual comparison.
-
Challenge
Step 5: Summarize findings and assess modeling potential
The analytics team needs more than charts and coefficients. They need a structured assessment: which relationships are strongest, which are weakest, which high correlation might be misleading, and which variables are the best candidates for a future predictive model.
In this final step, you will add summary functions, then run the already wired pipeline to see the full report. A complete pipeline ties loading, plotting, correlation, and reporting into one script the team can rerun as new data arrives.
main()is already wired up to call the functions you built throughout this lab: it loads the dataset, generates both scatter plots, computes correlations, builds the matrix, saves the heatmap, and prints the summary, caution note, and predictor recommendations.With Tasks 5.1 through 5.3 complete, run the full pipeline in the Terminal:
python3 analysis.py -
Challenge
Lab Complete
You built a correlation analysis script that loads operational metrics, visualizes relationships with scatter plots and a correlation heatmap, quantifies relationships using Pearson correlation coefficients, and generates a concise summary of the results. You practiced comparing visual patterns with numeric correlation values, identifying relationships across multiple variables, and recognizing when a strong correlation should be interpreted with caution.
These skills transfer directly to exploratory data analysis: use visualizations to explore the data, confirm observations with correlation coefficients, compare relationships across variables with a correlation matrix, and always consider the context before drawing conclusions from the numbers.
About the author
Real skill practice before real-world application
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Learn by doing
Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.
Follow your guide
All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.
Turn time into mastery
On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.