Skip to content

Commit 11b38cf

Browse files
committed
rename LiteralTarget -> Point
1 parent d69c5b0 commit 11b38cf

13 files changed

+82
-88
lines changed

docs/src/anatomy_of_an_implementation.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,19 +129,19 @@ end
129129
Users will be able to call `predict` like this:
130130

131131
```julia
132-
predict(model, LiteralTarget(), Xnew)
132+
predict(model, Point(), Xnew)
133133
```
134134

135-
where `Xnew` is a table (of the same form as `X` above). The argument `LiteralTarget()`
135+
where `Xnew` is a table (of the same form as `X` above). The argument `Point()`
136136
signals that literal predictions of the target variable are sought, as opposed to some
137-
proxy for the target, such as probability density functions. `LiteralTarget` is an
137+
proxy for the target, such as probability density functions. `Point` is an
138138
example of a [`LearnAPI.KindOfProxy`](@ref proxy_types) type. Targets and target proxies
139139
are discussed [here](@ref proxy).
140140

141141
We provide this implementation for our ridge regressor:
142142

143143
```@example anatomy
144-
LearnAPI.predict(model::RidgeFitted, ::LiteralTarget, Xnew) =
144+
LearnAPI.predict(model::RidgeFitted, ::Point, Xnew) =
145145
Tables.matrix(Xnew)*model.coefficients
146146
```
147147

@@ -210,7 +210,7 @@ Because we have implemented `predict`, we are required to overload the
210210
target, we make this definition:
211211

212212
```julia
213-
LearnAPI.kinds_of_proxy(::Ridge) = (LiteralTarget(),)
213+
LearnAPI.kinds_of_proxy(::Ridge) = (Point(),)
214214
```
215215

