This repository was archived by the owner on Oct 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInspection.py
More file actions
53 lines (35 loc) · 1.46 KB
/
Copy pathInspection.py
File metadata and controls
53 lines (35 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib
from fontTools.ttLib.tables.otTraverse import dfs_base_table
from sklearn.preprocessing import LabelEncoder
import seaborn as sns
student_data = pd.read_csv('Data/StudentData.csv')
df = pd.DataFrame(student_data)
print(df.isna())
le = LabelEncoder() # is the encoder in order to transform the non_numerical values into numerical
non_numeric_cols = df.select_dtypes(include=['object']).columns
for col in non_numeric_cols:
df[col] = le.fit_transform(df[col])
print(df)
df.hist(bins=50, figsize=(20, 10))
# Show the plots
#plt.show()
correlation_matrix = df.corr()
# Print the correlation matrix
print(correlation_matrix)
# Plot the heatmap
plt.figure(figsize=(20, 10)) # Set the figure size for readability
sns.heatmap(correlation_matrix, annot=True, cmap='coolwarm', vmin=-1, vmax=1, linewidths=0.5)
# Display the heatmap
plt.title('Correlation Matrix Heatmap')
#plt.show()
columns = ['Hours_Studied','Attendance','Previous_Scores','Tutoring_Sessions','Exam_Score']
x = df[columns]
directory = 'Data' # Replace with your desired directory path
file_name = 'Needed_data.csv' # Name of the CSV file
file_path = f'{directory}/{file_name}' # Complete file path
# Save the DataFrame as a CSV file
x.to_csv(file_path, index=False) # Set index=False to not include row indices in the CSV
print(f'DataFrame saved as CSV at: {file_path}')