Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
This video is Module 11: ThingWorx Analytics Mashup Exercise of the ThingWorx Analytics Training videos. It shows you how to create a ThingWorx project and populate it with entities that collectively comprise a functioning application.
It contains a recommended hands-on exercise. Here you are shown how to build a ThingWorx application that uses a ThingWorx Analytics predictive model. If your ThingWorx environment is connected to a streaming asset, say, through Kepware, you may use five tags from that asset rather than from the "CCPP" thing shown in this video. Simply bind to those tags and rename the new properties as shown in this video. NOTE: This exercise is only for demonstration purposes, and will not produce a meaningful or accurate model.
**Update June 16, 2023: The following steps now reference "DataSimulator_Standalone.xml" instead of the previous "dataSimulator.xml". This new Thing will prevent errors on import.**
If your environment isn't connected to a streaming asset, you may import and use the attached "DataSimulator_Standalone.xml". This data simulator takes the place of the streaming asset. Follow these steps to create your "CCPP_StreamingThing":
Here are the additional properties that will be added to your Thing:
The services to be added to your Thing are attached to this page as .txt files. NOTE: In these services, you must change references to the default microservices ('AnalyticsServer_TrainingThing', 'AnalyticsServer_SignalsThing', etc.) to be the correct name used by your ThingWorx Analytics installation. These correct names can be found by navigating to Things, and locating the microservices ('…_TrainingThing', '…_SignalsThing', etc.).
In the service TrainModel, change line 27 to be:
me.ModelResultID = Things["<your microservice here>"].CreateJob({
In the service RunRealTimeScore, change line 24 to be:
var prescriptiveScores = Things["<your microservice here>"].RealtimeScore({
Note: It is possible that in creating and modifying the above properties that some properties may start logging values before others. This will result in the TrainModel service creating a dataset with missing values, and the model will fail to train. To avoid this from happening, add the following code to the TrainModel service in line 23:
// cleaning up the rows that have empty values
for(var k=0; k<data.rows.length; k++){
var row = data.rows[k];
for(var j=0; j<modelFeatures.rows.length; j++){
if ( row[modelFeatures.rows[j].name] === undefined ) {
data.RemoveRow(k);
k--;
break;
}
}
}