-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscatter_plot.py
More file actions
63 lines (45 loc) · 2.68 KB
/
scatter_plot.py
File metadata and controls
63 lines (45 loc) · 2.68 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
54
55
56
57
58
59
60
61
62
63
from data_describer import load_csv
import numpy as np
import matplotlib.pyplot as plt
def scatter_plot(X, y, legend, xlabel, ylabel):
plt.scatter(X[:327], y[:327], color='red', alpha=0.5) # Grynffindor House
plt.scatter(X[327:856], y[327:856], color='yellow', alpha=0.5) # Hufflepuff House
plt.scatter(X[856:1299], y[856:1299], color='blue', alpha=0.5) # Ravenclaw House
plt.scatter(X[1299:], y[1299:], color='green', alpha=0.5) # Slytherin House
plt.legend(legend, loc='upper right', frameon=False)
plt.xlabel(xlabel)
plt.ylabel(ylabel)
plt.show()
if __name__ == '__main__':
"""
After looking at the PairPlot graph, you will notice that
"Astronomy" and "Defense Against the Dark Arts"
They are the two most similar characteristics
"""
dataset = load_csv('dataset_train.csv')
data = dataset[1:, :]
data = data[data[:, 1].argsort()]
""""Linear Negative Correlation:when Defense Again.. increases, Astromomy tends to decrease."""
# X = np.array(data[:, 7], dtype=float) # get the "Astronomy" row data
# y = np.array(data[:, 9], dtype=float) # get the "Defense Again ..." row data
# legend = ['Grynffindor', 'Hufflepuff', 'Ravenclaw', 'Slytherin'] # set the "Hogwarts House"'s \
# # names manually
# scatter_plot(X, y, legend=legend, xlabel=dataset[0, 7], ylabel=dataset[0, 9])
"""Being bad at magic and good at Flying means 99% that you belong in Grinffindor"""
# X = np.array(data[:, 13], dtype=float) # get the History of Magics row data
# y = np.array(data[:, 18], dtype=float) # get the "Flying ..." row data
# legend = ['Grynffindor', 'Hufflepuff', 'Ravenclaw', 'Slytherin'] # set the "Hogwarts House"'s \
# names manually
# scatter_plot(X, y, legend=legend, xlabel=dataset[0, 13], ylabel=dataset[0, 18])
"""" If they get bad marks in those they belong to 99% to Grynffindor"""
# X = np.array(data[:, 13], dtype=float) # get the "History of Magics" row data
# y = np.array(data[:, 14], dtype=float) # get the "Transfiguration ..." row data
# legend = ['Grynffindor', 'Hufflepuff', 'Ravenclaw', 'Slytherin'] # set the "Hogwarts House"'s \
# # names manually
# scatter_plot(X, y, legend=legend, xlabel=dataset[0, 13], ylabel=dataset[0, 14])
"""Null or weak correlation"""
X = np.array(data[:, 6], dtype=float) # get the "Arithmancy" row data
y = np.array(data[:, 16], dtype=float) # get the "Care of Magical Creatures ..." row data
legend = ['Grynffindor', 'Hufflepuff', 'Ravenclaw', 'Slytherin'] # set the "Hogwarts House"'s \
# names manually
scatter_plot(X, y, legend=legend, xlabel=dataset[0, 6], ylabel=dataset[0, 16])