Categories

Versions

You are viewing the RapidMiner Server documentation for version 9.7 -Check here for latest version

Predictive Maintenance

Predictive Maintenanceis a sample process in RapidMiner Studio's Samples Repository (Samples>Templates>Predictive Maintenance) designed to anticipate machine failure and to schedule maintenance pre-emptively. TheReference Datadescribes 136 machines characterized by their "Machine ID", 25 sensor values, and a binary label called "Failure". ThePredictive Maintenanceprocess builds a model to predict failure, and applies it to an unlabeled data set calledNew Data.

In what follows, we will use thePredictive Maintenanceexample to build two web services:

As a web service, this example is not entirely realistic, because the data source is static. In a typical web-service scenario, the input and output are constantly changing, and you need a real-time response. However, the current example has the advantage that all the steps are reproducible. You can use this example to convince yourself that your RapidMiner AI Hub setup is working as expected.

In principle, a web service can have thousands of users and be called multiple times per second. It would be absurd to rebuild the same model repeatedly. Hence, the basic strategy is to divide the original process into two:

  1. Create andstore the modelforPredictive Maintenance

  2. Retrieve the stored modeland apply it toNew Datato make a prediction

Remember:Building a model takes time, but once it's built and stored, you can apply it in real time. In general, a process that is designed to create a web service should not include any model building.

Copy the Predictive Maintenance folder

Let's start by making a copy of thePredictive Maintenancefolder in the Samples Repository, and pasting it to a new location, so that we are free to make changes. In the steps below, we choose to store the copy in theTemporary Repository, but that choice is completely arbitrary. You can save thePredictive Maintenancefolder anywhere you like.

  1. In the RapidMiner Studio, in the Repository Panel, go toSamples>Templates>Predictive Maintenance. Right-click the folder, and chooseCopy.

  2. In the RapidMiner Studio, in the Repository Panel, go toTemporary Repository. Right-click the folder, and choosePaste. ThePredictive Maintenancefolder is copied to the new location, together with three files:New Data,Reference Data, and a process calledPredictive Maintenance.

  3. We will continue to work in RapidMiner Studio, inTemporary Repository>Predictive Maintenance, until all our processes and models are ready. Once everything is working in RapidMiner Studio, we will copy thePredictive Maintenancefolder to theRapidMiner AI Hub Repository, andcreate a web service.

Store the model

To make sure that we are modifying the copied process and not the original, open the folderTemporary Repository>Predictive Maintenance, and double-click the processPredictive Maintenance, so that it is displayed in the Process Panel of RapidMiner Studio.

From the perspective of web services, thePredictive Maintenanceprocess is flawed, because it builds a model and makes predictions without ever storing the model. To store the model, we need to include theStoreOperator.Find it, and insertStorein the process, connecting the model output ("mod") ofApply Modelto the input port ofStore, as illustrated below:

TheStoreOperator takes a single parameter, the location where the object is stored. In the Parameters Panel, click on the folder icon to choose a location. We want to save the model in the same folder as the data and processes we are working with. Name the modelPredictive_Maintenance_Model, and make sure the checkbox for relative location is checked, so that when we later move thePredictive Maintenancefolder to the RapidMiner AI Hub Repository, nothing will break.

Save the process (File>Save Process), and run it to generate the model. ThePredictive_Maintenance_Modelnow appears in thePredictive Maintenance文件夹中。

Retrieve the model

Having stored the model, we now want to create the process we will use to generate a web service. Since most of the Operators in the originalPredictive Maintenanceprocess were dedicated to building a model, we can throw them away and instead use theRetrieveOperator to load the stored model, connecting its output to the model input ofApply Modeland leaving the remaining Operators as they are. In the Parameters Panel for theRetrieveOperator, click on the folder icon, and choose thePredictive_Maintenance_Modelthat was just created.

< ?xml version = " 1.0 " encoding = " utf - 8 " ?> <过程版本sion="9.2.000-BETA2">                                                              

You can build this process yourself, copying the relevant Operators from thePredictive Maintenanceprocess, or you can import it by clicking the link above, copying the XML into a file calledPredictive_Maintenance_web_service_without_parameters.rmp, and importing it into RapidMiner Studio viaFile>Import Process. Once you have imported it:

  1. Right-click on the folderTemporary Repository>Predictive Maintenance, and selectStore Process Here

  2. Name the processPredictive_Maintenance_web_service_without_parameters

  3. Double-click the new process underPredictive Maintenanceto load it into RapidMiner Studio, and check that you can run it without errors. It should generate the same output as the original processPredictive Maintenance, but without the overhead of building a model.

Read more:Create a web service without parameters

Insert a macro

The process we just created returns predictions for every value of "Machine ID", but what if we want a prediction for only one particular value of "Machine ID"? As a first step, we can introduce another Operator,Filter Examples, inserting it betweenRetrieve New DataandApply Model, and configuring it to include only that one specific value of "Machine ID".

The complication is that our web service will take a parameter corresponding to "Machine ID", and of course the user may choose an arbitrary value. We don't know the value of "Machine ID" in advance, and we don't want it to be hard-wired into our process. We do want an arbitrary value to be injected when the process is executed. What we need is amacro.

In the Parameters Panel forFilter Examples, click on the buttonAdd Filtersto display the following dialog. Ordinarily, we might choose a filter of the form "Machine_ID equals M_0221" to choose a specific machine, but now we will construct the filter somewhat differently. Because a macro is a key-value pair, we need to give our macro a name (machineID); the value will be provided later, by the web service. The value of a macro can be injected into any field in RapidMiner that takes a value, provided you insert the value using the following syntax:

%{machineID}

The Context Panel

At this point, we're almost done. If you've been following along, you may have already constructed the process that we will use to generate a web service with a parameter. If not, you can click the link below, copy the XML into a file calledPredictive_Maintenance_web_service_with_parameters.rmp, andimport itinto RapidMiner Studio. As before, you should save this process in thePredictive Maintenancefolder, and run the process to make sure that it works as expected.

< ?xml version = " 1.0 " encoding = " utf - 8 " ?> <过程版本sion="9.2.000-BETA2">      machineID M_0221                                                                       

Notice that when you run this process, the result is a prediction for a specific value of "Machine ID", because the XML process definition sets the value of the macro. Strictly speaking, there isno needto set this value. The process will run without error (albeit with no output) even without this value, and the web service will in any case reset the value, taking the value provided by the URL.

However, for testing purposes, it can be quite useful to set a value for the macro. To do so, you should open up aContext Panel, one of twonon-default panelsrelated to macros -- the other being the Macros Panel. At the bottom of the Context Panel, the current macros are listed. You can add or delete a macro via two icons on the right. You can modify the value of the macro by editing it in place. Try it! Run the process with a new value of the macro, or after deleting the key-value pair, and see how the result changes.

Read more:Create a web service with parameters

Copy the Predictive Maintenance folder to RapidMiner AI Hub

Once the model has been stored, and both new processes have been built and tested in RapidMiner Studio to see that they work, it's time to copy them to RapidMiner AI Hub. Using a similarcopy/paste procedure as used previously, copy thePredictive Maintenancefolder to a folder in the RapidMiner AI Hub repository. In the current example, the folder has been copied to/home/adminin theDockerOneTimeRepository. Seen from RapidMiner Studio, it looks like this:

Log in to RapidMiner AI Hub, click onRepository>Browse Repository, and continue browsing until you find thePredictive Maintenance文件夹中。从RapidMiner AI中心,它的样子this:

The two processes we will use to build web services are ready to go!

Next:Create a web service