0
0
SciPydata~15 mins

Correlation (correlate) in SciPy - Mini Project: Build & Apply

Choose your learning style9 modes available
Calculate Correlation Using scipy.correlate
📖 Scenario: You are analyzing two simple time series data sets representing daily sales of two products in a small store. You want to find how these two sales patterns relate to each other by calculating their correlation.
🎯 Goal: Build a Python program that uses scipy.correlate to find the correlation between two lists of sales data.
📋 What You'll Learn
Create two lists named sales_product_a and sales_product_b with exact daily sales values.
Create a variable named mode with the value 'full' to configure the correlation.
Use scipy.correlate with sales_product_a, sales_product_b, and mode to calculate the correlation and store it in correlation_result.
Print the correlation_result to see the correlation values.
💡 Why This Matters
🌍 Real World
Correlation helps find relationships between two sets of data, like sales of two products over time, to understand if they move together.
💼 Career
Data scientists and analysts use correlation to find patterns and connections in data, which helps businesses make better decisions.
Progress0 / 4 steps
1
Create sales data lists
Create two lists called sales_product_a and sales_product_b with these exact values: sales_product_a = [10, 20, 30, 40, 50] and sales_product_b = [15, 25, 35, 45, 55].
SciPy
Need a hint?

Use square brackets to create lists and separate numbers with commas.

2
Set correlation mode
Create a variable called mode and set it to the string 'full' to specify the correlation mode.
SciPy
Need a hint?

Assign the string 'full' to the variable mode.

3
Calculate correlation using scipy.correlate
Import correlate from scipy.signal. Then use correlate with sales_product_a, sales_product_b, and mode to calculate the correlation. Store the result in a variable called correlation_result.
SciPy
Need a hint?

Use from scipy.signal import correlate to import. Then call correlate() with the two lists and the mode.

4
Print the correlation result
Write a print statement to display the value of correlation_result.
SciPy
Need a hint?

Use print(correlation_result) to show the correlation values.