Created on 08-02-202307:47 AM - edited on 08-03-202301:34 AM by VidyaSargur
Introduction:
This article is designed to get the reader to call a deployed CML model from Apache NiFi or Cloudera Data Flow as quickly as possible. It will require using one of Cloudera's Applied Machine Learning Prototypes (AMPs) on Customer Churn and the Apache NiFi Flow provided in this article. (Git Repo Here)
Prerequisites:
Apache NiFi instance is running.
CML's AMP Customer Churn App is running with a Churn Model deployed.
Download the user data file and Apache Nifi flow from this repo.
The user data file needs to be added to the file location where NiFi's GetFile Processor has permissions.
Launch CML Churn AMP
In the AMP catalog, select Churn Modeling with skit-learn, and configure a new project. This will take 5-7 minutes to complete. You will need to deploy a model inside of CML, which isn't in the scope of this article. Once you finish, you will be able to see the following screen, which will provide the URL location and API key for the model.
NiFi Flow Overview:
This article will include a single customer file in JSON and an Apache NiFi Data flow, which will need to be configured to call the model deployed in CML. The following screenshot displays the template once it has been added to the working canvas.
Processor Configuration:
GetFile Processor
In the GetFile processor, the input directory needs to contain the customer JSON file that is included with the article.
EvaluateJSON Processor
The included Data Flow file has this processor configured, but this step is essential to appreciate. This processor will take values from the JSON file and add them as attribute values. Once these values are an attribute, they can be used to call the model in the next step.
InvokeHTTP Processor
You will need to add the URL location of the model deployed in CML, which is pictured above. You will also need to include the API key with the model call in the image below:
Successful Results
Once the processors have been configured, the model can be called the results can be displayed by opening the queue and selecting the response value.
@ibrooks Excellent article here. I will definitely be using this in my CML Demos going foward. I just sent a PR w/ some flow improvements you may like to use as well.