In expressions like
Plot[Through@{# &, #^2 &}@x, {x, -1, 1}]
Plot
effectively interprets the first argument as a vector-valued function, and plots both lines in the same colour:
To make Plot
interpret the first argument as a list of functions, we need to wrap the argument in Evaluate
, as in
Plot[Evaluate@Through@{# &, #^2 &}@x, {x, -1, 1}]
yielding
But what if the list of functions is a list of PredictorFunction
objects, each of which expects a numeric, or "Numerical", argument?
predictors = Predict[{1 -> 1, 2 -> 0, 3 -> -1, 4 -> 0}, Method -> #] &
/@ {"DecisionTree", "GaussianProcess"};
Plot[Evaluate@Through@predictors@x, {x, 0, 5}]
This yields the desired plot
but with PredictorFunction::mlincfttp
errors. Is there a way of doing this without generating the errors and without using Quiet
to suppress them? I need to pass the predictors as a list just like predictors
; there are too many to write out explicitly in the first argument to Plot
, as in {p1[x], p2[x], ...}
; I need a programmatic solution.
Quiet[]
, perhaps you can useOff[PredictorFunction::mlincfttp]
before the code is executed. Would that work? $\endgroup$