Skip to content

Commit

Permalink
GH-15809: add null check
Browse files Browse the repository at this point in the history
  • Loading branch information
syzonyuliia-h2o authored and wendycwong committed Feb 5, 2024
1 parent 1dac03e commit 8665036
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions h2o-core/src/main/java/hex/ModelMetricsBinomial.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public static class MetricBuilderBinomial<T extends MetricBuilderBinomial<T>> ex
_logloss += w * MathUtils.logloss(err);
}

if(m.getClass().toString().contains("Generic")) {
if(m != null && m.getClass().toString().contains("Generic")) {
_loglikelihood += m.likelihood(w, yact[0], ds);
}

Expand Down Expand Up @@ -280,7 +280,7 @@ private ModelMetrics makeModelMetrics(Model m, Frame f, GainsLift gl) {
sigma = weightedSigma();
mse = _sumsqe / _wcount;
logloss = _logloss / _wcount;
if(m.getClass().toString().contains("Generic")) {
if(m != null && m.getClass().toString().contains("Generic")) {
loglikelihood = -1 * _loglikelihood ; // get likelihood from negative loglikelihood
aic = m.aic(loglikelihood);
}
Expand Down
4 changes: 2 additions & 2 deletions h2o-core/src/main/java/hex/ModelMetricsMultinomial.java
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ public MetricBuilderMultinomial( int nclasses, String[] domain, MultinomialAucTy
}


if(m.getClass().toString().contains("Generic")) {
if(m != null && m.getClass().toString().contains("Generic")) {
_loglikelihood += m.likelihood(w, yact[0], ds);
}
return ds; // Flow coding
Expand Down Expand Up @@ -379,7 +379,7 @@ private void calculateAucsPerRow(double ds[], int iact, double w){
}
mse = _sumsqe / _wcount;
logloss = _logloss / _wcount;
if(m.getClass().toString().contains("Generic")) {
if(m != null && m.getClass().toString().contains("Generic")) {
loglikelihood = -1 * _loglikelihood ; // get likelihood from negative loglikelihood
aic = m.aic(loglikelihood);
}
Expand Down
4 changes: 2 additions & 2 deletions h2o-core/src/main/java/hex/ModelMetricsRegression.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public MetricBuilderRegression(Distribution dist) {
}
}

if(m.getClass().toString().contains("Generic")) {
if(m != null && m.getClass().toString().contains("Generic")) {
_loglikelihood += m.likelihood(w, yact[0], ds);
}

Expand Down Expand Up @@ -212,7 +212,7 @@ ModelMetricsRegression computeModelMetrics(Model m, Frame f, Frame adaptedFrame,
} else {
meanResDeviance = Double.NaN;
}
if(m.getClass().toString().contains("Generic")) {
if(m != null && m.getClass().toString().contains("Generic")) {
loglikelihood = -1 * _loglikelihood ; // get likelihood from negative loglikelihood
aic = m.aic(loglikelihood);
}
Expand Down

0 comments on commit 8665036

Please sign in to comment.