-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsampling.py
More file actions
46 lines (34 loc) · 1.12 KB
/
sampling.py
File metadata and controls
46 lines (34 loc) · 1.12 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 numpy as np
from pprint import pprint
from utils.DataLoader import DataLoader
from utils.DimensionalityReducer import DimensionalityReducer
from utils.Sampler import Sampler
from utils.plot import plotScatter
from utils import Expressions
from validation.Analyzer import Analyzer
print("Imported modules")
dataLoader = DataLoader("dataset4")
dimReducer = DimensionalityReducer()
analyzer = Analyzer()
print("data loaded")
#%%
healthy = dataLoader.getData(["healthy"], ["THCA","SARC","LUAD","GBM"])
#sick = dataLoader.getData(["sick"], ["THCA","GBM"])
gene_labels = dataLoader.getGeneLabels()
print("got combined data")
# %%
selected_genes = dimReducer.getFeatures(healthy)
print("Unsampled")
plotScatter(healthy, selected_genes, gene_labels)
# %%
sampler = Sampler()
print("Standard Sampling")
sampled = sampler.over_sample(healthy, change_labels=True)
plotScatter(sampled, selected_genes, gene_labels)
#%%
samples = sampler.get_different_samples(healthy)
methods = sampler.get_sample_methods()
for index, sample in enumerate(samples):
print("Method: " + methods[index])
plotScatter(sample, selected_genes, gene_labels)