1
1
<?php
2
2
#
3
- # Copyright 2012-2021 BigML
3
+ # Copyright 2012-2023 BigML
4
4
#
5
5
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6
6
# not use this file except in compliance with the License. You may obtain
@@ -140,9 +140,9 @@ class MultiVote {
140
140
const DEFAULT_METHOD = 0 ;
141
141
const BINS_LIMIT = 32 ;
142
142
143
- public $ COMBINATION_WEIGHTS = array (MultiVote::PLURALITY => null , MultiVote::CONFIDENCE => 'confidence ' , MultiVote::PROBABILITY => 'probability ' , MultiVote::THRESHOLD => null );
143
+ public $ COMBINATION_WEIGHTS = array (MultiVote::PLURALITY => '' , MultiVote::CONFIDENCE => 'confidence ' , MultiVote::PROBABILITY => 'probability ' , MultiVote::THRESHOLD => '' );
144
144
public $ COMBINER_MAP = array (MultiVote::PLURALITY_CODE =>MultiVote::PLURALITY , MultiVote::CONFIDENCE_CODE => MultiVote::CONFIDENCE , MultiVote::PROBABILITY_CODE => MultiVote::PROBABILITY , MultiVote::THRESHOLD_CODE =>MultiVote::THRESHOLD );
145
- public $ WEIGHT_KEYS = array (MultiVote::PLURALITY => null , MultiVote::CONFIDENCE => array ('confidence ' ), MultiVote::PROBABILITY =>array ('distribution ' , 'count ' ), MultiVote::THRESHOLD => null );
145
+ public $ WEIGHT_KEYS = array (MultiVote::PLURALITY => '' , MultiVote::CONFIDENCE => array ('confidence ' ), MultiVote::PROBABILITY =>array ('distribution ' , 'count ' ), MultiVote::THRESHOLD => '' );
146
146
147
147
public $ predictions ;
148
148
public $ probabilities ;
@@ -588,7 +588,7 @@ public function combine($method=MultiVote::DEFAULT_METHOD, $with_confidence=fals
588
588
}
589
589
590
590
return $ predictions ->combine_categorical ( (array_key_exists ($ method , $ this ->COMBINATION_WEIGHTS )) ?
591
- $ this ->COMBINATION_WEIGHTS [$ method ] : null ,
591
+ $ this ->COMBINATION_WEIGHTS [$ method ] : '' ,
592
592
$ with_confidence , $ add_confidence , $ add_distribution , $ add_count );
593
593
}
594
594
}
@@ -706,7 +706,7 @@ function probability_weight() {
706
706
707
707
}
708
708
709
- function combine_categorical ($ weight_label =null , $ with_confidence =false , $ add_confidence =false ,
709
+ function combine_categorical ($ weight_label ='' , $ with_confidence =false , $ add_confidence =false ,
710
710
$ add_distribution =false , $ add_count =False ) {
711
711
/*
712
712
Returns the prediction combining votes by using the given weight:
@@ -722,13 +722,13 @@ function combine_categorical($weight_label=null, $with_confidence=false, $add_co
722
722
$ mode = array ();
723
723
724
724
$ weight = 0 ;
725
- if ($ weight_label == null ) {
725
+ if ($ weight_label == '' ) {
726
726
$ weight = 1 ;
727
727
}
728
728
$ instances = 0 ;
729
729
730
730
foreach ($ this ->predictions as $ prediction ) {
731
- if ($ weight_label != null ) {
731
+ if ($ weight_label != '' ) {
732
732
733
733
if (!in_array ($ weight_label , array_values ($ this ->COMBINATION_WEIGHTS ))) {
734
734
throw new \Exception ("Wrong weight_label value. " );
@@ -871,7 +871,7 @@ function weighted_confidence($combined_prediction, $weight_label) {
871
871
}
872
872
}
873
873
874
- if ($ weight_label != null && (!is_string ($ weight_label ) || (!$ check_confidence_and_weight_label )) ) {
874
+ if ($ weight_label != '' && (!is_string ($ weight_label ) || (!$ check_confidence_and_weight_label )) ) {
875
875
throw new \Exception ("Not enough data to use the selected prediction method. Lacks " . $ weight_label . " information. " );
876
876
}
877
877
@@ -880,7 +880,7 @@ function weighted_confidence($combined_prediction, $weight_label) {
880
880
$ weight = 1 ;
881
881
882
882
foreach ($ predictions as $ prediction ) {
883
- if ($ weight_label != null ) {
883
+ if ($ weight_label != '' ) {
884
884
$ weight = $ prediction ->$ weight_label ;
885
885
}
886
886
0 commit comments