Challenge: Compare Data Distributions with Seaborn
When you want to compare the performance of different groups—such as classes taking the same test or participants in an experiment—simply looking at averages does not always reveal the whole story. Comparing data distributions allows you to see differences in spread, outliers, and overall patterns. In educational settings, visualizing the test scores from two classes side by side can help identify which class has more consistent results, whether one group has higher outliers, or if both groups share a similar range of scores. Boxplots are a powerful way to summarize and compare these distributions, as they highlight the median, quartiles, and any potential outliers in a compact visual format.
123456789101112131415161718import random import seaborn as sns import matplotlib.pyplot as plt # Generate random test scores for two classes class_a_scores = [random.randint(60, 100) for _ in range(30)] class_b_scores = [random.randint(55, 98) for _ in range(30)] # Prepare data for seaborn data = [class_a_scores, class_b_scores] labels = ["Class A", "Class B"] # Create side-by-side boxplots sns.boxplot(data=data) plt.xticks([0, 1], labels) plt.ylabel("Test Scores") plt.title("Comparison of Test Score Distributions: Class A vs Class B") plt.show()
Swipe to start coding
Write a function that generates two lists of random integers to represent test scores for two different classes. Use seaborn to create side-by-side boxplots comparing the score distributions. Add descriptive labels for the x-axis, y-axis, and a title for the plot.
- Generate a list of 30 random integers between 60 and 100 for the first class.
- Generate a list of 30 random integers between 55 and 98 for the second class.
- Create a side-by-side boxplot comparing the two lists.
- Label the x-axis with the class names, set a label for the y-axis, and add a plot title.
Oplossing
Bedankt voor je feedback!
single
Vraag AI
Vraag AI
Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.
Geweldig!
Completion tarief verbeterd naar 4.76
Challenge: Compare Data Distributions with Seaborn
Veeg om het menu te tonen
When you want to compare the performance of different groups—such as classes taking the same test or participants in an experiment—simply looking at averages does not always reveal the whole story. Comparing data distributions allows you to see differences in spread, outliers, and overall patterns. In educational settings, visualizing the test scores from two classes side by side can help identify which class has more consistent results, whether one group has higher outliers, or if both groups share a similar range of scores. Boxplots are a powerful way to summarize and compare these distributions, as they highlight the median, quartiles, and any potential outliers in a compact visual format.
123456789101112131415161718import random import seaborn as sns import matplotlib.pyplot as plt # Generate random test scores for two classes class_a_scores = [random.randint(60, 100) for _ in range(30)] class_b_scores = [random.randint(55, 98) for _ in range(30)] # Prepare data for seaborn data = [class_a_scores, class_b_scores] labels = ["Class A", "Class B"] # Create side-by-side boxplots sns.boxplot(data=data) plt.xticks([0, 1], labels) plt.ylabel("Test Scores") plt.title("Comparison of Test Score Distributions: Class A vs Class B") plt.show()
Swipe to start coding
Write a function that generates two lists of random integers to represent test scores for two different classes. Use seaborn to create side-by-side boxplots comparing the score distributions. Add descriptive labels for the x-axis, y-axis, and a title for the plot.
- Generate a list of 30 random integers between 60 and 100 for the first class.
- Generate a list of 30 random integers between 55 and 98 for the second class.
- Create a side-by-side boxplot comparing the two lists.
- Label the x-axis with the class names, set a label for the y-axis, and add a plot title.
Oplossing
Bedankt voor je feedback!
single