-
Notifications
You must be signed in to change notification settings - Fork 1
/
BLE_SVM.py
69 lines (59 loc) · 2.13 KB
/
BLE_SVM.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import os
import pandas as pd
import numpy as np
from imblearn.over_sampling import SMOTE
from sklearn import metrics
from sklearn.svm import SVC
os.chdir('/content/gdrive/My Drive/training_testing_data/')
test = pd.read_csv('test_data_rp_3.csv')
X_test = test.iloc[:, :-1]
X_test = X_test.values
Y_test = test.iloc[:, -1:]
Y_test = Y_test.values
Y_test = Y_test.reshape((Y_test.shape[0],))
clf = SVC()
train = pd.read_csv('train_data_rp_3_IMBALANCED.csv')
X_train = train.iloc[:, :-1]
X_train = X_train.values
Y_train = train.iloc[:, -1:]
Y_train = Y_train.values
Y_train = Y_train.reshape((Y_train.shape[0],))
clf = clf.fit(X_train, Y_train)
Y_pred = clf.predict(X_test)
print("IMBALANCED:", metrics.classification_report(Y_test, Y_pred, digits=4))
train = pd.read_csv('train_data_rp_3_SMOTE.csv')
X_train = train.iloc[:, :-1]
X_train = X_train.values
Y_train = train.iloc[:, -1:]
Y_train = Y_train.values
Y_train = Y_train.reshape((Y_train.shape[0],))
clf = clf.fit(X_train, Y_train)
Y_pred = clf.predict(X_test)
print("SMOTE:", metrics.classification_report(Y_test, Y_pred, digits=4))
train = pd.read_csv('train_data_rp_3_ADASYN.csv')
X_train = train.iloc[:, :-1]
X_train = X_train.values
Y_train = train.iloc[:, -1:]
Y_train = Y_train.values
Y_train = Y_train.reshape((Y_train.shape[0],))
clf = clf.fit(X_train, Y_train)
Y_pred = clf.predict(X_test)
print("ADASYN:", metrics.classification_report(Y_test, Y_pred, digits=4))
train = pd.read_csv('train_data_rp_3_VAE.csv')
X_train = train.iloc[:, :-1]
X_train = X_train.values
Y_train = train.iloc[:, -1:]
Y_train = Y_train.values
Y_train = Y_train.reshape((Y_train.shape[0],))
clf = clf.fit(X_train, Y_train)
Y_pred = clf.predict(X_test)
print("VAE:", metrics.classification_report(Y_test, Y_pred, digits=4))
train = pd.read_csv('train_data_rp_3_CVAE.csv')
X_train = train.iloc[:, :-1]
X_train = X_train.values
Y_train = train.iloc[:, -1:]
Y_train = Y_train.values
Y_train = Y_train.reshape((Y_train.shape[0],))
clf = clf.fit(X_train, Y_train)
Y_pred = clf.predict(X_test)
print("CVAE:", metrics.classification_report(Y_test, Y_pred, digits=4))