1
$\begingroup$

I am trying some basic machine learning with Mathematica. I am wondering if I can see the function that Mathematica produces for a training set. I give the following example:

trainingset = {1 -> 1.3, 2 -> 2.4, 3 -> 4.4, 4 -> 5.1, 6 -> 7.3}; p = Predict[trainingset, Method -> "LinearRegression"]

If I type p[1.5], it will give me the predicted value. However, could I also see/know somehow the function used, e.g. for this case in the form of y=a*x+b, (where x is the variable)? Is there a way to see the predicted function?

$\endgroup$
3
$\begingroup$

It turns out that PredictorFunctions are implemented in a nice and transparent way as PredictorFunction[ Association[...]]. So execute p[[1]] and everything is laid out nicely for you.

$\endgroup$
  • $\begingroup$ Thank you Henrik, this was very helpful! Still though, I don't get how can I see the function. Sorry for my ignorance. $\endgroup$ – harazogo Jun 19 '18 at 9:22
  • $\begingroup$ Well, the actual predictor consists of one or more neural nets with pre- and postprocessors. Very complicated. You can try to inspect trace = Trace[p[1.5]]; in order to guess what is going on... The working of FindFit or LinearModelFit might be easier to graps. $\endgroup$ – Henrik Schumacher Jun 19 '18 at 11:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.