@@ -31,10 +31,6 @@ const ERR_INVALID_OPERATION = ArgumentError(
31
31
_ambiguous_operation (model, measure) =
32
32
" `$measure ` does not support a `model` with " *
33
33
" `prediction_type(model) == :$(prediction_type (model)) `. "
34
- err_ambiguous_operation (model, measure) = ArgumentError (
35
- _ambiguous_operation (model, measure)*
36
- " \n Unable to infer an appropriate operation for `$measure `. " *
37
- " Explicitly specify `operation=...` or `operations=...`. " )
38
34
err_incompatible_prediction_types (model, measure) = ArgumentError (
39
35
_ambiguous_operation (model, measure)*
40
36
" If your model is truly making probabilistic predictions, try explicitly " *
@@ -65,11 +61,37 @@ ERR_MEASURES_DETERMINISTIC(measure) = ArgumentError(
65
61
" and so is not supported by `$measure `. " * LOG_AVOID
66
62
)
67
63
68
- # ==================================================================
69
- # # MODEL TYPES THAT CAN BE EVALUATED
64
+ err_ambiguous_operation (model, measure) = ArgumentError (
65
+ _ambiguous_operation (model, measure)*
66
+ " \n Unable to infer an appropriate operation for `$measure `. " *
67
+ " Explicitly specify `operation=...` or `operations=...`. " *
68
+ " Possible value(s) are: $PREDICT_OPERATIONS_STRING . "
69
+ )
70
+
71
+ const ERR_UNSUPPORTED_PREDICTION_TYPE = ArgumentError (
72
+ """
70
73
71
- # not exported:
72
- const Measurable = Union{Supervised, Annotator}
74
+ The `prediction_type` of your model needs to be one of: `:deterministic`,
75
+ `:probabilistic`, or `:interval`. Does your model implement one of these operations:
76
+ $PREDICT_OPERATIONS_STRING ? If so, you can try explicitly specifying `operation=...`
77
+ or `operations=...` (and consider posting an issue to have the model review it's
78
+ definition of `MLJModelInterface.prediction_type`). Otherwise, performance
79
+ evaluation is not supported.
80
+
81
+ """
82
+ )
83
+
84
+ const ERR_NEED_TARGET = ArgumentError (
85
+ """
86
+
87
+ To evaluate a model's performance you must provide a target variable `y`, as in
88
+ `evaluate(model, X, y; options...)` or
89
+
90
+ mach = machine(model, X, y)
91
+ evaluate!(mach; options...)
92
+
93
+ """
94
+ )
73
95
74
96
# ==================================================================
75
97
# # RESAMPLING STRATEGIES
@@ -987,7 +1009,7 @@ function _actual_operations(operation::Nothing,
987
1009
throw (err_ambiguous_operation (model, m))
988
1010
end
989
1011
else
990
- throw (err_ambiguous_operation (model, m) )
1012
+ throw (ERR_UNSUPPORTED_PREDICTION_TYPE )
991
1013
end
992
1014
end
993
1015
end
@@ -1137,7 +1159,7 @@ See also [`evaluate`](@ref), [`PerformanceEvaluation`](@ref),
1137
1159
1138
1160
"""
1139
1161
function evaluate! (
1140
- mach:: Machine{<:Measurable} ;
1162
+ mach:: Machine ;
1141
1163
resampling= CV (),
1142
1164
measures= nothing ,
1143
1165
measure= measures,
@@ -1160,6 +1182,8 @@ function evaluate!(
1160
1182
# weights, measures, operations, and dispatches a
1161
1183
# strategy-specific `evaluate!`
1162
1184
1185
+ length (mach. args) > 1 || throw (ERR_NEED_TARGET)
1186
+
1163
1187
repeats > 0 || error (" Need `repeats > 0`. " )
1164
1188
1165
1189
if resampling isa TrainTestPairs
@@ -1235,7 +1259,7 @@ Returns a [`PerformanceEvaluation`](@ref) object.
1235
1259
See also [`evaluate!`](@ref).
1236
1260
1237
1261
"""
1238
- evaluate (model:: Measurable , args... ; cache= true , kwargs... ) =
1262
+ evaluate (model:: Model , args... ; cache= true , kwargs... ) =
1239
1263
evaluate! (machine (model, args... ; cache= cache); kwargs... )
1240
1264
1241
1265
# -------------------------------------------------------------------
0 commit comments