iaravagni commited on
Commit
2916efe
·
1 Parent(s): 0138e0d
Files changed (3) hide show
  1. README.md +14 -5
  2. dataset-eda.py +110 -0
  3. dataset/scores_summary.csv +1 -7
README.md CHANGED
@@ -36,11 +36,20 @@ The dataset comprises 20 participant records with:
36
  The recommended sample size is 52 participants; however, this dataset currently contains 20, representing a shortfall of 32 participants.
37
 
38
  ## Exploratory Data Analysis
39
- Score Distribution:
40
- - Mean total score: 2.65
41
- - Most common diagnosis: Absence of brain impairment (14 cases)
42
- - Borderline cases: 5
43
- - Strong evidence for brain impairment: 1 case
 
 
 
 
 
 
 
 
 
44
 
45
  ## Data Collection Protocol
46
  Participants were recruited from Duke University and through social media to ensure broad outreach. Only candidates aged 18 and older were accepted. The data collection process involved the following steps:
 
36
  The recommended sample size is 52 participants; however, this dataset currently contains 20, representing a shortfall of 32 participants.
37
 
38
  ## Exploratory Data Analysis
39
+ ### Dataset Overview:
40
+ The dataset consists of 20 records, each representing a participant's test results and demographic information:
41
+ - Mean Total Score: 2.65
42
+ - Most Common Diagnosis: Absence of brain impairment (14 cases)
43
+ - Borderline Cases: 5
44
+ - Strong Evidence for Brain Impairment: 1 case
45
+
46
+
47
+ ### Visualizations:
48
+ - Bar chart for diagnosis: A bar chart was created to visualize the distribution of diagnoses, with the majority of participants having no brain impairment.
49
+ - Boxplot of Total Scores by Education Level: Shows how total scores vary across different education levels, providing insight into potential patterns related to cognitive skills and educational background.
50
+ - Boxplot of Total Scores by Previous Test Experience: Examines how prior experience with the test might influence scores, revealing differences between those who have taken the test before and those who have not.
51
+ - Most common error: A bar plot comparing the total value per error, showing which factors tend to have the most significant impact on the scores.
52
+
53
 
54
  ## Data Collection Protocol
55
  Participants were recruited from Duke University and through social media to ensure broad outreach. Only candidates aged 18 and older were accepted. The data collection process involved the following steps:
