# Export trained AI/ML model

From what I know, AI/ML uses a large amount of data to train an algorithm to solve problems. But since it’s an algorithm, I was wondering if it's possible to export it. If I trained an AI with R, could I export a mathematical algorithm that could be imported by other users to use in their application, whether it’s written in R or another language?

So it’s like I’ve discovered a secret message decoding method. I don’t need to share the whole program for others to decode it. I just need to tell them the steps (algorithm) to decode it, and they can implement it in whatever application they want.

If the 'algorithm' you're talking about is a neural network, then you can distribute the learned parameters/weights to anyone who wants to use it. This is how neural nets are normally 'exported': without all of the training data used to create them. Actually, this is done with many kinds of models (parameterized ones).

In order to 'decode' the model, users would only have to know its structure. In the case of a neural network, they'd need to know the size of each layer, what activation functions were used, etc.

This is not possible with every type of ML model, however. Specifically, non-parametric models and 'lazy' models make use of training data at inference time. They wouldn't be useful without their training data. Classifying an input by finding its k nearest neighbors, for example, would require having the training data.

Yes, once you've trained a model you'll have the details of that model in your workspace.

e.g.

B_Naive = naiveBayes(train_set[,-c(1)],train_set[,1]);


Will give you an object B_naive that can be 'exported'. These are the parameters of the model, you'll still need the naïve bayes library (or whichever library).