Skip to content

Commit

Permalink
Merge pull request #524 from alan-turing-institute/dev
Browse files Browse the repository at this point in the history
For a 0.17.7 release
  • Loading branch information
ablaom authored Mar 15, 2021
2 parents e3b2f8c + 757b5ee commit a327547
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MLJBase"
uuid = "a7f614a8-145f-11e9-1d2a-a57a1082229d"
authors = ["Anthony D. Blaom <[email protected]>"]
version = "0.17.6"
version = "0.17.7"

[deps]
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
Expand Down Expand Up @@ -39,15 +39,15 @@ InvertedIndices = "^1"
JLSO = "^2.1,^2.2"
JSON = "^0.21"
LossFunctions = "0.5, 0.6"
MLJModelInterface = "^0.4"
MLJModelInterface = "^0.4.1"
MLJScientificTypes = "^0.4.1"
Missings = "^0.4"
OrderedCollections = "^1.1"
Parameters = "^0.12"
PrettyTables = "^0.8,^0.9,^0.10,^0.11"
ProgressMeter = "^1.3"
StatsBase = "^0.32,^0.33"
StatisticalTraits = "^0.1"
StatisticalTraits = "^0.1.1"
Tables = "^0.2,^1.0"
julia = "1"

Expand Down
4 changes: 2 additions & 2 deletions src/MLJBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import MLJModelInterface: fit, update, update_data, transform,
predict_mode, predict_mean, predict_median, predict_joint,
evaluate, clean!, is_same_except,
save, restore, is_same_except, istransparent,
params
params, training_losses

# Macros
using Parameters
Expand Down Expand Up @@ -105,7 +105,7 @@ export @mlj_model, metadata_pkg, metadata_model
export fit, update, update_data, transform, inverse_transform,
fitted_params, predict,
predict_mode, predict_mean, predict_median, predict_joint,
evaluate, clean!
evaluate, clean!, training_losses

# data operations
export matrix, int, classes, decoder, table,
Expand Down
13 changes: 13 additions & 0 deletions src/machines.jl
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,19 @@ reports keyed on those machines.
"""
report(mach::Machine) = mach.report

"""
training_losses(mach::Machine)
Return a list of training losses, for models that make these
available. Otherwise, returns `nothing`.
"""

training_losses(mach::Machine) =
training_losses(mach.model, mach.report)




## SERIALIZATION

Expand Down
4 changes: 3 additions & 1 deletion src/resampling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1173,12 +1173,14 @@ StatisticalTraits.package_name(::Type{<:Resampler}) = "MLJBase"

StatisticalTraits.load_path(::Type{<:Resampler}) = "MLJBase.Resampler"

evaluate(resampler::Resampler, fitresult) = fitresult.evaluation
fitted_params(::Resampler, fitresult) = fitresult

evaluate(resampler::Resampler, fitresult) = fitresult.evaluation
function evaluate(machine::Machine{<:Resampler})
if isdefined(machine, :fitresult)
return evaluate(machine.model, machine.fitresult)
else
throw(error("$machine has not been trained."))
end
end

2 changes: 2 additions & 0 deletions test/machines.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ t = machine(tree, X, y)
t.model.max_depth = 1
@test_logs (:info, r"Updating") fit!(t)

@test training_losses(t) === nothing

predict(t, selectrows(X,test));
@test rms(predict(t, selectrows(X, test)), y[test]) < std(y)

Expand Down

0 comments on commit a327547

Please sign in to comment.