|
1 |
| -# MLJTestIntegration.jl |
| 1 | +# MLJTestInterface.jl |
2 | 2 |
|
3 |
| -Package for applying integration tests to models implementing the |
4 |
| -[MLJ](https://alan-turing-institute.github.io/MLJ.jl/dev/) model |
5 |
| -interface. |
| 3 | +Package for testing an implementation of the |
| 4 | +[MLJ](https://alan-turing-institute.github.io/MLJ.jl/dev/) model interface. |
6 | 5 |
|
7 |
| -[](https://github.com/bcgov/repomountie/blob/master/doc/lifecycle-badges.md) [](https://github.com/JuliaAI/MLJTestIntegration.jl/actions) [](https://codecov.io/github/JuliaAI/MLJTestIntegration.jl?branch=master) |
| 6 | +[](https://github.com/bcgov/repomountie/blob/master/doc/lifecycle-badges.md) [](https://github.com/JuliaAI/MLJTestInterface.jl/actions) [](https://codecov.io/github/JuliaAI/MLJTestInterface.jl?branch=master) |
8 | 7 |
|
9 | 8 | # Installation
|
10 | 9 |
|
11 | 10 | ```julia
|
12 | 11 | using Pkg
|
13 |
| -Pkg.add("MLJTestIntegration") |
| 12 | +Pkg.add("MLJTestInterface") |
14 | 13 | ```
|
15 | 14 |
|
16 | 15 | # Usage
|
17 | 16 |
|
18 |
| -This package provides a method for testing a collection of `models` |
19 |
| -(types or named tuples with keys `:name` and `:package_name`) using |
20 |
| -the specified training `data`: |
| 17 | +To test that a collection of model types, `models`, satisfy the [MLJ model interface |
| 18 | +requirements](https://alan-turing-institute.github.io/MLJ.jl/dev/adding_models_for_general_use/), |
| 19 | +use the `MLJTestInterface.test` function: |
21 | 20 |
|
22 | 21 | ```julia
|
23 |
| -MLJTestIntegration.test(models, data...; mod=Main, level=2, throw=false, verbosity=1) |
| 22 | +MLJTestInterface.test(models, data...; mod=Main, level=2, throw=false, verbosity=1) |
24 | 23 | -> failures, summary
|
25 | 24 | ```
|
26 | 25 |
|
27 |
| -For detailed documentation, run `using MLJTestIntegration; @doc MLJTestIntegration.test`. |
| 26 | +Here `data` is training data acceptable to all the specified `models`, as would appear in |
| 27 | +a call `MLJModelInterface.fit(model_instance, verbosity, data...)`. |
28 | 28 |
|
29 |
| -For convenience, a number of specializations of this method are also provided: |
| 29 | +For detailed documentation, run `using MLJTestInterface; @doc MLJTestInterface.test`. |
30 | 30 |
|
31 |
| -- `test_single_target_classifiers` |
32 |
| -- `test_single_target_regressors` |
33 |
| -- `test_single_target_count_regressors` |
34 |
| -- `test_continuous_table_transformers` |
35 | 31 |
|
36 |
| -Query the document strings for details, or see |
37 |
| -[examples/bigtest/notebook.jl](examples/bigtest/notebook.jl). |
| 32 | +# Example |
38 | 33 |
|
39 |
| - |
40 |
| -# Examples |
41 |
| - |
42 |
| -## Testing models in a new MLJ model interface implementation |
43 |
| - |
44 |
| -The following tests the model interface implemented by some model type `MyClassifier` for |
45 |
| -multiclass classification, as might appear in tests for a package providing that type: |
| 34 | +The following tests the model interface implemented by the `DecisionTreeClassifier` model |
| 35 | +implemented in the package MLJDecisionTreeInterface.jl. |
46 | 36 |
|
47 | 37 | ```julia
|
48 |
| -import MLJTestIntegration |
| 38 | +import MLJDecisionTreeInterface |
| 39 | +import MLJTestInterface |
49 | 40 | using Test
|
50 |
| -X, y = MLJTestIntegration.make_multiclass() |
51 |
| -failures, summary = MLJTestIntegration.test([MyClassifier, ], X, y, verbosity=1, mod=@__MODULE__) |
| 41 | +X, y = MLJTestInterface.make_multiclass() |
| 42 | +failures, summary = MLJTestInterface.test( |
| 43 | + [MLJDecisionTreeInterface.DecisionTreeClassifier, ], |
| 44 | + X, y, |
| 45 | + verbosity=0, # set to 2 when debugging |
| 46 | + throw=false, # set to `true` when debugging |
| 47 | + mod=@__MODULE__, |
| 48 | +) |
52 | 49 | @test isempty(failures)
|
53 | 50 | ```
|
54 | 51 |
|
55 |
| -## Testing models after filtering models in the registry |
56 |
| - |
57 |
| -The following applies comprehensive integration tests to all |
58 |
| -regressors provided by the package GLM.jl appearing in the MLJ Model |
59 |
| -Registry. Since GLM.jl models are provided through the interface |
60 |
| -package `MLJGLMInterface`, this must be in the current environment: |
61 |
| - |
62 |
| -```julia |
63 |
| -Pkg.add("MLJGLMInterface") |
64 |
| -import MLJBase, MLJTestIntegration |
65 |
| -using DataFrames # to view summary |
66 |
| -X, y = MLJTestIntegration.MLJ.make_regression(); |
67 |
| -regressors = MLJTestIntegration.MLJ.models(matching(X, y)) do m |
68 |
| - m.package_name == "GLM" |
69 |
| -end |
70 |
| - |
71 |
| -# to test code loading: |
72 |
| -MLJTestIntegration.test(regressors, X, y, verbosity=2, mod=@__MODULE__, level=1) |
73 |
| - |
74 |
| -# comprehensive tests: |
75 |
| -failures, summary = |
76 |
| - MLJTestIntegration.test(regressors, X, y, verbosity=2, mod=@__MODULE__, level=4) |
77 |
| - |
78 |
| -summary |> DataFrame |
79 |
| -``` |
80 |
| - |
81 | 52 | # Datasets
|
82 | 53 |
|
83 |
| -The following commands generate datasets of the form `(X, y)` suitable for integration |
| 54 | +The following commands generate small datasets of the form `(X, y)` suitable for interface |
84 | 55 | tests:
|
85 | 56 |
|
86 |
| -- `MLJTestIntegration.make_binary` |
| 57 | +- `MLJTestInterface.make_binary` |
87 | 58 |
|
88 |
| -- `MLJTestIntegration.make_multiclass` |
| 59 | +- `MLJTestInterface.make_multiclass` |
89 | 60 |
|
90 |
| -- `MLJTestIntegration.make_regression` |
| 61 | +- `MLJTestInterface.make_regression` |
91 | 62 |
|
92 |
| -- `MLJTestIntegration.make_count` |
| 63 | +- `MLJTestInterface.make_count` |
93 | 64 |
|
0 commit comments