-
Notifications
You must be signed in to change notification settings - Fork 0
/
scatter_plot.py
47 lines (39 loc) · 1.17 KB
/
scatter_plot.py
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
import sys
import matplotlib.pyplot as plt
from preprocessing import load_data
from utils import get_house_color
def to_scatter(df, x_feature: str, y_feature: str, ax: plt.axes):
""" Plots a scatter plot for the grade repartition between two features,
separated by house.
"""
ax.scatter(
x=df[x_feature],
y=df[y_feature],
c=[
get_house_color(house)
for house in df['Hogwarts House']
],
s=1
)
def main():
try:
if len(sys.argv) != 2:
raise IndexError('Please enter one argument.')
df, features = load_data(sys.argv[1])
features = df.select_dtypes('number').columns.tolist()
for feature in features:
for feature2 in features:
_, ax = plt.subplots()
to_scatter(
df=df,
x_feature=feature,
y_feature=feature2,
ax=ax
)
plt.xlabel(feature)
plt.ylabel(feature2)
plt.show()
except BaseException as e:
print(type(e).__name__, ':', e)
if __name__ == '__main__':
main()