@@ -286,65 +286,42 @@ public void flatMap(Tuple3<String, Integer, Integer> input_stream, Collector<Tup
286
286
// WARNING PHASE
287
287
if (!empty_background_state .value ()) {
288
288
HoeffdingTree background_hoeffdingTree = background_hoeffdingTreeValueState .value ();
289
- background_hoeffdingTree .TestHoeffdingTree (background_hoeffdingTree .root , features , 0 );
290
- background_hoeffdingTree .UpdateHoeffdingTree (background_hoeffdingTree .root , features , instance_weight );
289
+ for (int i = 0 ; i < instance_weight ; i ++) {
290
+ background_hoeffdingTree .UpdateHoeffdingTree (background_hoeffdingTree .root , features , instance_weight );
291
+ }
291
292
background_hoeffdingTreeValueState .update (background_hoeffdingTree );
292
- // System.out.println(" "+instance_id+" "+background_hoeffdingTree.getAccuracy());
293
- collector .collect (new Tuple6 <>(instance_id , prediction , -1 , purpose_id , background_hoeffdingTree .getErrorRate (), 0 ));
294
293
} else if (empty_background_state .value ()) {
295
294
// System.out.println("===================================Warning Phase===================================");
296
- System .out .println ("Background Tree " + instance_id + " Just Created " );
295
+ // System.out.println("Background Tree " + instance_id + " Just Created ");
297
296
empty_background_state .update (false );
298
297
// Warning Signal. Create & Train the Background Tree
299
298
HoeffdingTree background_hoeffdingTree = new HoeffdingTree ();
300
- background_hoeffdingTree .NEW_CreateHoeffdingTree (2 , 2 , 200 , 0.000001 , 0.05 , this .combination_function , hoeffding_tree_id , age_of_maturity_input );
299
+ background_hoeffdingTree .NEW_CreateHoeffdingTree (7 , 9 , 200 , 0.0001 , 0.05 , this .combination_function , hoeffding_tree_id , 1 );
301
300
// background_hoeffdingTree.print_m_features();
302
301
background_hoeffdingTreeValueState .update (background_hoeffdingTree );
303
- collector .collect (new Tuple6 <>(instance_id , prediction , -1 , purpose_id , background_hoeffdingTree .getErrorRate (), 0 ));
304
-
305
302
}
306
- } else if (( current_stream_status == 1 || current_stream_status == 2 ) && updated_stream_status == 2 ) {
303
+ } else if (current_stream_status == 1 && updated_stream_status == 0 ) {
307
304
// System.out.println("DS Signal: instance id " + instance_id);
308
305
if (current_signal == 2 ) {
309
306
// System.out.println("=============================Stable Phase/ Drift===================================");
310
307
// System.out.println("Stable phase after a Drift Signal");
311
- // System.out.println("Do the Switch: " + instance_id + " Background Tree taking over "+ht.getAccuracy() );
308
+ System .out .println ("Do the Switch: " + instance_id + "Background Tree taking over" );
312
309
// Drift Signal. Do the Switch
313
310
HoeffdingTree background_tree = background_hoeffdingTreeValueState .value ();
314
- background_tree .TestHoeffdingTree (background_tree .root , features , 0 );
315
- background_tree .UpdateHoeffdingTree (background_tree .root , features , instance_weight );
316
- background_hoeffdingTreeValueState .update (background_tree );
317
- collector .collect (new Tuple6 <>(instance_id , prediction , -1 , purpose_id , background_tree .getErrorRate (), 0 ));
318
-
319
- if (current_stream_status == 1 ) {
320
- System .out .println ("Pending for the Switch: " + hoeffding_tree_id + " => " + instance_id + " Background Tree taking over " + ht .getAccuracy () + " => " + background_tree .getAccuracy ());
321
- }
322
- // System.out.println("Size "+ ht.SizeHT(ht.root));
323
- // System.out.println("Counter "+ ht.counter);
324
- if (background_tree .getAccuracy () > ht .getAccuracy ()) {
325
- System .out .println ("Do the Switch: " + hoeffding_tree_id + " => " + instance_id + " Background Tree taking over " + ht .getAccuracy () + " => " + background_tree .getAccuracy ());
326
- ht .RemoveHoeffdingTree ();
327
- hoeffdingTreeValueState .update (background_tree );
328
- ht = hoeffdingTreeValueState .value ();
329
- System .out .println (ht .getAccuracy () + " " + ht .getErrorRate ());
330
- empty_background_state .update (true );
331
- // System.out.println("Making the switch and resetting the Drift Detector");
332
- //RESET EVERYTHING
333
- conceptDriftDetector .ResetConceptDrift ();
334
- }
335
- collector .collect (new Tuple6 <>(instance_id , prediction , -1 , purpose_id , background_tree .getErrorRate (), 0 ));
336
-
337
- }
338
- } else if (current_stream_status == 1 && updated_stream_status == 0 ) {
339
- if (current_signal == -1 ) {
311
+ ht .RemoveHoeffdingTree ();
312
+ hoeffdingTreeValueState .update (background_tree );
313
+ empty_background_state .update (true );
314
+ // System.out.println("Making the switch and resetting the Drift Detector");
315
+ //RESET EVERYTHING
316
+ conceptDriftDetector .ResetConceptDrift ();
317
+ } else if (current_signal == -1 ) {
340
318
// System.out.println("=========================Stable Phase/ False Alarm=================================");
341
- System .out .println ("Stable phase after a false alarm" );
319
+ // System.out.println("Stable phase after a false alarm");
342
320
// System.out.println("FAS False Alarm Signal: instance id " + instance_id);
343
321
HoeffdingTree background_tree = background_hoeffdingTreeValueState .value ();
344
322
background_tree .RemoveHoeffdingTree ();
345
323
background_hoeffdingTreeValueState .clear ();
346
324
empty_background_state .update (true );
347
-
348
325
}
349
326
//System.out.println("Training HT with id " + hoeffding_tree_id + " which has error-rate " + ht.getErrorRate() + " predicts " + prediction + " for the instance with id " + instance_id + " while the true label is " + true_label);
350
327
}
@@ -372,8 +349,8 @@ public void flatMap(Tuple3<String, Integer, Integer> input_stream, Collector<Tup
372
349
} else if (instance_id == -1 && true_label == -1 && purpose_id == -1 ) {
373
350
HoeffdingTree ht = hoeffdingTreeValueState .value ();
374
351
int size = ht .SizeHT (ht .root );
375
-
376
- System .out .print (size + "\t " + ht .getAccuracy () + "\t " );
352
+ int number_of_splits = ht . getNumberOfSplits ( ht . root );
353
+ System .out .print (size + "\t " + ht .getAccuracy () + "\t " + number_of_splits );
377
354
// System.out.println("Accuracy : " + ht.getAccuracy());
378
355
379
356
System .out .println ("End of Stream message " + hoeffding_tree_id );
0 commit comments