@@ -13,12 +13,20 @@ DOC_MUTATION(op) =
13
13
14
14
"""
15
15
16
+ DOC_SLURPING (op) =
17
+ """
18
+
19
+ An algorithm is free to implement `$op ` signatures with additional positional
20
+ arguments (eg., data-slurping signatures) but LearnAPI.jl is silent about their
21
+ interpretation or existence.
22
+
23
+ """
16
24
17
25
DOC_MINIMIZE (func) =
18
26
"""
19
27
20
- If, additionally, [`LearnAPI.strip(model)`](@ref) is overloaded, then the following identity
21
- must hold:
28
+ If, additionally, [`LearnAPI.strip(model)`](@ref) is overloaded, then the following
29
+ identity must hold:
22
30
23
31
```julia
24
32
$func (LearnAPI.strip(model), args...) = $func (model, args...)
@@ -63,7 +71,7 @@ which lists all supported target proxies.
63
71
The argument `model` is anything returned by a call of the form `fit(algorithm, ...)`.
64
72
65
73
If `LearnAPI.features(LearnAPI.algorithm(model)) == nothing`, then argument `data` is
66
- omitted. An example is density estimators.
74
+ omitted in both signatures . An example is density estimators.
67
75
68
76
# Example
69
77
@@ -79,20 +87,20 @@ See also [`fit`](@ref), [`transform`](@ref), [`inverse_transform`](@ref).
79
87
80
88
# Extended help
81
89
82
- If `predict` supports data in the form of a tuple `data = (X1, ..., Xn)`, then a slurping
83
- signature is also provided, as in `predict(model, X1, ..., Xn)`.
84
-
85
- Note `predict ` does not mutate any argument, except in the special case
90
+ Note `predict ` must not mutate any argument, except in the special case
86
91
`LearnAPI.is_static(algorithm) == true`.
87
92
88
93
# New implementations
89
94
90
95
If there is no notion of a "target" variable in the LearnAPI.jl sense, or you need an
91
96
operation with an inverse, implement [`transform`](@ref) instead.
92
97
93
- Implementation is optional. Only the first signature is implemented, but each
94
- `kind_of_proxy` that gets an implementation must be added to the list returned by
95
- [`LearnAPI.kinds_of_proxy`](@ref).
98
+ Implementation is optional. Only the first signature (with or without the `data` argument)
99
+ is implemented, but each `kind_of_proxy` that gets an implementation must be added to the
100
+ list returned by [`LearnAPI.kinds_of_proxy`](@ref).
101
+
102
+ If `data` is not present in the implemented signature (eg., for density estimators) then
103
+ [`LearnAPI.features(algorithm, data)`](@ref) must return `nothing`.
96
104
97
105
$(DOC_IMPLEMENTED_METHODS (" :(LearnAPI.predict)" ))
98
106
@@ -106,23 +114,12 @@ $(DOC_DATA_INTERFACE(:predict))
106
114
predict (model, data) = predict (model, kinds_of_proxy (algorithm (model)) |> first, data)
107
115
predict (model) = predict (model, kinds_of_proxy (algorithm (model)) |> first)
108
116
109
- # automatic slurping of multiple data arguments:
110
- predict (model, k:: KindOfProxy , data1, data2, datas... ; kwargs... ) =
111
- predict (model, k, (data1, data2, datas... ); kwargs... )
112
- predict (model, data1, data2, datas... ; kwargs... ) =
113
- predict (model, (data1, data2, datas... ); kwargs... )
114
-
115
-
116
-
117
117
"""
118
118
transform(model, data)
119
119
120
120
Return a transformation of some `data`, using some `model`, as returned by
121
121
[`fit`](@ref).
122
122
123
- For `data` that consists of a tuple, a slurping version is also provided, i.e., you can do
124
- `transform(model, X1, X2, X3)` in place of `transform(model, (X1, X2, X3))`.
125
-
126
123
# Example
127
124
128
125
Below, `X` and `Xnew` are data of the same form.
@@ -157,8 +154,10 @@ See also [`fit`](@ref), [`predict`](@ref),
157
154
158
155
# New implementations
159
156
160
- Implementation for new LearnAPI.jl algorithms is optional. A fallback provides the
161
- slurping version. $(DOC_IMPLEMENTED_METHODS (" :(LearnAPI.transform)" ))
157
+ Implementation for new LearnAPI.jl algorithms is
158
+ optional. $(DOC_IMPLEMENTED_METHODS (" :(LearnAPI.transform)" ))
159
+
160
+ $(DOC_SLURPING (:transform ))
162
161
163
162
$(DOC_MINIMIZE (:transform ))
164
163
@@ -167,8 +166,8 @@ $(DOC_MUTATION(:transform))
167
166
$(DOC_DATA_INTERFACE (:transform ))
168
167
169
168
"""
170
- transform (model, data1, data2, datas ... ; kwargs ... ) =
171
- transform (model, (data1, data2, datas ... ); kwargs ... ) # automatic slurping
169
+ function transform end
170
+
172
171
173
172
"""
174
173
inverse_transform(model, data)
0 commit comments