@@ -5,20 +5,28 @@ Return, for each form of `data` supported in a call of the form [`fit(learner,
5
5
data)`](@ref), the target variable part of `data`. If `nothing` is returned, the
6
6
`learner` does not see a target variable in training (is unsupervised).
7
7
8
+ The returned object `y` has the same number of observations as `data`. If `data` is the
9
+ output of an [`obs`](@ref) call, then `y` is additionally guaranteed to implement the
10
+ data interface specified by [`LearnAPI.data_interface(learner)`](@ref).
11
+
8
12
# Extended help
9
13
10
14
## What is a target variable?
11
15
12
- Examples of target variables are house prices in realestate pricing estimates, the
16
+ Examples of target variables are house prices in real estate pricing estimates, the
13
17
"spam"/"not spam" labels in an email spam filtering task, "outlier"/"inlier" labels in
14
18
outlier detection, cluster labels in clustering problems, and censored survival times in
15
19
survival analysis. For more on targets and target proxies, see the "Reference" section of
16
20
the LearnAPI.jl documentation.
17
21
18
22
## New implementations
19
23
20
- A fallback returns `nothing`. Must be implemented if `fit` consumes data including a
21
- target variable.
24
+ A fallback returns `nothing`. The method must be overloaded if `fit` consumes data
25
+ including a target variable.
26
+
27
+ If overloading [`obs`](@ref), ensure that the return value, unless `nothing`, implements
28
+ the data interface specified by [`LearnAPI.data_interface(learner)`](@ref), in the special
29
+ case that `data` is the output of an `obs` call.
22
30
23
31
$(DOC_IMPLEMENTED_METHODS (" :(LearnAPI.target)" ; overloaded= true ))
24
32
@@ -32,10 +40,20 @@ Return, for each form of `data` supported in a call of the form [`fit(learner,
32
40
data)`](@ref), the per-observation weights part of `data`. Where `nothing` is returned, no
33
41
weights are part of `data`, which is to be interpreted as uniform weighting.
34
42
43
+ The returned object `w` has the same number of observations as `data`. If `data` is the
44
+ output of an [`obs`](@ref) call, then `w` is additionally guaranteed to implement the
45
+ data interface specified by [`LearnAPI.data_interface(learner)`](@ref).
46
+
47
+ # Extended help
48
+
35
49
# New implementations
36
50
37
51
Overloading is optional. A fallback returns `nothing`.
38
52
53
+ If overloading [`obs`](@ref), ensure that the return value, unless `nothing`, implements
54
+ the data interface specified by [`LearnAPI.data_interface(learner)`](@ref), in the special
55
+ case that `data` is the output of an `obs` call.
56
+
39
57
$(DOC_IMPLEMENTED_METHODS (" :(LearnAPI.weights)" ; overloaded= true ))
40
58
41
59
"""
@@ -53,26 +71,34 @@ implemented, as in the following sample workflow:
53
71
54
72
```julia
55
73
model = fit(learner, data)
56
- X = features(data)
74
+ X = LearnAPI. features(learner, data)
57
75
ŷ = predict(learner, kind_of_proxy, X) # eg, `kind_of_proxy = Point()`
58
76
```
59
77
60
- The returned object has the same number of observations as `data`. For supervised models
61
- (i.e., where `:(LearnAPI.target) in LearnAPI.functions(learner)`) `ŷ` above is generally
62
- intended to be an approximate proxy for `LearnAPI.target(learner, data)`, the training
63
- target.
78
+ For supervised models (i.e., where `:(LearnAPI.target) in LearnAPI.functions(learner)`)
79
+ `ŷ` above is generally intended to be an approximate proxy for `LearnAPI.target(learner,
80
+ data)`, the training target.
81
+
82
+ The object `X` returned by `LearnAPI.target` has the same number of observations as
83
+ `data`. If `data` is the output of an [`obs`](@ref) call, then `X` is additionally
84
+ guaranteed to implement the data interface specified by
85
+ [`LearnAPI.data_interface(learner)`](@ref).
64
86
87
+ # Extended help
65
88
66
89
# New implementations
67
90
68
- That the output can be passed to `predict` and/or `transform`, and has the same number of
69
- observations as `data`, are the only contracts. A fallback returns `first(data)` if `data`
70
- is a tuple, and otherwise returns `data`.
91
+ For density estimators, whose `fit` typically consumes *only* a target variable, you
92
+ should overload this method to return `nothing`.
93
+
94
+ It must otherwise be possible to pass the return value `X` to `predict` and/or
95
+ `transform`, and `X` must have same number of observations as `data`. A fallback returns
96
+ `first(data)` if `data` is a tuple, and otherwise returns `data`.
71
97
72
- Overloading may be necessary if [`obs(learner, data)`](@ref) is overloaded to return
73
- some learner-specific representation of training `data`. For density estimators, whose
74
- `fit` typically consumes *only* a target variable, you should overload this method to
75
- return `nothing` .
98
+ Further overloadings may be necessary to handle the case that ` data` is the output of
99
+ [`obs( learner, data)`](@ref), if `obs` is being overloaded. In this case, be sure that
100
+ `X`, unless `nothing`, implements the data interface specified by
101
+ [`LearnAPI.data_interface(learner)`](@ref) .
76
102
77
103
"""
78
104
features (learner, data) = _first (data)
0 commit comments