1
- # # TYPE ALIASES
1
+ # TYPE ALIASES
2
2
3
3
const AbstractRow = Union{AbstractVector{<: Integer }, Colon}
4
4
const TrainTestPair = Tuple{AbstractRow,AbstractRow}
@@ -747,6 +747,64 @@ Base.show(io::IO, e::CompactPerformanceEvaluation) =
747
747
print (io, " CompactPerformanceEvaluation$(_summary (e)) " )
748
748
749
749
750
+
751
+ # ===============================================================
752
+ # # USER CONTROL OF DEFAULT LOGGING
753
+
754
+ const DOC_DEFAULT_LOGGER =
755
+ """
756
+
757
+ The default logger is used in calls to [`evaluate!`](@ref) and [`evaluate`](@ref), and
758
+ in the constructors `TunedModel` and `IteratedModel`, unless the `logger` keyword is
759
+ explicitly specified.
760
+
761
+ !!! note
762
+
763
+ Prior to MLJ v0.20.7 (and MLJBase 1.5) the default logger was always `nothing`.
764
+
765
+ """
766
+
767
+ """
768
+ default_logger()
769
+
770
+ Return the current value of the default logger for use with supported machine learning
771
+ tracking platforms, such as [MLflow](https://mlflow.org/docs/latest/index.html).
772
+
773
+ $DOC_DEFAULT_LOGGER
774
+
775
+ When MLJBase is first loaded, the default logger is `nothing`. To reset the logger, see
776
+ beow.
777
+
778
+ """
779
+ default_logger () = DEFAULT_LOGGER[]
780
+
781
+ """
782
+ default_logger(logger)
783
+
784
+ Reset the default logger.
785
+
786
+ # Example
787
+
788
+ Suppose an [MLflow](https://mlflow.org/docs/latest/index.html) tracking service is running
789
+ on a local server at `http://127.0.0.1:500`. Then every in every `evaluate` call in which
790
+ `logger` is not specified, as in the example below, the peformance evaluation is
791
+ automatically logged to the service.
792
+
793
+ ```julia-repl
794
+ using MLJ
795
+ logger = MLJFlow.Logger("http://127.0.0.1:5000/api")
796
+ default_logger(logger)
797
+
798
+ X, y = make_moons()
799
+ model = ConstantClassifier()
800
+ evaluate(model, X, y, measures=[log_loss, accuracy)])
801
+
802
+ """
803
+ function default_logger (logger)
804
+ DEFAULT_LOGGER[] = logger
805
+ end
806
+
807
+
750
808
# ===============================================================
751
809
# # EVALUATION METHODS
752
810
@@ -1068,7 +1126,8 @@ Although `evaluate!` is mutating, `mach.model` and `mach.args` are not mutated.
1068
1126
`false` the `per_observation` field of the returned object is populated with
1069
1127
`missing`s. Setting to `false` may reduce compute time and allocations.
1070
1128
1071
- - `logger` - a logger object (see [`MLJBase.log_evaluation`](@ref))
1129
+ - `logger=default_logger()` - a logger object for forwarding results to a machine learning
1130
+ tracking platform; see [`default_logger`](@ref) for details.
1072
1131
1073
1132
- `compact=false` - if `true`, the returned evaluation object excludes these fields:
1074
1133
`fitted_params_per_fold`, `report_per_fold`, `train_test_rows`.
@@ -1093,7 +1152,7 @@ function evaluate!(
1093
1152
check_measure= true ,
1094
1153
per_observation= true ,
1095
1154
verbosity= 1 ,
1096
- logger= nothing ,
1155
+ logger= default_logger () ,
1097
1156
compact= false ,
1098
1157
)
1099
1158
@@ -1544,7 +1603,7 @@ end
1544
1603
acceleration=default_resource(),
1545
1604
check_measure=true,
1546
1605
per_observation=true,
1547
- logger=nothing ,
1606
+ logger=default_logger() ,
1548
1607
compact=false,
1549
1608
)
1550
1609
@@ -1624,7 +1683,7 @@ function Resampler(
1624
1683
repeats= 1 ,
1625
1684
cache= true ,
1626
1685
per_observation= true ,
1627
- logger= nothing ,
1686
+ logger= default_logger () ,
1628
1687
compact= false ,
1629
1688
)
1630
1689
resampler = Resampler (
0 commit comments