Skip to content

Latest commit

 

History

History
81 lines (59 loc) · 2.3 KB

predict_transform.md

File metadata and controls

81 lines (59 loc) · 2.3 KB

[predict, transform, and relatives](@id operations)

Standard methods:

predict(model, kind_of_proxy, data...) -> prediction
transform(model, data...) -> transformed_data
inverse_transform(model, data...) -> inverted_data

Methods consuming output, obsdata, of data-preprocessor obs:

obspredict(model, kind_of_proxy, obsdata) -> prediction
obstransform(model, obsdata) -> transformed_data

Typical worklows

# Train some supervised `algorithm`:
model = fit(algorithm, X, y)

# Predict probability distributions:= predict(model, Distribution(), Xnew)

# Generate point predictions:= predict(model, LiteralTarget(), Xnew)
# Training a dimension-reducing `algorithm`:
model = fit(algorithm, X)
Xnew_reduced = transform(model, Xnew)

# Apply an approximate right inverse:
inverse_transform(model, Xnew_reduced)

An advanced workflow

fitdata = obs(fit, algorithm, X, y)
predictdata = obs(predict, algorithm, Xnew)
model = obsfit(algorithm, obsdata)
ŷ = obspredict(model, LiteralTarget(), predictdata)

Implementation guide

The methods predict and transform are not directly overloaded. Implement obspredict and obstransform instead:

method compulsory? fallback requires
obspredict no none fit
obstransform no none fit
inverse_transform no none fit, obstransform

Predict or transform?

If the algorithm has a notion of [target variable](@ref proxy), then arrange for obspredict to output each supported [kind of target proxy](@ref proxy_types) (LiteralTarget(), Distribution(), etc).

For output not associated with a target variable, implement obstransform instead, which does not dispatch on LearnAPI.KindOfProxy, but can be optionally paired with an implementation of inverse_transform for returning (approximate) right inverses to transform.

Reference

predict
obspredict
transform
obstransform
inverse_transform