@@ -65,12 +65,18 @@ with `learner`, or an associated model (object returned by `fit(learner, ...)`,
65
65
first argument. Learner traits (methods for which `learner` is the *only* argument)
66
66
are excluded.
67
67
68
+ To return actual functions, instead of symbols, use [`@functions`](@ref)` learner`
69
+ instead.
70
+
68
71
The returned tuple may include expressions like `:(DecisionTree.print_tree)`, which
69
72
reference functions not owned by LearnAPI.jl.
70
73
71
74
The understanding is that `learner` is a LearnAPI-compliant object whenever the return
72
75
value is non-empty.
73
76
77
+ Do `LearnAPI.functions()` to list all possible elements of the return value owned by
78
+ LearnAPI.jl.
79
+
74
80
# Extended help
75
81
76
82
# New implementations
@@ -100,6 +106,7 @@ learner-specific ones. The LearnAPI.jl accessor functions are: $ACCESSOR_FUNCTIO
100
106
(`LearnAPI.strip` is always included).
101
107
102
108
"""
109
+ functions (:: Any ) = ()
103
110
functions () = (
104
111
:(LearnAPI. fit),
105
112
:(LearnAPI. learner),
@@ -114,8 +121,34 @@ functions() = (
114
121
:(LearnAPI. predict),
115
122
:(LearnAPI. transform),
116
123
:(LearnAPI. inverse_transform),
124
+ ACCESSOR_FUNCTIONS... ,
117
125
)
118
- functions (:: Any ) = ()
126
+
127
+ """
128
+ @functions learner
129
+
130
+ Return a tuple of functions that can be meaningfully applied with `learner`, or an
131
+ associated model, as the first argument. An "associated model" is an object returned by
132
+ `fit(learner, ...)`. Learner traits (methods for which `learner` is the *only* argument)
133
+ are excluded.
134
+
135
+ ```
136
+ julia> @functions my_feature_selector
137
+ (fit, LearnAPI.learner, strip, obs, transform)
138
+
139
+ ```
140
+
141
+ New learner implementations should overload [`LearnAPI.functions`](@ref).
142
+
143
+ See also [`LearnAPI.functions`](@ref).
144
+
145
+ """
146
+ macro functions (learner)
147
+ quote
148
+ exs = LearnAPI. functions (learner)
149
+ eval .(exs)
150
+ end |> esc
151
+ end
119
152
120
153
"""
121
154
LearnAPI.kinds_of_proxy(learner)
0 commit comments