Mark III Systems Blog

Curious how to Operationalize Machine Learning Models?

Customers often ask me about how to operationalize the machine learning models they have created.  It’s common for them to have the machine learning model, but are struggling with how to apply it to new or existing business data sets. Another line of questioning is about “How do we move the machine learning model forward into production?”

I wrote this article to provide readers an overview of the basic steps of operationalizing machine learning models.

Creating a logistic regression model that can be operationalized

Believe it or not, you simply create the machine learning model and save it to a file.  This is typically done in a script that is separate from the script that will be used in production.  Pickle and joblib are common ways to save random forest, logistic regression, or other classical machine learning models. In this post, I will show you the process for pickle. Joblib is very similar.  For neural networks created with Keras, it is recommended to use keras.models.  Once the file is created, you can later load it and use it to score your data set.


Create the model file and save it

Create (fit) your model

Save it to a file.


Import the model from the file and use it on new data

Import (load) your model file

Get results using the loaded model


Example:  Logistic Regression

Script to create and save model

import pickle

# Import other modules such as scikit-learn to create your model


# Load and manipulate data as necessary


#Create model and fit

model = LogisticRegression(), Y_train)


# Save the model to a file.  Common extensions for the file are .h5, .pkl, or .sav.  It does not matter what extension you use.

filename = “my_model_file.h5”

pickle.dump(model, open(filename, ‘wb’))


Script used in production

import pickle

# Import other modules such as scikit-learn to be able to use your model


# Load and manipulate data as necessary


# Load (open) the saved model file and score

filename = “my_model_file.h5”

loaded_model = pickle.load(open(filename, ‘rb’))

result = loaded_model.score(X_test, Y_test))


# Evaluate your results as needed for your situation


That’s all there is to it!  For more in-depth instructions on how to operationalize models using joblib from scikit-learn or saving and loading models in Keras, check out the following helpful websites:

Jason Brownlee’s Machine Learning Mastery website


Do you work with clients who need help with operationalizing machine learning models? I’d love to hear what questions you commonly come across, please share by adding a comment below.

If you have questions and want to connect, you can message me on LinkedIn, Twitter:

Follow me on Twitter @pacejohn