@@ -474,11 +474,11 @@ be interpreted with caution. See, for example, Bates et al.
474
474
These fields are part of the public API of the `PerformanceEvaluation`
475
475
struct.
476
476
477
- - `measure`: vector of measures (metrics) used to evaluate performance
478
-
479
477
- `model`: model used to create the performance evaluation. In the case a
480
478
tuning model, this is the best model found.
481
479
480
+ - `measure`: vector of measures (metrics) used to evaluate performance
481
+
482
482
- `measurement`: vector of measurements - one for each element of
483
483
`measure` - aggregating the performance measurements over all
484
484
train/test pairs (folds). The aggregation method applied for a given
@@ -512,15 +512,15 @@ struct.
512
512
training and evaluation respectively.
513
513
"""
514
514
struct PerformanceEvaluation{M,
515
- Model ,
515
+ Measure ,
516
516
Measurement,
517
517
Operation,
518
518
PerFold,
519
519
PerObservation,
520
520
FittedParamsPerFold,
521
521
ReportPerFold} <: MLJType
522
- measure :: M
523
- model :: Model
522
+ model :: M
523
+ measure :: Measure
524
524
measurement:: Measurement
525
525
operation:: Operation
526
526
per_fold:: PerFold
@@ -573,9 +573,9 @@ function Base.show(io::IO, ::MIME"text/plain", e::PerformanceEvaluation)
573
573
574
574
println (io, " PerformanceEvaluation object " *
575
575
" with these fields:" )
576
- println (io, " measure, operation, measurement, per_fold,\n " *
576
+ println (io, " model, measure, operation, measurement, per_fold,\n " *
577
577
" per_observation, fitted_params_per_fold,\n " *
578
- " report_per_fold, train_test_rows" , " model " )
578
+ " report_per_fold, train_test_rows" )
579
579
println (io, " Extract:" )
580
580
show_color = MLJBase. SHOW_COLOR[]
581
581
color_off ()
@@ -812,6 +812,24 @@ _process_accel_settings(accel) = throw(ArgumentError("unsupported" *
812
812
813
813
# --------------------------------------------------------------
814
814
# User interface points: `evaluate!` and `evaluate`
815
+ #
816
+ """
817
+ log_evaluation(logger, performance_evaluation)
818
+
819
+ Log a performance evaluation to `logger`, an object specific to some logging
820
+ platform, such as mlflow. If `logger=nothing` then no logging is performed.
821
+ The method is called at the end of every call to `evaluate/evaluate!` using
822
+ the logger provided by the `logger` keyword argument.
823
+
824
+ # Implementations for new logging platforms
825
+ #
826
+ Julia interfaces to workflow logging platforms, such as mlflow (provided by
827
+ the MLFlowClient.jl interface) should overload
828
+ `log_evaluation(logger::LoggerType, performance_evaluation)`,
829
+ where `LoggerType` is a platform-specific type for logger objects. For an
830
+ example, see the implementation provided by the MLJFlow.jl package.
831
+ """
832
+ log_evaluation (logger, performance_evaluation) = nothing
815
833
816
834
"""
817
835
evaluate!(mach,
@@ -825,7 +843,8 @@ _process_accel_settings(accel) = throw(ArgumentError("unsupported" *
825
843
acceleration=default_resource(),
826
844
force=false,
827
845
verbosity=1,
828
- check_measure=true)
846
+ check_measure=true,
847
+ logger=nothing)
829
848
830
849
Estimate the performance of a machine `mach` wrapping a supervised
831
850
model in data, using the specified `resampling` strategy (defaulting
@@ -924,6 +943,8 @@ untouched.
924
943
925
944
- `check_measure` - default is `true`
926
945
946
+ - `logger` - a logger object (see [`MLJBase.log_evaluation`](@ref))
947
+
927
948
### Return value
928
949
929
950
A [`PerformanceEvaluation`](@ref) object. See
@@ -943,7 +964,8 @@ function evaluate!(mach::Machine{<:Measurable};
943
964
repeats= 1 ,
944
965
force= false ,
945
966
check_measure= true ,
946
- verbosity= 1 )
967
+ verbosity= 1 ,
968
+ logger= nothing )
947
969
948
970
# this method just checks validity of options, preprocess the
949
971
# weights, measures, operations, and dispatches a
@@ -984,9 +1006,12 @@ function evaluate!(mach::Machine{<:Measurable};
984
1006
985
1007
_acceleration= _process_accel_settings (acceleration)
986
1008
987
- evaluate! (mach, resampling, weights, class_weights, rows, verbosity,
988
- repeats, _measures, _operations, _acceleration, force)
1009
+ evaluation = evaluate! (mach, resampling, weights, class_weights, rows,
1010
+ verbosity, repeats, _measures, _operations,
1011
+ _acceleration, force)
1012
+ log_evaluation (logger, evaluation)
989
1013
1014
+ evaluation
990
1015
end
991
1016
992
1017
"""
@@ -1161,22 +1186,6 @@ function measure_specific_weights(measure, weights, class_weights, test)
1161
1186
return nothing
1162
1187
end
1163
1188
1164
- # Workflow logging interfaces, such as MLJFlow (MLFlow connection via
1165
- # MLFlowClient.jl), overload the following method but replace the `logger`
1166
- # argument with `logger::LoggerType`, where `LoggerType` is specific to the
1167
- # logging platform.
1168
- """
1169
- log_evaluation(logger, performance_evaluation)
1170
-
1171
- Logs a performance evaluation (the returning object from `evaluate!`)
1172
- to a logging platform. The default implementation does nothing.
1173
- Can be overloaded by logging interfaces, such as MLJFlow (MLFlow
1174
- connection via MLFlowClient.jl), which replace the `logger` argument
1175
- with `logger::LoggerType`, where `LoggerType` is specific to the logging
1176
- platform.
1177
- """
1178
- log_evaluation (logger, performance_evaluation) = nothing
1179
-
1180
1189
# Evaluation when `resampling` is a TrainTestPairs (CORE EVALUATOR):
1181
1190
function evaluate! (mach:: Machine , resampling, weights,
1182
1191
class_weights, rows, verbosity, repeats,
@@ -1285,8 +1294,8 @@ function evaluate!(mach::Machine, resampling, weights,
1285
1294
end
1286
1295
1287
1296
return PerformanceEvaluation (
1288
- measures,
1289
1297
mach. model,
1298
+ measures,
1290
1299
per_measure,
1291
1300
operations,
1292
1301
per_fold,
0 commit comments