Skip to content

Commit

Permalink
throw a helpful error if input data only has one class
Browse files Browse the repository at this point in the history
  • Loading branch information
tiemvanderdeure committed Oct 28, 2024
1 parent e43b313 commit c7b49b7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/mlj_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit c7b49b7

Please sign in to comment.