-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_feature_extraction.py
35 lines (30 loc) · 1.28 KB
/
test_feature_extraction.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
# -*- coding: utf-8 -*-
import os
import random
import unittest
import pandas as pd
class FeatureExtractionTestCase(unittest.TestCase):
def setUp(self):
start = os.getcwd()
# load dataframe with computed features, test will ot work without
self.df_features = pd.read_pickle('df_features.pkl')
self.randlist = []
for i in range(200):
self.randlist.append(random.randint(0, len(self.df_features)))
# load ground truth data
path_txt = start + "\\ISM"
train_txt = open(path_txt + "\\train.txt", "r")
self.ground_truth = train_txt.readlines()
train_txt.close()
def test_diagnosis(self):
for index in self.randlist:
name = self.df_features.loc[index]['file_name']
for line in self.ground_truth:
if line.split(" ")[0] == name:
self.assertEqual(line.split(" ")[1], self.df_features.loc[index]['diagnosis'])
def test_entries_unique(self):
for index in self.randlist:
name = self.df_features.loc[index]['file_name']
for j in range( len(self.df_features)):
if j != index:
self.assertNotEqual(self.df_features.loc[j]['file_name'], name)