Skip to content

Commit

Permalink
Debug tests failed on jenkins
Browse files Browse the repository at this point in the history
  • Loading branch information
maurever committed May 22, 2024
1 parent d4c70fa commit 1dfae13
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
30 changes: 21 additions & 9 deletions h2o-core/src/main/java/hex/AUUC.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,8 @@ public AUUC(double[] customThresholds, Vec preds, Vec y, Vec uplift, AUUCType au
public AUUC(AUUCBuilder bldr, boolean trueProbabilities, AUUCType auucType) {
_auucType = auucType;
_auucTypeIndx = getIndexByAUUCType(_auucType);
_nBins = bldr._nbins;
//assert _nBins >= 1 : "Must have >= 1 bins for AUUC calculation, but got " + _nBins;
_nBins = bldr._nbinsUsed;
if (_nBins > 0) {
assert trueProbabilities || bldr._thresholds[_nBins - 1] == 1 : "Bins need to contain pred = 1 when 0-1 probabilities are used";
_n = bldr._n;
_ths = Arrays.copyOf(bldr._thresholds, _nBins);
_treatment = Arrays.copyOf(bldr._treatment, _nBins);
Expand Down Expand Up @@ -117,6 +115,9 @@ public AUUC(AUUCBuilder bldr, boolean trueProbabilities, AUUCType auucType) {
_frequencyCumsum[i] = tmpf;
}

System.out.println(Arrays.toString(_treatment));
System.out.println(Arrays.toString(_control));

// these methods need to be call in this order
setUplift();
setUpliftRandom();
Expand Down Expand Up @@ -148,16 +149,19 @@ public AUUC(AUUCBuilder bldr, boolean trueProbabilities, AUUCType auucType) {
}

public void setUplift(){
for(int i=0; i<AUUCType.VALUES.length; i++) {
for(int i=0; i < AUUCType.VALUES.length; i++) {
for (int j = 0; j < _nBins; j++) {
_uplift[i][j] = AUUCType.VALUES[i].exec(this, j);
double value = AUUCType.VALUES[i].exec(this, j);
_uplift[i][j] = value;
}
}
for(int i=0; i<AUUCType.VALUES.length; i++) {
for(int i=0; i < AUUCType.VALUES.length; i++) {
if (_uplift[i].length == 1 && Double.isNaN(_uplift[i][0])) {
_uplift[i][0] = 0;
} else {
ArrayUtils.interpolateLinear(_uplift[i]);
if (!Double.isNaN(_uplift[i][_uplift[i].length-1])) {
ArrayUtils.interpolateLinear(_uplift[i]);
}
}
}
}
Expand Down Expand Up @@ -601,14 +605,22 @@ public enum AUUCType {
qini() {
@Override
double exec(long treatment, long control, long yTreatment, long yControl) {
double norm = treatment / (double)control;
double norm = control > 0 ? treatment / (double)control : 1;
return yTreatment - yControl * norm;
}
},
lift() {
@Override
double exec(long treatment, long control, long yTreatment, long yControl) {
return yTreatment / (double) treatment - yControl / (double)control;
if (treatment > 0 && control > 0) {
return yTreatment / (double) treatment - yControl / (double) control;
} else if (treatment < 0 && control > 0) {
return - (yControl / (double) control);
} else if (treatment > 0 && control < 0) {
return yTreatment / (double) treatment;
} else {
return Double.NaN;
}
}
},
gain() {
Expand Down
2 changes: 1 addition & 1 deletion h2o-core/src/main/java/water/util/ArrayUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -2248,7 +2248,7 @@ public static double[] uniformDistFromArray(double[][] array, long seed) {
*/
public static void interpolateLinear(double[] array){
assert array.length > 0 && !Double.isNaN(array[array.length-1]):
"Input array length should be > 0 and the first item should not be NaN";
"Input array length should be > 0 and the last item should not be NaN";
if (array.length == 1){
return;
}
Expand Down

0 comments on commit 1dfae13

Please sign in to comment.