Did you know that 90% of machine learning models never actually make it into production?
This means that the topic of machine learning deployment is rarely discussed when people learn machine learning. As a result, many AI practitioners know how to create useful ML models, but they find it difficult to deploy them into production.
Needless to say, machine learning deployment is one of the more important skills you should have if you’re going to work with ML models.
Model deployment is the process of integrating your model into an existing production environment. The model will receive input and predict an output for decision making for a specific use case.
For example, a model can be deployed in an e-commerce site and it can predict if a review about a specific product is positive or negative.
Only when a model is fully integrated with the business systems, we can extract real value from its predictions. - Christopher Samiullah
There are different ways you can deploy your machine learning model into production. But in today’s article, you will learn how to deploy your NLP model into production as an API with Algorithmia.
In this article, you will learn:
Our first step is to create a machine learning model that can detect spam SMS text messages. So let’t get started!
First, we need to build our model. Here are the steps you should follow to do that.
We first import all the importance python packages that we will use to load the data, preprocess the data, and create a text classification model.
## import important modules
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from string import punctuation
## sklearn modules
from sklearn.model_selection import train_test_split
from sklearn.naive_bayes import MultinomialNB
from sklearn.svm import SVC
from sklearn.metrics import (
accuracy_score,
classification_report,
plot_confusion_matrix,
f1_score,
roc_auc_score,
)
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.model_selection import cross_val_score, RandomizedSearchCV
## text preprocessing modules
from nltk.tokenize import word_tokenize
from cleantext import clean
import nltk
from nltk.corpus import stopwords
from nltk.stem import WordNetLemmatizer
import re #regular expression
from wordcloud import WordCloud, STOPWORDS
## Download dependency
for dependency in (
"brown",
"names",
"wordnet",
"averaged_perceptron_tagger",
"universal_tagset",
"stopwords"
):
nltk.download(dependency)
#nltk.download('stopwords')
import warnings
warnings.filterwarnings("ignore")
## seeding
np.random.seed(123)
#data-science #api #developer