216216
A macro provides a shortcut, convenient when multiple traits are to be defined:
@@ -219,7 +219,7 @@ A macro provides a shortcut, convenient when multiple traits are to be defined:
219219
@trait(
220220
Ridge,
221221
constructor = Ridge,
222-
kinds_of_proxy=(LiteralTarget(),),
222+
kinds_of_proxy=(Point(),),
223223
tags = (:regression,),
224224
functions = (
225225
:(LearnAPI.fit),
@@ -326,7 +326,7 @@ LearnAPI.minimize(model::RidgeFitted) =
326326
@trait(
327327
Ridge,
328328
constructor = Ridge,
329-
kinds_of_proxy=(LiteralTarget(),),
329+
kinds_of_proxy=(Point(),),
330330
tags = (:regression,),
331331
functions = (
332332
:(LearnAPI.fit),
@@ -424,11 +424,11 @@ case:
424424
```@example anatomy2
425425
LearnAPI.obs(::RidgeFitted, Xnew) = Tables.matrix(Xnew)'
426426
427-
LearnAPI.predict(model::RidgeFitted, ::LiteralTarget, observations::AbstractMatrix) =
427+
LearnAPI.predict(model::RidgeFitted, ::Point, observations::AbstractMatrix) =
428428
observations'*model.coefficients
429429
430-
LearnAPI.predict(model::RidgeFitted, ::LiteralTarget, Xnew) =
431-
predict(model, LiteralTarget(), obs(model, Xnew))
430+
LearnAPI.predict(model::RidgeFitted, ::Point, Xnew) =
431+
predict(model, Point(), obs(model, Xnew))
432432
```
433433

434434
### `target` and `features` methods

docs/src/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ LearnAPI.functions(forest)
5050
model = fit(forest, X, y)
5151

5252
# Generate point predictions:
53-
= predict(model, Xnew) # or `predict(model, LiteralTarget(), Xnew)`
53+
= predict(model, Xnew) # or `predict(model, Point(), Xnew)`
5454

5555
# Predict probability distributions:
5656
predict(model, Distribution(), Xnew)
@@ -65,10 +65,10 @@ serialize("my_random_forest.jls", small_model)
6565
# Recover saved model and algorithm configuration:
6666
recovered_model = deserialize("my_random_forest.jls")
6767
@assert LearnAPI.algorithm(recovered_model) == forest
68-
@assert predict(recovered_model, LiteralTarget(), Xnew) ==
68+
@assert predict(recovered_model, Point(), Xnew) ==
6969
```
7070

71-
`Distribution` and `LiteralTarget` are singleton types owned by LearnAPI.jl. They allow
71+
`Distribution` and `Point` are singleton types owned by LearnAPI.jl. They allow
7272
dispatch based on the [kind of target proxy](@ref proxy), a key LearnAPI.jl concept.
7373
LearnAPI.jl places more emphasis on the notion of target variables and target proxies than
7474
on the usual supervised/unsupervised learning dichotomy. From this point of view, a

docs/src/kinds_of_target_proxy.md

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -14,64 +14,14 @@ LearnAPI.KindOfProxy
1414
LearnAPI.IID
1515
```
1616

17-
| type | form of an observation |
18-
|:-------------------------------------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
19-
| `LearnAPI.LiteralTarget` | same as target observations; may have the interpretation of a 50% quantile, 50% expectile or mode |
20-
| `LearnAPI.Sampleable` | object that can be sampled to obtain object of the same form as target observation |
21-
| `LearnAPI.Distribution` | explicit probability density/mass function whose sample space is all possible target observations |
22-
| `LearnAPI.LogDistribution` | explicit log-probability density/mass function whose sample space is possible target observations |
23-
| `LearnAPI.Probability`¹ | numerical probability or probability vector |
24-
| `LearnAPI.LogProbability`¹ | log-probability or log-probability vector |
25-
| `LearnAPI.Parametric`¹ | a list of parameters (e.g., mean and variance) describing some distribution |
26-
| `LearnAPI.LabelAmbiguous` | collections of labels (in case of multi-class target) but without a known correspondence to the original target labels (and of possibly different number) as in, e.g., clustering |
27-
| `LearnAPI.LabelAmbiguousSampleable` | sampleable version of `LabelAmbiguous`; see `Sampleable` above |
28-
| `LearnAPI.LabelAmbiguousDistribution` | pdf/pmf version of `LabelAmbiguous`; see `Distribution` above |
29-
| `LearnAPI.LabelAmbiguousFuzzy` | same as `LabelAmbiguous` but with multiple values of indeterminant number |
30-
| `LearnAPI.Quantile`² | same as target but with quantile interpretation |
31-
| `LearnAPI.Expectile`² | same as target but with expectile interpretation |
32-
| `LearnAPI.ConfidenceInterval`² | confidence interval |
33-
| `LearnAPI.Fuzzy` | finite but possibly varying number of target observations |
34-
| `LearnAPI.ProbabilisticFuzzy` | as for `Fuzzy` but labeled with probabilities (not necessarily summing to one) |
35-
| `LearnAPI.SurvivalFunction` | survival function |
36-
| `LearnAPI.SurvivalDistribution` | probability distribution for survival time |
37-
| `LearnAPI.SurvivalHazardFunction` | hazard function for survival time |
38-
| `LearnAPI.OutlierScore` | numerical score reflecting degree of outlierness (not necessarily normalized) |
39-
| `LearnAPI.Continuous` | real-valued approximation/interpolation of a discrete-valued target, such as a count (e.g., number of phone calls) |
40-
41-
¹Provided for completeness but discouraged to avoid [ambiguities in
42-
representation](https://github.com/alan-turing-institute/MLJ.jl/blob/dev/paper/paper.md#a-unified-approach-to-probabilistic-predictions-and-their-evaluation).
43-
44-
²The level will be controlled by a hyper-parameter; models providing only quantiles or
45-
expectiles at 50% will provide `LiteralTarget` instead.
46-
47-
> Table of concrete subtypes of `LearnAPI.IID <: LearnAPI.KindOfProxy`.
48-
49-
5017
## Proxies for density estimation lgorithms
5118

5219
```@docs
5320
LearnAPI.Single
5421
```
5522

56-
| type `T` | form of output of `predict(model, ::T)` |
57-
|:--------------------------------:|:-----------------------------------------------------------------------|
58-
| `LearnAPI.SingleSampleable` | object that can be sampled to obtain a single target observation |
59-
| `LearnAPI.SingleDistribution` | explicit probability density/mass function for sampling the target |
60-
| `LearnAPI.SingleLogDistribution` | explicit log-probability density/mass function for sampling the target |
61-
62-
> Table of `LearnAPI.KindOfProxy` subtypes subtyping `LearnAPI.Single`
63-
64-
6523
## Joint probability distributions
6624

6725
```@docs
6826
LearnAPI.Joint
6927
```
70-
71-
| type `T` | form of output of `predict(model, ::T, data)` |
72-
|:-------------------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------|
73-
| `LearnAPI.JointSampleable` | object that can be sampled to obtain a *vector* whose elements have the form of target observations; the vector length matches the number of observations in `data`. |
74-
| `LearnAPI.JointDistribution` | explicit probability density/mass function whose sample space is vectors of target observations; the vector length matches the number of observations in `data` |
75-
| `LearnAPI.JointLogDistribution` | explicit log-probability density/mass function whose sample space is vectors of target observations; the vector length matches the number of observations in `data` |
76-
77-
> Table of `LearnAPI.KindOfProxy` subtypes subtyping `LearnAPI.Joint`

docs/src/minimize.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ minimize(model) -> <smaller version of model suitable for serialization>
88

99
```julia
1010
model = fit(algorithm, (X, y)) # or `fit(algorithm, X, y)`
11-
= predict(model, LiteralTarget(), Xnew)
11+
= predict(model, Point(), Xnew)
1212
LearnAPI.feature_importances(model)
1313

1414
small_model = minimize(model)
1515
serialize("my_model.jls", small_model)
1616

1717
recovered_model = deserialize("my_random_forest.jls")
18-
@assert predict(recovered_model, LiteralTarget(), Xnew) ==
18+
@assert predict(recovered_model, Point(), Xnew) ==
1919

2020
# throws MethodError:
2121
LearnAPI.feature_importances(recovered_model)

docs/src/obs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ scores = map(train_test_folds) do (train, test)
6868
global never_trained = false
6969
end
7070
predictobs_subset = MLUtils.getobs(predictobs, test)
71-
= predict(model, LiteralTarget(), predictobs_subset)
71+
= predict(model, Point(), predictobs_subset)
7272

7373
return <score comparing ŷ with y[test]>
7474

docs/src/predict_transform.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ ŷ = predict(model, Distribution(), Xnew)
2727
Generate point predictions:
2828

2929
```julia
30-
= predict(model, LiteralTarget(), Xnew)
30+
= predict(model, Point(), Xnew)
3131
```
3232

3333
Train a dimension-reducing `algorithm`:
@@ -49,7 +49,7 @@ inverse_transform(model, Xnew_reduced)
4949
fitobs = obs(algorithm, (X, y)) # algorithm-specific repr. of data
5050
model = fit(algorithm, MLUtils.getobs(fitobs, 1:100))
5151
predictobs = obs(model, MLUtils.getobs(X, 101:150))
52-
= predict(model, LiteralTarget(), predictobs)
52+
= predict(model, Point(), predictobs)
5353
```
5454

5555

@@ -65,7 +65,7 @@ ŷ = predict(model, LiteralTarget(), predictobs)
6565

6666
If the algorithm has a notion of [target variable](@ref proxy), then use
6767
[`predict`](@ref) to output each supported [kind of target proxy](@ref
68-
proxy_types) (`LiteralTarget()`, `Distribution()`, etc).
68+
proxy_types) (`Point()`, `Distribution()`, etc).
6969

7070
For output not associated with a target variable, implement [`transform`](@ref)
7171
instead, which does not dispatch on [`LearnAPI.KindOfProxy`](@ref), but can be optionally

docs/src/target_weights_features.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ target:
2222
model = fit(algorithm, data)
2323
X = LearnAPI.features(algorithm, data)
2424
y = LearnAPI.target(algorithm, data)
25-
= predict(model, LiteralTarget(), X)
25+
= predict(model, Point(), X)
2626
training_loss = sum(ŷ .!= y)
2727
```
2828

src/obs.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Usual workflow, using data-specific resampling methods:
2424
data = (X, y) # a DataFrame and a vector
2525
data_train = (Tables.select(X, 1:100), y[1:100])
2626
model = fit(algorithm, data_train)
27-
ŷ = predict(model, LiteralTarget(), X[101:150])
27+
ŷ = predict(model, Point(), X[101:150])
2828
```
2929
3030
Alternative workflow using `obs` and the MLUtils.jl method `getobs` (assumes
@@ -37,7 +37,7 @@ fit_observations = obs(algorithm, data)
3737
model = fit(algorithm, MLUtils.getobs(fit_observations, 1:100))
3838
3939
predict_observations = obs(model, X)
40-
ẑ = predict(model, LiteralTarget(), MLUtils.getobs(predict_observations, 101:150))
40+
ẑ = predict(model, Point(), MLUtils.getobs(predict_observations, 101:150))
4141
@assert ẑ == ŷ
4242
```
4343

src/predict_transform.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ DOC_DATA_INTERFACE(method) =
5757
5858
The first signature returns target predictions, or proxies for target predictions, for
5959
input features `data`, according to some `model` returned by [`fit`](@ref). Where
60-
supported, these are literally target predictions if `kind_of_proxy = LiteralTarget()`,
60+
supported, these are literally target predictions if `kind_of_proxy = Point()`,
6161
and probability density/mass functions if `kind_of_proxy = Distribution()`. List all
6262
options with [`LearnAPI.kinds_of_proxy(algorithm)`](@ref), where `algorithm =
6363
LearnAPI.algorithm(model)`.
@@ -75,7 +75,7 @@ training features `X`, training target `y`, and test features `Xnew`:
7575
7676
```julia
7777
model = fit(algorithm, (X, y)) # or `fit(algorithm, X, y)`
78-
predict(model, LiteralTarget(), Xnew)
78+
predict(model, Point(), Xnew)
7979
```
8080
8181
See also [`fit`](@ref), [`transform`](@ref), [`inverse_transform`](@ref).

src/target_weights_features.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ implemented, as in the following sample workflow:
4646
```julia
4747
model = fit(algorithm, data)
4848
X = features(data)
49-
ŷ = predict(algorithm, kind_of_proxy, X) # eg, `kind_of_proxy = LiteralTarget()`
49+
ŷ = predict(algorithm, kind_of_proxy, X) # eg, `kind_of_proxy = Point()`
5050
```
5151
5252
The return value has the same number of observations as `data` does. For supervised models

0 commit comments

Comments
 (0)