From c7b49b7bfc335503c07ffdd0580b783481c718f0 Mon Sep 17 00:00:00 2001 From: tiemvanderdeure Date: Mon, 28 Oct 2024 09:48:08 +0100 Subject: [PATCH] throw a helpful error if input data only has one class --- src/mlj_interface.jl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/mlj_interface.jl b/src/mlj_interface.jl index 8521302..b9ca24b 100644 --- a/src/mlj_interface.jl +++ b/src/mlj_interface.jl @@ -67,6 +67,13 @@ function MMI.fit(m::MaxnetBinaryClassifier, verbosity::Int, X, y) # convert categorical to boolean y_boolean = Bool.(MMI.int(y) .- 1) + allequal(y_boolean) && error( + """ + Only class $(CategoricalArrays.get(first(y))) was found in the data. + Provide data with two classes that represent background and presence samples. + """ + ) + fitresult = maxnet( y_boolean, X; m.features, regularization_multiplier = m.regularization_multiplier,