Skip to content

EVALUATE: predict across the range of an input variable #1178

Description

@gjwgit

Split out from #1174, where this was point (1). Point (2) of that issue,
scoring a larger dataset, is done and is tracked in #1175.

What is wanted

A table, and a chart, that shows how the prediction changes as one input
variable is varied across its range, with the other inputs held at values the
user chooses. One row per value of the varied variable, each with the
prediction and its probability.

In the weather dataset, for example: enter a min temp, a max temp and a cloud
cover, then vary the humidity from its lowest to its highest value in the
data, and see the predicted likelihood of rain tomorrow at each step.

This is a natural extension of the Interactive button on the EVALUATE tab
(6.5.39), which already collects a value for every input variable and predicts
that one observation with each ticked model. The step beyond it is to nominate
one variable to vary, build a grid rather than a single row, and plot the
result.

Known elsewhere as an ICE curve, or predictions at representative values, and
it is what the at = argument of the
prediction
package produces.

Notes towards building it

No new R dependency is needed. Every evaluate_model_*.R script sets
model and defines pred_ra() and prob_ra() for it, and those work on a
data frame of any number of rows just as well as on the single row the
Interactive popup builds today. The prediction package has 67 methods, but
not randomForest, xgboost, ada, ctree/cforest or neuralnet, so it
would cover fewer of our models than we already cover ourselves.

The shape of the curve depends on the model, and this needs designing for.
Measured over the weather data:

  • Decision tree, varying humidity_3pm: a single step, 0.06 below about 75%
    humidity and 0.85 above it. A tree is piecewise constant, so its curve is
    always a step function.
  • Linear model, same variable: a smooth curve from 0.0007 to 0.99.
  • Decision tree, varying rainfall: a flat line, because that tree never
    splits on rainfall.

A flat line is a truthful answer, the model genuinely ignores that variable,
but it will be reported as a bug unless the display says so. Defaulting the
varied variable to one the model actually uses, and showing several models on
the one chart, would both help.

Varying a derived variable can produce impossible observations. In the
weather data rain_today follows from rainfall, so sweeping rainfall
while holding rain_today at No asks the model about combinations that cannot
occur. Worth a note in the tooltip at least.

The example in #1174 reads two ways. Sweeping today's rainfall from 0 to
its maximum and reporting the predicted likelihood of rain tomorrow is
straightforward with the models Rattle builds. Reporting the likelihood of
each possible volume of rain tomorrow is a different question, needing a
distributional or quantile model, and is not something any current Rattle
model can answer. Worth settling which is meant before building.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions