# MLJ: RootMeanSquaredLogError() returns Inf instead of actual score

**URL:** <https://discourse.julialang.org/t/mlj-rootmeansquaredlogerror-returns-inf-instead-of-actual-score/93995>\
**Category:** Machine Learning\
**Tags:** question, mlj\
**Created:** [February 3, 2023, 3:25pm UTC](https://discourse.julialang.org/t/mlj-rootmeansquaredlogerror-returns-inf-instead-of-actual-score/93995 "2023-02-03T15:25:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![clouedoc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/clouedoc/32/46324_2.png) [@clouedoc](https://discourse.julialang.org/u/clouedoc)\
**Post date:** [February 3, 2023, 3:25pm UTC](https://discourse.julialang.org/t/mlj-rootmeansquaredlogerror-returns-inf-instead-of-actual-score/93995/1 "2023-02-03T15:25:20Z")

</div>

Hello,

I’m trying to build a model for the [_Store Sales_ Kaggle Competition](https://www.kaggle.com/competitions/store-sales-time-series-forecasting/).

I’ve tried to build a super-simple model that only takes two-three features and submit my predictions to Kaggle. The numbers didn’t correspond between `evaluate!` and Kaggle at all, so I figured that my evaluation metric was wrong…

After consulting the [competitions’ documentation about evaluation](https://www.kaggle.com/competitions/store-sales-time-series-forecasting/overview/evaluation), I switched from _Root Mean Squared Error_ to _Root Mean Squared **Log** Error_ (in fact, I included both in my evaluation).

My problem is that I get `Inf` as RMSLE. I’m also worried that my model is not optimized towards RMSLE but instead RMSL  
I’d like to get something that at least ressembles my Kaggle score, which is of `2.89`.

```julia
train_timeseries = load_timeseries("./data/train.csv")
y, X = process_for_tree(train_timeseries, true)
tree = EvoTreeRegressor(
  measure=rmsle
)
mach = machine(tree, X, y)
evaluate!(mach, measure=[rms, rmsle])

```

This gives me the following evaluation:

```julia
┌───────────────────────────┬───────────┬─────────────┬─────────┬───────────────────────────────────────────────┐
│ measure │ operation │ measurement │ 1.96*SE │ per_fold │
├───────────────────────────┼───────────┼─────────────┼─────────┼───────────────────────────────────────────────┤
│ RootMeanSquaredError() │ predict │ 978.0 │ 151.0 │ [704.0, 878.0, 892.0, 1070.0, 1070.0, 1170.0] │
│ RootMeanSquaredLogError() │ predict │ Inf │ NaN │ [Inf, Inf, Inf, Inf, Inf, Inf] │

```

How could I make `evaluate!` output something else than `Inf`?

> **Notes about tuning EvoTrees for :logistic loss**
>
> I’ve tried setting `loss=:logistic` in my Tree’s constructor ([doc](https://evovest.github.io/EvoTrees.jl/dev/models/#EvoTrees.EvoTreeRegressor)) but I got this error:
> 
> ```julia
> tree = EvoTreeRegressor(
> loss=:logistic
> )
> 
> ```
> 
> ```julia
> ┌ Error: Problem fitting the machine machine(EvoTrees.EvoTreeRegressor{EvoTrees.Logistic, Float32}
> │ - nrounds: 10
> │ - lambda: 0.0
> │ - gamma: 0.0
> │ - eta: 0.1
> │ - max_depth: 5
> │ - min_weight: 1.0
> │ - rowsample: 1.0
> │ - colsample: 1.0
> │ - nbins: 32
> │ - alpha: 0.5
> │ - monotone_constraints: Dict{Int64, Int64}()
> │ - rng: Random.TaskLocalRNG()
> │ - device: cpu
> │ , …). 
> └ @ MLJBase ~/.julia/packages/MLJBase/uxwHr/src/machines.jl:682
> [ Info: Running type checks... 
> [ Info: Type checks okay. 
> ERROR: DomainError with -1.0025849:
> log will only return a complex result if called with a complex argument. Try log(Complex(x)).
> Stacktrace:
> [1] throw_complex_domainerror(f::Symbol, x::Float32)
> @ Base.Math ./math.jl:33
> [2] _log(x::Float32, base::Val{:ℯ}, func::Symbol)
> @ Base.Math ./special/log.jl:336
> [3] log
> @ ./special/log.jl:264 [inlined]
> [4] log_fast
> @ ./fastmath.jl:349 [inlined]
> [5] logit
> @ ~/.julia/packages/EvoTrees/RueBJ/src/loss.jl:134 [inlined]
> [6] init_evotree(params::EvoTrees.EvoTreeRegressor{EvoTrees.Logistic, Float32}; x_train::SubArray{Float64, 2, Matrix{Float64}, Tuple{Vector{Int64}, Base.Slice{Base.OneTo{Int64}}}, false}, y_train::SubArray{Float64, 1, Vector{Float64}, Tuple{Vector{Int64}}, false}, w_train::Nothing, offset_train::Nothing, fnames::Nothing)
> [7] fit(model::EvoTrees.EvoTreeRegressor{EvoTrees.Logistic, Float32}, verbosity::Int64, A::NamedTuple{(:matrix, :names), Tuple{SubArray{Float64, 2, Matrix{Float64}, Tuple{Vector{Int64}, Base.Slice{Base.OneTo{Int64}}}, false}, Vector{Symbol}}}, y::SubArray{Float64, 1, Vector{Float64}, Tuple{Vector{Int64}}, false}, w::Nothing)
> [... irrelevant stacktraces below removed ...]
> 
> ```
