forked from yunjey/stargan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalyzeResults.py
43 lines (30 loc) · 1.46 KB
/
analyzeResults.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
import pandas as pd
import numpy as np
from sklearn import svm
import csv
def normalizeData(dataMatrix):
distance_mean = np.mean(dataMatrix)
distance_sd = np.std(dataMatrix)
mean_zero = (dataMatrix-distance_mean)/distance_sd
return mean_zero
## Train preparation
trainDistances = pd.read_csv('/home/mikylab/stargan-identity/stargan_identity.bel0/results/trainDistances_bel60.csv')
trainArray = np.asarray(trainDistances)
trainMatrix = trainArray[:, 1:3]
X_train = normalizeData(trainMatrix)
Y_train = trainArray[:, 0]
## Test preparation
# testDistances = pd.read_csv('/home/mikylab/stargan-identity/stargan_identity.hair/results/testDistance720.csv')
# testArray = np.asarray(testDistances)
# testMatrix = testArray[:, 1:8]
# X = normalizeData(testMatrix)
# Y = testArray[:, 0]
#Train an SVM with a weight, then use the trained model to predict on the test set
svm_model= svm.SVC(kernel="linear", probability = True, random_state = 316)
#svm_model = svm.SVC(kernel="rbf", gamma=0.7, C=1.0),
#svm_model = svm.SVC(kernel="poly", degree=3, gamma="auto", C=1.0, probability = True)
svm_model.fit(X_train, Y_train)
predicted_values_train = svm_model.predict_proba(X_train)#[:,1]
#predicted_values = svm_model.predict_proba(X)#[:,1]
np.save("/home/mikylab/stargan-identity/stargan_identity.bel0/results/predicted_beltrain60_lin.npy", predicted_values_train)
#np.save("/home/mikylab/stargan-identity/stargan_identity.hair/results/predicted_test_poly.npy", predicted_values)