forked from WilsonYangLiu/Relief
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.py
More file actions
31 lines (26 loc) · 709 Bytes
/
tests.py
File metadata and controls
31 lines (26 loc) · 709 Bytes
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
"""
Unit tests for ReliefF.
"""
from ReliefF import ReliefF
import csv, os
import numpy as np
if __name__ == '__main__':
#os.chdir(r'E:/Project_ML/ReliefF')
with open(r'data/liver.csv', 'rb') as csvfile:
spamreader = csv.reader(csvfile)
liver = np.array(list(spamreader))
data = (liver[1:, :-2]).astype(np.float64)
labels = (liver[1:, -2]).astype(np.int8)
fs = ReliefF(n_features_to_keep=10)
fs.fit(data, labels)
data_trans = fs.transform(data)
'''
tmp = np.array([[ 1.61311827, 0.19955703],
[-0.21997067, 0.86474714],
[-0.58658846, -1.46341823],
[-1.31982404, -0.79822813],
[ 0.5132649 , 1.19734219]])
y = np.array([1, 1, 1, 2, 2])
fs = ReliefF(2)
fs.fit(tmp, y)
'''