@@ -54,8 +54,19 @@ For each supported form of `data` in `fit(learner, data)`, it must be true that
54
54
fit(learner, observations)` is equivalent to `model = fit(learner, data)`, whenever
55
55
`observations = obs(learner, data)`. For each supported form of `data` in calls
56
56
`predict(model, ..., data)` and `transform(model, data)`, where implemented, the calls
57
- `predict(model, ..., observations)` and `transform(model, observations)` are supported
58
- alternatives, whenever `observations = obs(model, data)`.
57
+ `predict(model, ..., observations)` and `transform(model, observations)` must be supported
58
+ alternatives with the same output, whenever `observations = obs(model, data)`.
59
+
60
+ Implicit in the above requirements is that `obs(learner, _)` and `obs(model, _)` are
61
+ involutive, meaning both the following hold:
62
+
63
+ ```julia
64
+ obs(learner, obs(learner, data)) == obs(learner, data)
65
+ obs(model, obs(model, data) == obs(model, obs(model, data)
66
+ ```
67
+
68
+ If one overloads `obs`, one typically needs additionally overloadings to guarantee
69
+ involutivity.
59
70
60
71
The fallback for `obs` is `obs(model_or_learner, data) = data`, and the fallback for
61
72
`LearnAPI.data_interface(learner)` is `LearnAPI.RandomAccess()`. For details refer to
@@ -67,14 +78,16 @@ to be overloaded. However, the user will get no performance benefits by using `o
67
78
that case.
68
79
69
80
When overloading `obs(learner, data)` to output new model-specific representations of
70
- data, it may be necessary to also overload [`LearnAPI.features`](@ref),
71
- [`LearnAPI.target`](@ref) (supervised learners), and/or [`LearnAPI.weights`](@ref) (if
72
- weights are supported), for extracting relevant parts of the representation.
81
+ data, it may be necessary to also overload [`LearnAPI.features(learner,
82
+ observations)`](@ref), [`LearnAPI.target(learner, observations)`](@ref) (supervised
83
+ learners), and/or [`LearnAPI.weights(learner, observations)`](@ref) (if weights are
84
+ supported), for each kind output `observations` of `obs(learner, data)`.
73
85
74
86
## Sample implementation
75
87
76
- Refer to the "Anatomy of an Implementation" section of the LearnAPI.jl
77
- [manual](https://juliaai.github.io/LearnAPI.jl/dev/).
88
+ Refer to the ["Anatomy of an
89
+ Implementation"](https://juliaai.github.io/LearnAPI.jl/dev/anatomy_of_an_implementation/#Providing-an-advanced-data-interface)
90
+ section of the LearnAPI.jl manual.
78
91
79
92
80
93
"""
0 commit comments