-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpair_plot.py
More file actions
46 lines (38 loc) · 1.18 KB
/
pair_plot.py
File metadata and controls
46 lines (38 loc) · 1.18 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
import csv
import pandas as pd
import seaborn as sns
import ml_functions as ml
csvfile = open('assets/dataset_train.csv')
rawdata = list(csv.reader(csvfile))
# Features: modify indexFeatures according to the dataset
indexFeatures = 6
lenFeatures = len(rawdata[0]) - indexFeatures
features = [] * lenFeatures
for i in range(len(rawdata[0]) - indexFeatures):
features.append(rawdata[0][i + indexFeatures])
features.append(rawdata[0][1])
del rawdata[0]
marks = []
# Get data
for i in range(lenFeatures + 1):
marks.append([])
for row in rawdata:
if ml.isFormatted(row):
marks[lenFeatures].append(row[1])
for i in range(lenFeatures):
marks[i].append(float(row[i + indexFeatures]))
# Normalize
for i in range(lenFeatures):
minV, maxV = ml.getMinMax(marks[i])
marks[i] = ml.normalizeData(marks[i], minV, maxV)
# Prepare data for pair plot
pairplot = []
for i in range(len(marks[0])):
tmp = []
for j in range(lenFeatures + 1):
tmp.append(marks[j][i])
pairplot.append(tmp)
# Plot
pairplot = pd.DataFrame(pairplot, columns=features)
sns_plot = sns.pairplot(pairplot, size=2.5, hue=features[lenFeatures])
sns_plot.savefig("pair_plot.png")