Hello!
After training a maxnet model, I get NA from:
predict(model, newdata, type = "cloglog")
There are no NAs in newdata.
Debugging shows model$entropy is NaN.
In maxnet() the entropy is computed as:
rr <- predict.maxnet(model, data[p == 0, , drop = FALSE], type = "exponent", clamp = FALSE)
raw <- rr / sum(rr)
model$entropy <- -sum(raw * log(raw))
When any entry of rr is exactly 0, raw contains zeros and raw * log(raw) evaluates to NaN.
This NaN then propagates and causes predict(..., "cloglog") to return NA.
Questions
(1) Is a model with model$entropy = NaN considered a failed/invalid fit?
(2) Would it be appropriate for maxnet() to compute entropy with a zero-safe convention (e.g., -sum(ifelse(raw > 0, raw * log(raw), 0)))?
(3) Alternatively, should zeros in rr be prevented at the source (e.g., filtering extreme features) or be explicitly excluded when computing entropy?
(4) Is there a recommended preprocessing or parameter setting to avoid rr = 0 ?
Thank you!