-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_histogram.py
54 lines (35 loc) · 1.09 KB
/
make_histogram.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
48
49
50
51
52
53
54
import argparse
import matplotlib.pyplot as plt
import utils.loader as l
def get_arguments():
"""Gets arguments from the command line.
Returns:
A parser with the input arguments.
"""
# Creates the ArgumentParser
parser = argparse.ArgumentParser(
usage='Loads a .npy fileand creates its histogram.')
parser.add_argument(
'input', help='Path to the .npy file', type=str)
return parser.parse_args()
if __name__ == "__main__":
# Gathers the input arguments
args = get_arguments()
# Gathering variables from arguments
input_array = args.input
# Loads the .npy file
features = l.load_npy(input_array)
# Gathers the number of features
n_features = features.shape[1]
# Creating a matplotlib figure
fig = plt.figure()
# For every possible column
for i in range(n_features):
# Defines the subplot
plt.subplot(1, n_features, i+1)
# Setting up the title
plt.title(f'x[{i}]')
# Creating the histogram
plt.hist(features[:, i])
# Displaying the plot
plt.show()