-
Notifications
You must be signed in to change notification settings - Fork 1
/
weak_test.py
95 lines (78 loc) · 3.27 KB
/
weak_test.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import random
from skmultiflow.meta import LearnPPNSEClassifier
from skmultiflow.lazy import KNNClassifier
from skmultiflow.meta import OnlineBoostingClassifier
from skmultiflow.lazy import SAMKNNClassifier
from skmultiflow.lazy import KNNADWINClassifier
from stream.MFCCStream import MFCCStream
from stream.WaveStream import WaveStream
from skmultiflow.prototype import RobustSoftLearningVectorQuantization
from datetime import date
import os
import logging
import argparse
import matplotlib.pyplot as plt
import matplotlib
import pandas as pd
import numpy as np
from sklearn.linear_model import SGDClassifier
from models.CMGMM_Classifier import CMGMMClassifier
from detector.kd3 import KD3
from skmultiflow.evaluation import EvaluatePrequential
from skmultiflow.data import SEAGenerator
from skmultiflow.data import FileStream
import warnings
from skmultiflow.drift_detection import ADWIN
from skmultiflow.drift_detection import DDM
from skmultiflow.drift_detection import EDDM
from skmultiflow.drift_detection import HDDM_A
from skmultiflow.drift_detection import HDDM_W
from skmultiflow.drift_detection import KSWIN
from skmultiflow.drift_detection import PageHinkley
from evaluation.WeakPrequential import WeakEvaluatePrequential
warnings.filterwarnings("ignore")
random.seed(42)
logging.basicConfig(level=logging.WARNING)
parser = argparse.ArgumentParser()
parser.add_argument('-d', '--dataset', required=False,
default="sea_gen", help="Name of Detector {KD3/Adwin/PageHinkley}")
parser.add_argument('-s', '--label_size', required=False,
default=0.25 , help="Name of Detector {KD3/Adwin/PageHinkley}")
args = parser.parse_args()
test_dataset = args.dataset
print("dataset:"+"datasets/"+test_dataset+'.csv')
stream = FileStream("datasets/"+test_dataset+'.csv')
#print(stream.get_target_values())
onlineBoosting = OnlineBoostingClassifier()
knn_adwin = KNNADWINClassifier(
n_neighbors=8, leaf_size=40, max_window_size=1000)
SAMKNN = SAMKNNClassifier(n_neighbors=10, weighting='distance', max_window_size=500,
stm_size_option='maxACCApprox', use_ltm=False)
learn_pp_nse = LearnPPNSEClassifier()
SGD = SGDClassifier()
rslvq = RobustSoftLearningVectorQuantization()
#CMMM2 = CMGMMClassifier(classes=stream.get_target_values(), prune_component=True, drift_detector=None)
#CMMM.train(train_dataset, 'label', 'mfcc')
#
eval = WeakEvaluatePrequential(show_plot=False,
pretrain_size=1500,
batch_size=200,
label_size= float(args.label_size),
metrics=['accuracy', 'f1', 'running_time', 'model_size'])
#eval.evaluate(stream=stream, model=[SGD], model_names=[ 'SVM-SGD'])
#exit()
detector = KD3(window_size=500)
#detector = ADWIN()
CMMM = CMGMMClassifier(classes=stream.get_target_values(),
prune_component=True,
drift_detector=None)
eval.evaluate(stream=stream, model=[
CMMM, SAMKNN, learn_pp_nse, SGD], model_names=['CMGMM', 'SAMKNN', 'LearnPPNSE', "SVM-SGD"])
print(CMMM.adaptasi)
print(eval.psudo_label_accuracy[0])
plt.plot(eval.psudo_label_accuracy[0])
plt.title('model accuracy')
plt.ylabel('Psudo Label accuracy')
plt.xlabel('adaptation')
plt.show(block=True)
print("selesai")