dataset-eda.py ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import seaborn as sns
3
+ import matplotlib.pyplot as plt
4
+ import pytest
5
+
6
+ # Paths to the dataset files
7
+ scores_file = 'dataset/scores_summary.csv'
8
+ metadata_file = 'dataset/metadata.csv'
9
+
10
+ # Read both datasets
11
+ scores_df = pd.read_csv(scores_file)
12
+ metadata_df = pd.read_csv(metadata_file)
13
+
14
+ # Merge the datasets on 'id'
15
+ df = pd.merge(scores_df, metadata_df, on='id')
16
+
17
+ # Basic dataset info
18
+ print("Dataset Info:")
19
+ print(df.info())
20
+ print("\nSummary Statistics:")
21
+ print(df.describe())
22
+ print("\nMissing Values:")
23
+ print(df.isnull().sum())
24
+
25
+ # Distribution of diagnoses
26
+ plt.figure(figsize=(10, 6))
27
+ df['diagnose'].value_counts().plot(kind='bar')
28
+ plt.title('Distribution of Diagnoses')
29
+ plt.xlabel('Diagnosis')
30
+ plt.ylabel('Count')
31
+ plt.xticks(rotation=45)
32
+ plt.tight_layout()
33
+ plt.show()
34
+
35
+ # Create the boxplot
36
+ plt.figure(figsize=(10, 6))
37
+ sns.boxplot(data=df, x='education_level', y='total_score')
38
+ plt.title('Total Scores by Education Level')
39
+ plt.xticks(rotation=45)
40
+ plt.xlabel('Education Level')
41
+ plt.ylabel('Total Score')
42
+ plt.tight_layout()
43
+ plt.show()
44
+
45
+ # Taken test before
46
+ plt.figure(figsize=(10, 6))
47
+ sns.boxplot(data=df, x='taken_test_before', y='total_score')
48
+ plt.title('Total Scores by Previous Test Experience')
49
+ plt.xlabel('Has Taken Test Before')
50
+ plt.ylabel('Total Score')
51
+ plt.tight_layout()
52
+ plt.show()
53
+
54
+ # Most common error
55
+ columns_to_plot = [
56
+ 'rotation', 'overlapping_difficulty', 'simplication', 'fragmentation', 'retrogression',
57
+ 'perseveration', 'collision', 'impotence', 'closure_difficulty', 'motor_incoordination',
58
+ 'angulation', 'cohesion', 'time'
59
+ ]
60
+
61
+ mean_values = df[columns_to_plot].sum().sort_values(ascending=False)
62
+
63
+ plt.figure(figsize=(10, 6))
64
+ sns.barplot(x=mean_values.index, y=mean_values.values)
65
+ plt.title('Mean Values of Parameters Ordered from Largest to Smallest')
66
+ plt.xlabel('Parameter')
67
+ plt.ylabel('Mean Value')
68
+ plt.xticks(rotation=45)
69
+ plt.tight_layout()
70
+ plt.show()
71
+
72
+ # --- Pytest for CSV reading ---
73
+ def test_pd_read_scores():
74
+ """Test if the scores CSV is read correctly"""
75
+ scores_df = pd.read_csv(scores_file)
76
+
77
+ # Check if the DataFrame is not empty
78
+ assert not scores_df.empty, "Scores DataFrame is empty"
79
+
80
+ # Check if the required columns exist
81
+ required_columns = [
82
+ 'id', 'rotation', 'overlapping_difficulty', 'simplication', 'fragmentation',
83
+ 'retrogression', 'perseveration', 'collision', 'impotence', 'closure_difficulty',
84
+ 'motor_incoordination', 'angulation', 'cohesion', 'time', 'total_score', 'diagnose'
85
+ ]
86
+ for column in required_columns:
87
+ assert column in scores_df.columns, f"Column '{column}' not found in scores DataFrame"
88
+
89
+ # Check if the number of rows matches the expected value (use len to check row count)
90
+ expected_row_count = 20
91
+ assert len(scores_df) == expected_row_count, f"Expected {expected_row_count} rows, but found {len(scores_df)}"
92
+
93
+ def test_pd_read_metadata():
94
+ """Test if the metadata CSV is read correctly"""
95
+ metadata_df = pd.read_csv(metadata_file)
96
+
97
+ # Check if the DataFrame is not empty
98
+ assert not metadata_df.empty, "Metadata DataFrame is empty"
99
+
100
+ # Check if the required columns exist
101
+ required_columns = ['id', 'age', 'nacionality', 'education_level', 'taken_test_before']
102
+ for column in required_columns:
103
+ assert column in metadata_df.columns, f"Column '{column}' not found in metadata DataFrame"
104
+
105
+ # Check if the number of rows matches the expected value
106
+ expected_row_count = 20
107
+ assert len(metadata_df) == expected_row_count, f"Expected {expected_row_count} rows, but found {len(metadata_df)}"
108
+
109
+ if __name__ == "__main__":
110
+ pytest.main()
dataset/scores_summary.csv CHANGED
@@ -18,10 +18,4 @@ s16,0,1,1,0,0,0,0,0,0,0,0,0,0,2,absence of brain impairment
18
  s17,0,1,1,0,0,1,0,0,1,0,0,0,0,4,borderline
19
  s18,0,1,1,0,0,1,0,0,1,0,0,0,0,4,borderline
20
  s19,0,1,1,0,0,1,0,0,0,0,0,0,0,3,absence of brain impairment
21
- s20,0,1,1,0,0,1,0,0,1,0,0,0,0,4,borderline
22
- ,,,,,,,,,,,,,,,
23
- ,,,,,,,,,,,,,,,
24
- ,,,,,,,,,,,,,,,
25
- ,,,,,,,,,,,,,,,
26
- ,,,,,,,,,,,,,,,
27
- ,,,,,,,,,,,,,,,
 
18
  s17,0,1,1,0,0,1,0,0,1,0,0,0,0,4,borderline
19
  s18,0,1,1,0,0,1,0,0,1,0,0,0,0,4,borderline
20
  s19,0,1,1,0,0,1,0,0,0,0,0,0,0,3,absence of brain impairment
21
+ s20,0,1,1,0,0,1,0,0,1,0,0,0,0,4,borderline