-
Notifications
You must be signed in to change notification settings - Fork 4
/
drift.py
34 lines (25 loc) · 1.11 KB
/
drift.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
import numpy as np
import torch
from .DATE import DATESampling
from .hybrid import HybridSampling
from utils import timer_func
class DriftSampling(HybridSampling):
def __init__(self, args):
super(DriftSampling,self).__init__(args)
assert len(self.subsamps) == 2
# self.data already exists - In main.py, we declared in: sampler.set_data(data)
def generate_DATE_embeddings(self):
date_sampler = DATESampling(self.args)
date_sampler.set_data(self.data)
date_sampler.train_xgb_model()
date_sampler.prepare_DATE_input()
date_sampler.train_DATE_model()
valid_embeddings = torch.stack(date_sampler.get_embedding_valid()) # Embeddings for validation data
test_embeddings = torch.stack(date_sampler.get_embedding_test()) # Embeddings for test data
return valid_embeddings, test_embeddings
def concept_drift(self):
pass
@timer_func
def update_subsampler_weights(self):
self.dms_weight = round(self.concept_drift(), 2)
self.weights = [1 - self.dms_weight, self.dms_weight]