def test_accuracy_stream(self): stream = SEAGenerator(random_state=42) stream.prepare_for_use() clf = ARSLVQ(sigma=0.5, prototypes_per_class=2, batch_size=5, decay_rate=0.999) evaluator = EvaluatePrequential(show_plot=False, max_samples=20000, batch_size=5) evaluator.evaluate(stream, clf, model_names=['ARSLVQ']) measurements = np.asarray(evaluator.get_measurements()[0])[0] self.assertTrue( measurements.get_accuracy() >= 0.84, msg='Accuracy was {} but has to be greater than 0.84'.format( measurements.get_accuracy())) self.assertTrue( measurements.get_kappa() >= 0.68, msg='Kappa was {} but has to be greater than 0.68'.format( measurements.get_kappa()))
def test_accuracy_stream(self): stream = ConceptDriftStream(stream=SEAGenerator(random_state=112, noise_percentage=0.1), drift_stream=SEAGenerator( random_state=112, classification_function=1, noise_percentage=0.1), random_state=None, position=20000, width=50000) stream.prepare_for_use() clf = GLVQ(prototypes_per_class=6, beta=2, C=None, decay_rate=0.9, gradient_descent="SGD") evaluator = EvaluatePrequential(pretrain_size=1, show_plot=False, max_samples=20000, batch_size=1) evaluator.evaluate(stream, clf, model_names=['GLVQ']) measurements = np.asarray(evaluator.get_measurements()[0])[0] self.assertTrue( measurements.get_accuracy() >= 0.93, msg='Accuracy was {} but has to be greater than 0.93'.format( measurements.get_accuracy())) self.assertTrue( measurements.get_kappa() >= 0.84, msg='Kappa was {} but has to be greater than 0.84'.format( measurements.get_kappa()))
def test_stream(self): stream = SEAGenerator(classification_function = 2, random_state = 112, balance_classes = False, noise_percentage = 0.28) stream.prepare_for_use() evaluator = EvaluatePrequential(show_plot=False,max_samples=5000, restart_stream=True,batch_size=10,metrics=['kappa', 'kappa_m', 'accuracy']) evaluator.evaluate(stream=stream, model=RRSLVQ(prototypes_per_class=4,sigma=10)) measurements = np.asarray(evaluator.get_measurements()[0])[0] self.assertIsNotNone(eval) self.assertTrue(measurements.get_accuracy() >= 0.5, msg='Accuracy was {} but has to be greater than 0.5'. format(measurements.get_accuracy()))
def test_reoccuring(self): s1 = MIXEDGenerator(classification_function = 1, random_state= 112, balance_classes = False) s2 = MIXEDGenerator(classification_function = 0, random_state= 112, balance_classes = False) stream = ReoccuringDriftStream(stream=s1, drift_stream=s2, random_state=None, alpha=90.0, # angle of change grade 0 - 90 position=2000, width=500) stream.prepare_for_use() evaluator = EvaluatePrequential(show_plot=False,batch_size=10, max_samples=1000, metrics=['accuracy', 'kappa_t', 'kappa_m', 'kappa'], output_file=None) eval = evaluator.evaluate(stream=stream, model=OzaBaggingAdwin(base_estimator=KNN())) measurements = np.asarray(evaluator.get_measurements()[0])[0] self.assertIsNotNone(eval) self.assertTrue(measurements.get_accuracy() >= 0.6, msg='Accuracy was {} but has to be greater than 0.6'. format(measurements.get_accuracy()))
def test_accuracy_stream(self): stream = SEAGenerator(random_state=42) stream.prepare_for_use() clf = GRLVQ(prototypes_per_class=2, regularization=5.0, beta=2, C=None) evaluator = EvaluatePrequential(pretrain_size=1, show_plot=False, max_samples=20000, batch_size=1) evaluator.evaluate(stream, clf, model_names=['GRLVQ']) measurements = np.asarray(evaluator.get_measurements()[0])[0] self.assertTrue( measurements.get_accuracy() >= 0.7, msg='Accuracy was {} but has to be greater than 0.7'.format( measurements.get_accuracy())) self.assertTrue( measurements.get_kappa() >= 0.3, msg='Kappa was {} but has to be greater than 0.3'.format( measurements.get_kappa()))
from skmultiflow.data.sea_generator import SEAGenerator from rslvq import RSLVQ from adaptive_rslvqs_batch import RSLVQ as BARSLVQ from skmultiflow.evaluation.evaluate_prequential import EvaluatePrequential from arslvq import RSLVQ as ARSLVQ import numpy as np from rslvq_stream import RSLVQ as MasterRSLVQ stream = SEAGenerator() stream.prepare_for_use() clf = [ RSLVQ(batch_size=5), BARSLVQ(gradient_descent='Adadelta', batch_size=5, decay_rate=0.9, sigma=1.0), RSLVQ(), MasterRSLVQ(gradient_descent='Adadelta', decay_rate=0.999, sigma=1.0) ] evaluator = EvaluatePrequential(max_samples=100000, batch_size=5, show_plot=True) evaluator.evaluate(stream=stream, model=clf, model_names=['BRSLVQ', 'BARSLVQ', 'RSLVQ', 'MRSLVQ']) measurements = np.asarray(evaluator.get_measurements()[0])[0]