3
$\begingroup$

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.

$\endgroup$
4
$\begingroup$

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 NetEncoders and NetDecoders 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.)

$\endgroup$
1
$\begingroup$

You may want to export it using something like mxnet.

$\endgroup$
6
  • $\begingroup$ ThankYou! Can you please direct me to a website? $\endgroup$ – user34018 Jan 20 '19 at 13:20
  • $\begingroup$ mxnet.apache.org $\endgroup$ – M. Di Jan 20 '19 at 13:21
  • $\begingroup$ How can a PredictorFunction (which is what Predict returns) be exported to MXNet? $\endgroup$ – C. E. Mar 17 '19 at 18:48
  • $\begingroup$ @C.E. I believe that if you use Method->"NeuralNetwork" it's possible by doing some spelunking - if you check InputForm of the PredictorFunction there might be a network in there that you can then export. $\endgroup$ – Carl Lange Mar 18 '19 at 8:20
  • $\begingroup$ @C.E. Actually, see my answer, I have an implementation. $\endgroup$ – Carl Lange Mar 18 '19 at 8:42
-2
$\begingroup$

You may export the model to CDF player pro and use this setting to make the tests.

$\endgroup$
2
  • 1
    $\begingroup$ To what "setting" are you referring? $\endgroup$ – bbgodfrey Mar 17 '19 at 17:49
  • $\begingroup$ I believe they may have meant "setting" as in "environment". $\endgroup$ – Carl Lange Mar 18 '19 at 8:42

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.