Skip to content

Commit 34f1bb2

Browse files
committed
TrueTarget -> LiteralTarget
1 parent d6b394e commit 34f1bb2

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

docs/src/anatomy_of_an_implementation.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
> returning the absolute values of the linear coefficients. The ridge regressor has a
99
> target variable and outputs literal predictions of the target (rather than, say,
1010
> probabilistic predictions); accordingly the overloaded `predict` method is dispatched on
11-
> the `TrueTarget` subtype of `KindOfProxy`. An **algorithm trait** declares this type as the
11+
> the `LiteralTarget` subtype of `KindOfProxy`. An **algorithm trait** declares this type as the
1212
> preferred kind of target proxy. Other traits articulate the algorithm's training data type
1313
> requirements and the input/output type of `predict`.
1414
@@ -110,7 +110,7 @@ level API, using those traits.
110110
Now we need a method for predicting the target on new input features:
111111

112112
```@example anatomy
113-
function LearnAPI.predict(::MyRidge, ::LearnAPI.TrueTarget, fitted_params, Xnew)
113+
function LearnAPI.predict(::MyRidge, ::LearnAPI.LiteralTarget, fitted_params, Xnew)
114114
Xmatrix = Tables.matrix(Xnew)
115115
report = nothing
116116
return Xmatrix*fitted_params.coefficients, report
@@ -119,7 +119,7 @@ nothing # hide
119119
```
120120

121121
The second argument of `predict` is always an instance of `KindOfProxy`, and will always
122-
be `TrueTarget()` in this case, as only literal values of the target (rather than, say
122+
be `LiteralTarget()` in this case, as only literal values of the target (rather than, say
123123
probabilistic predictions) are being supported.
124124

125125
In some algorithms `predict` computes something of interest in addition to the target
@@ -159,13 +159,13 @@ list). Accordingly, we are required to declare a preferred target proxy, which w
159159
[`LearnAPI.preferred_kind_of_proxy`](@ref):
160160

161161
```@example anatomy
162-
LearnAPI.preferred_kind_of_proxy(::Type{<:MyRidge}) = LearnAPI.TrueTarget()
162+
LearnAPI.preferred_kind_of_proxy(::Type{<:MyRidge}) = LearnAPI.LiteralTarget()
163163
nothing # hide
164164
```
165165
Or, you can use the shorthand
166166

167167
```@example anatomy
168-
@trait MyRidge preferred_kind_of_proxy=LearnAPI.TrueTarget()
168+
@trait MyRidge preferred_kind_of_proxy=LearnAPI.LiteralTarget()
169169
nothing # hide
170170
```
171171

@@ -307,7 +307,7 @@ feature_importances(algorithm, fitted_params, fit_report)
307307
Make a prediction using new data:
308308

309309
```@example anatomy
310-
yhat, predict_report = predict(algorithm, LearnAPI.TrueTarget(), fitted_params, X[test])
310+
yhat, predict_report = predict(algorithm, LearnAPI.LiteralTarget(), fitted_params, X[test])
311311
```
312312

313313
Compare predictions with ground truth

docs/src/operations.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Here's a snippet of code with a `LearnAPI.predict` call:
1717
```julia
1818
fitted_params, state, fit_report = LearnAPI.fit(some_algorithm, 1, X, y)
1919
ŷ, predict_report =
20-
LearnAPI.predict(some_algorithm, LearnAPI.TrueTarget(), fitted_params, Xnew)
20+
LearnAPI.predict(some_algorithm, LearnAPI.LiteralTarget(), fitted_params, Xnew)
2121
```
2222

2323
| method | compulsory? | fallback | requires |
@@ -43,7 +43,7 @@ ŷ, predict_report =
4343
## Predict or transform?
4444

