Datasets:
Upload exploratory_data_analysis.py
Browse files
code/exploratory_data_analysis.py
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
import matplotlib.pyplot as plt
|
| 3 |
+
import seaborn as sns
|
| 4 |
+
|
| 5 |
+
# Set seaborn style
|
| 6 |
+
sns.set(style="whitegrid")
|
| 7 |
+
|
| 8 |
+
# Function to plot age distribution
|
| 9 |
+
def plot_age_distribution(df):
|
| 10 |
+
plt.figure(figsize=(8, 5))
|
| 11 |
+
sns.histplot(df['Age'], kde=False, color='skyblue', bins=5)
|
| 12 |
+
plt.title('Age Distribution')
|
| 13 |
+
plt.xlabel('Age')
|
| 14 |
+
plt.ylabel('Count')
|
| 15 |
+
plt.show()
|
| 16 |
+
|
| 17 |
+
# Function to plot gender distribution (Donut Chart)
|
| 18 |
+
def plot_gender_distribution(df):
|
| 19 |
+
gender_counts = df['Gender'].value_counts()
|
| 20 |
+
plt.figure(figsize=(7, 7))
|
| 21 |
+
plt.pie(gender_counts, labels=gender_counts.index, autopct='%1.1f%%', startangle=90,
|
| 22 |
+
colors=sns.color_palette("pastel"))
|
| 23 |
+
plt.title('Gender Distribution')
|
| 24 |
+
plt.gca().set_aspect('equal')
|
| 25 |
+
plt.show()
|
| 26 |
+
|
| 27 |
+
# Function to plot nationality distribution
|
| 28 |
+
def plot_nationality_distribution(df):
|
| 29 |
+
plt.figure(figsize=(8, 5))
|
| 30 |
+
sns.countplot(y=df['Nationality'], palette='coolwarm')
|
| 31 |
+
plt.title('Nationality Distribution')
|
| 32 |
+
plt.gca().set_aspect('equal')
|
| 33 |
+
plt.show()
|
| 34 |
+
|
| 35 |
+
# Function to plot native language distribution
|
| 36 |
+
def plot_native_language_distribution(df):
|
| 37 |
+
plt.figure(figsize=(8, 5))
|
| 38 |
+
sns.countplot(y=df['Native Language'], palette='coolwarm')
|
| 39 |
+
plt.title('Native Language Distribution')
|
| 40 |
+
plt.gca().set_aspect('equal')
|
| 41 |
+
plt.show()
|
| 42 |
+
|
| 43 |
+
# Function to plot familiarity with English distribution
|
| 44 |
+
def plot_familiarity_with_english(df):
|
| 45 |
+
plt.figure(figsize=(8, 5))
|
| 46 |
+
sns.countplot(y=df['Familiarity with English'], palette='coolwarm')
|
| 47 |
+
plt.title('Familiarity with English')
|
| 48 |
+
plt.xlabel('Count')
|
| 49 |
+
plt.ylabel('Familiarity Level')
|
| 50 |
+
plt.show()
|
| 51 |
+
|
| 52 |
+
# Function to plot recording duration distribution
|
| 53 |
+
def plot_duration_distribution(df):
|
| 54 |
+
plt.figure(figsize=(8, 5))
|
| 55 |
+
sns.histplot(df['Duration (secs)'], kde=False, color='coral', bins=10)
|
| 56 |
+
plt.title('Recording Duration Distribution')
|
| 57 |
+
plt.xlabel('Duration (seconds)')
|
| 58 |
+
plt.ylabel('Count')
|
| 59 |
+
plt.show()
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
def main():
|
| 63 |
+
# Load the dataset
|
| 64 |
+
df = pd.read_csv("metadata.csv")
|
| 65 |
+
|
| 66 |
+
# Plot the distributions
|
| 67 |
+
plot_age_distribution(df)
|
| 68 |
+
plot_gender_distribution(df)
|
| 69 |
+
plot_nationality_distribution(df)
|
| 70 |
+
plot_native_language_distribution(df)
|
| 71 |
+
plot_familiarity_with_english(df)
|
| 72 |
+
plot_duration_distribution(df)
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
if __name__ == "__main__":
|
| 76 |
+
main()
|