-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #170 from JuliaAI/dev
For a 0.7.0 release
- Loading branch information
Showing
11 changed files
with
223 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ jobs: | |
fail-fast: false | ||
matrix: | ||
version: | ||
- '1.3' | ||
- '1.6' | ||
- '1' | ||
os: | ||
- ubuntu-latest | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
MLJModelInterface.save(::MLJTuning.EitherTunedModel, fitresult::Machine) = | ||
serializable(fitresult) | ||
|
||
function MLJModelInterface.restore(::MLJTuning.EitherTunedModel, fitresult) | ||
fitresult.fitresult = restore(fitresult.model, fitresult.fitresult) | ||
return fitresult | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
[deps] | ||
CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597" | ||
ComputationalResources = "ed09eef8-17a6-5b46-8889-db040fac31e3" | ||
DecisionTree = "7806a523-6efd-50cb-b5f6-3fa6f1930dbb" | ||
Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7" | ||
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b" | ||
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" | ||
LatinHypercubeSampling = "a5e1c1ea-c99a-51d3-a14d-a9a37257b02d" | ||
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" | ||
MLJBase = "a7f614a8-145f-11e9-1d2a-a57a1082229d" | ||
MLJModelInterface = "e80e1ace-859a-464e-9ed9-23947d8ae3ea" | ||
MultivariateStats = "6f286f6a-111f-5878-ab1e-185364afe411" | ||
NearestNeighbors = "b8a86587-4115-5ab1-83bc-aa920d37bbce" | ||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" | ||
ScientificTypes = "321657f4-b219-11e9-178b-2701a2544e81" | ||
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b" | ||
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3" | ||
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" | ||
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" | ||
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
||
[compat] | ||
CategoricalArrays = "0.10" | ||
ComputationalResources = "0.3" | ||
DecisionTree = "0.10" | ||
Distances = "0.10" | ||
Distributions = "0.25" | ||
MLJBase = "0.20" | ||
MLJModelInterface = "1.3" | ||
MultivariateStats = "0.9" | ||
NearestNeighbors = "0.4" | ||
ScientificTypes = "3.0" | ||
StableRNGs = "1.0" | ||
StatsBase = "0.33" | ||
Tables = "1.6" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
|
||
module TestSerialization | ||
|
||
using Test | ||
using MLJBase | ||
using Serialization | ||
using MLJTuning | ||
using ..Models | ||
|
||
function test_args(mach) | ||
# Check source nodes are empty if any | ||
for arg in mach.args | ||
if arg isa Source | ||
@test arg == source() | ||
end | ||
end | ||
end | ||
|
||
function test_data(mach) | ||
@test !isdefined(mach, :old_rows) | ||
@test !isdefined(mach, :data) | ||
@test !isdefined(mach, :resampled_data) | ||
@test !isdefined(mach, :cache) | ||
end | ||
|
||
function generic_tests(mach₁, mach₂) | ||
test_args(mach₂) | ||
test_data(mach₂) | ||
@test mach₂.state == -1 | ||
for field in (:frozen, :model, :old_model, :old_upstream_state, :fit_okay) | ||
@test getfield(mach₁, field) == getfield(mach₂, field) | ||
end | ||
end | ||
|
||
|
||
@testset "Test TunedModel" begin | ||
filename = "tuned_model.jls" | ||
X, y = make_regression(100) | ||
base_model = DecisionTreeRegressor() | ||
tuned_model = TunedModel( | ||
model=base_model, | ||
tuning=Grid(), | ||
range=[range(base_model, :min_samples_split, values=[2,3,4])], | ||
) | ||
mach = machine(tuned_model, X, y) | ||
fit!(mach, rows=1:50, verbosity=0) | ||
smach = MLJBase.serializable(mach) | ||
@test smach.fitresult isa Machine | ||
@test smach.report == mach.report | ||
generic_tests(mach, smach) | ||
|
||
Serialization.serialize(filename, smach) | ||
smach = Serialization.deserialize(filename) | ||
MLJBase.restore!(smach) | ||
|
||
@test MLJBase.predict(smach, X) == MLJBase.predict(mach, X) | ||
@test fitted_params(smach) isa NamedTuple | ||
@test report(smach) == report(mach) | ||
|
||
rm(filename) | ||
|
||
# End to end | ||
MLJBase.save(filename, mach) | ||
smach = machine(filename) | ||
@test predict(smach, X) == predict(mach, X) | ||
|
||
rm(filename) | ||
|
||
end | ||
|
||
end | ||
|
||
true |
Oops, something went wrong.