0
0
SciPydata~30 mins

Kolmogorov-Smirnov test in SciPy - Mini Project: Build & Apply

Choose your learning style9 modes available
Kolmogorov-Smirnov Test with SciPy
📖 Scenario: You are a data analyst working with two sets of data representing customer ratings from two different stores. You want to check if these two sets of ratings come from the same distribution or not.
🎯 Goal: Build a Python program that uses the Kolmogorov-Smirnov test from SciPy to compare two data samples and print the test statistic and p-value.
📋 What You'll Learn
Create two lists of customer ratings with exact values
Import the ks_2samp function from scipy.stats
Use ks_2samp to compare the two lists
Print the test statistic and p-value exactly as shown
💡 Why This Matters
🌍 Real World
The Kolmogorov-Smirnov test helps compare two sets of data to check if they come from the same distribution, useful in quality control and customer feedback analysis.
💼 Career
Data scientists and analysts use this test to validate assumptions about data distributions before building models or making decisions.
Progress0 / 4 steps
1
Create two lists of customer ratings
Create two lists called ratings_store1 and ratings_store2 with these exact values: ratings_store1 = [4, 5, 3, 4, 5, 4, 3, 4] and ratings_store2 = [5, 5, 4, 4, 5, 5, 4, 5].
SciPy
Need a hint?

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

2
Import the Kolmogorov-Smirnov test function
Import the function ks_2samp from the module scipy.stats.
SciPy
Need a hint?

Use the from ... import ... syntax to import ks_2samp.

3
Apply the Kolmogorov-Smirnov test
Use the function ks_2samp with ratings_store1 and ratings_store2 as inputs and save the result in a variable called ks_result.
SciPy
Need a hint?

Call ks_2samp with the two lists as arguments and assign it to ks_result.

4
Print the test statistic and p-value
Print the test statistic and p-value from ks_result using print(f"KS statistic: {ks_result.statistic}") and print(f"p-value: {ks_result.pvalue}").
SciPy
Need a hint?

Use print with f-strings to show the statistic and pvalue attributes of ks_result.