4545
If the algorithm has a notion of [target variable](@ref proxy), then implement a `predict`
46-
method for each supported kind of target proxy (`TrueTarget()`, `Distribution()`,
46+
method for each supported kind of target proxy (`LiteralTarget()`, `Distribution()`,
4747
etc). See [Target proxies](@ref) below.
4848

4949
If an operation is to have an inverse operation, then it cannot be `predict` - use
@@ -70,7 +70,7 @@ LearnAPI.IID
7070
| type | form of an observation |
7171
|:-------------------------------:|:----------------------------------------------------|
7272
| `LearnAPI.None` | has no declared relationship with a target variable |
73-
| `LearnAPI.TrueTarget` | same as target observations |
73+
| `LearnAPI.LiteralTarget` | same as target observations |
7474
| `LearnAPI.Sampleable` | object that can be sampled to obtain object of the same form as target observation |
7575
| `LearnAPI.Distribution` | explicit probability density/mass function whose sample space is all possible target observations |
7676
| `LearnAPI.LogDistribution` | explicit log-probability density/mass function whose sample space is possible target observations |

src/algorithm_traits.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ LearnAPI.predict(algorithm::MyNewAlgorithmType, LearnAPI.Distribution(), Xnew) =
9898
Then we can declare
9999
100100
```julia
101-
@trait MyNewAlgorithmType preferred_kind_of_proxy = LearnAPI.TrueTarget()
101+
@trait MyNewAlgorithmType preferred_kind_of_proxy = LearnAPI.LiteralTarget()
102102
```
103103
104104
which is shorthand for
@@ -590,8 +590,8 @@ const DOC_PREDICT_OUTPUT(s) =
590590
Overloading the trait is optional. Here's a sample implementation for a supervised
591591
regressor type `MyRgs` that only predicts actual values of the target:
592592
593-
LearnAPI.predict(alogrithm::MyRgs, ::LearnAPI.TrueTarget, data...) = ...
594-
LearnAPI.predict_output_$(s)(::Type{<:MyRgs}, ::LearnAPI.TrueTarget) =
593+
LearnAPI.predict(alogrithm::MyRgs, ::LearnAPI.LiteralTarget, data...) = ...
594+
LearnAPI.predict_output_$(s)(::Type{<:MyRgs}, ::LearnAPI.LiteralTarget) =
595595
AbstractVector{ScientificTypesBase.Continuous}
596596
597597
The fallback method returns `Any`.
@@ -617,7 +617,7 @@ const DOC_PREDICT_OUTPUT2(s) =
617617
618618
Return a dictionary of upper bounds on the $(s) of predictions, keyed on concrete
619619
subtypes of [`LearnAPI.KindOfProxy`](@ref). Each of these subtypes respresents a
620-
different form of target prediction (`TrueTarget`, `Distribution`, `SurvivalFunction`,
620+
different form of target prediction (`LiteralTarget`, `Distribution`, `SurvivalFunction`,
621621
etc) possibly supported by `algorithm`, but the existence of a key does not guarantee
622622
that form is supported.
623623

src/operations.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ as observations) or a proxy for these, for the specified `algorithm` having lear
2525
parameters `fitted_params` (first object returned by [`LearnAPI.fit`](@ref)`(algorithm,
2626
...)`). $DOC_NEW_DATA
2727
28-
Where available, use `kind_of_proxy=TrueTarget()` for ordinary target predictions, and
28+
Where available, use `kind_of_proxy=LiteralTarget()` for ordinary target predictions, and
2929
`kind_of_proxy=Distribution()` for PDF/PMF predictions. Always available is
3030
`kind_of_proxy=`LearnAPI.preferred_kind_of_proxy(algorithm)`.
3131
@@ -157,7 +157,7 @@ See also [`LearnAPI.KindOfProxy`](@ref).
157157
"""
158158
abstract type IID <: KindOfProxy end
159159

160-
struct TrueTarget <: IID end
160+
struct LiteralTarget <: IID end
161161
struct Sampleable <: IID end
162162
struct Distribution <: IID end
163163
struct LogDistribution <: IID end

0 commit comments

Comments
 (0)