I need to test my machine learning models that I’ve built using Predict
on 100,000 observations. The problem is that the machine where the testing is done doesn’t have Mathematica. I would like to find an alternative to the cloud if possible. I don’t think I have or can have enough cloud credit to do the testing.
3 Answers
This depends on what Method
you pick.
If you use Method->"LinearRegression"
it is possible to do like PredictorInformation[p, "Function"]
, which returns the formula that you can use in any code.
If you use Method->"NeuralNetwork"
it is possible to export the network to MXNet, which you can then use (with some caveats) on other machines.
(p /. PredictorFunction -> Association)["Model", "Network"]
This will return the trained Neural Network, which you can then export to MXNet:
Export["mynet.json", (p /. PredictorFunction -> Association)["Model", "Network"], "MXNet"]
This exports a .json
file (the network specification) and a .params
file, which contains the layer weights.
Caveats include NetEncoder
s and NetDecoder
s not being included in this specification, so if you trained on images or audio or something, you need to recreate the encoder in your chosen language.
If you use Method->"GaussianProcess"
, it's possible that PredictorInformation[p, "OptimizedGaussianProcessModel"]
will give you something useful - but to be honest, I have no idea what a Gaussian Process is. My expectation is that the result of that function gives you a list of parameters to plug into some standard formula, but I haven't a clue unfortunately.
If you use Method->"NearestNeighbor"
, it's not clear to me that you can export anything useful. This method appears to use Nearest
underneath, and I am unclear on whether you can export a NearestFunction
usefully. If this is your issue, probably best to search here and then open a new question if it's not obvious.
If you use Method->"DecisionTree"
, Method->"RandomForest"
or Method->"GradientBoostedTrees"
, it is unclear to me that you can export any part of the results meaningfully.
If can be useful to look at the Normal
of your trained PredictorFunction
(eg, Normal@p
), as well as PredictorInformation[p, "Properties"]
. They may enlighten you on what your predictor is doing underneath. (In future versions of WL, just Information
should work.)
You may want to export it using something like mxnet.
-
$\begingroup$ ThankYou! Can you please direct me to a website? $\endgroup$ Jan 20, 2019 at 13:20
-
-
$\begingroup$ How can a
PredictorFunction
(which is whatPredict
returns) be exported to MXNet? $\endgroup$– C. E.Mar 17, 2019 at 18:48 -
$\begingroup$ @C.E. I believe that if you use
Method->"NeuralNetwork"
it's possible by doing some spelunking - if you checkInputForm
of thePredictorFunction
there might be a network in there that you can then export. $\endgroup$ Mar 18, 2019 at 8:20 -
$\begingroup$ @C.E. Actually, see my answer, I have an implementation. $\endgroup$ Mar 18, 2019 at 8:42
You may export the model to CDF player pro and use this setting to make the tests.
-
1
-
$\begingroup$ I believe they may have meant "setting" as in "environment". $\endgroup$ Mar 18, 2019 at 8:42