Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

The Journey of a Machine Learning Model From Building to Retraining

DZone's Guide to

The Journey of a Machine Learning Model From Building to Retraining

Learn about building a predictive ML model, deploying it as an API to be used in applications, testing the model, and retraining the model with feedback data.

· AI Zone ·
Free Resource

Did you know that 50- 80% of your enterprise business processes can be automated with AssistEdge?  Identify processes, deploy bots and scale effortlessly with AssistEdge.

This post is an excerpt from our solution tutorial that walks you through the process of building a predictive machine learning model, deploying it as an API to be used in applications, testing the model, and retraining the model with feedback data. All of this happening in an integrated and unified self-service experience on IBM Cloud.

In this post, the famous Iris flower dataset is used for creating a machine learning model to classify species of flowers.

In the terminology of machine learning, classification is considered an instance of supervised learning, i.e. learning where a training set of correctly identified observations is available.

Import Data to a Project

A project is how you organize your resources to achieve a particular goal within Watson Data Platform. Your project resources can include data, collaborators, and analytic tools like Jupyter notebooks and machine learning models.

You can create a project to add data and open a data asset in the data refiner for cleansing and shaping your data.

Create a Project

Go to the IBM® Cloud catalog and select Data Science Experience under the Data & Analytics section. Create the service. Click on the Get Started button to launch the Data Science Experience dashboard.

Create a New Project (Projects > All Projects > New Project). Add a name, say iris_project, and optional description for the project.

Leave the Restrict who can be a collaborator checkbox unchecked as there’s no confidential data.

Under Define Storage, click on Add and choose an existing object storage service or create a new one (Select Lite plan > Create). Hit Refresh to see the created service.

Under Define compute engine, Click on Add and choose an existing Spark service or create a new one.

Click Create. Your new project opens and you can start adding resources to it.

Import Data

As mentioned earlier, you will be using the Iris dataset. The Iris dataset was used in R.A. Fisher’s classic 1936 paper, The Use of Multiple Measurements in Taxonomic Problems, and can also be found on the UCI Machine Learning Repository. This small dataset is often used for testing out machine learning algorithms and visualizations. The aim is to classify Iris flowers among three species (Setosa, Versicolor, or Virginica) from measurements of length and width of sepals and petals. The iris dataset contains three classes of 50 instances each, where each class refers to a type of iris plant.

Courtesy: DataCamp

Download iris_initial.csv, which consists of 40 instances of each class. You will use the rest ten instances of each class to re-train your model.

Under Assets in your project, click the Find and Add Data icon.

Under Load, click on browse and upload the downloaded iris_initial.csv.

Once added, you should see iris_initial.csv in the Data assets section of the project. Click on the name to see the contents of the dataset.

Build a Machine Learning Model

Back in the Assets overview, under Models, click on New model. In the dialog, add iris-model as name and an optional description.

Under Machine Learning Service section, click on Associate a Machine Learning service instance to bind a machine learning service (Lite plan) to your project. Click Reload.



Select Model builder as your model type and Manual to manually create a model. Click Create.

For the automatic method, you rely on automatic data preparation (ADP) completely. For the manual method, in addition to some functions that are handled by the ADP transformer, you can add and configure your own estimators, which are the algorithms used in the analysis.

On the next page, select iris_initial.csv as your data set and click Next.

On the Select a technique page, based on the dataset added, ;abel columns and feature columns are pre-populated. Select species (String) as your Label Col and petal_length (Decimal) and petal_width (Decimal) as your Feature columns.

Choose Multiclass Classification as your suggested technique.

For Validation Split, configure the following setting:

  • Train: 50%,
  • Test: 25%,
  • Holdout: 25%

Click on Add Estimators and select Decision Tree Classifier, then Add.

You can evaluate multiple estimators in one go. For example, you can add Decision Tree Classifier and Random Forest Classifier as estimators to train your model and choose the best fit based on the evaluation output.

Click Next to train the model. Once you see the status as Trained & Evaluated, click Save.

Click on Overview to check the details of the model.

Your journey doesn’t stop here. Following the steps below, you will deploy your model as an API, test it, and retrain by creating a feedback data connection.

Consuming AI in byte sized applications is the best way to transform digitally. #BuiltOnAI, EdgeVerve’s business application, provides you with everything you need to plug & play AI into your enterprise.  Learn more.

Topics:
ai ,machine learning ,ibm cloud ,api ,tutorial

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}