cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can change your system assigned username to something more personal in your community settings. X

Prescriptions Mashup for Thingworx Analytics

No ratings

I have created a mashup which allows you to easily use and test the Prescriptions functionality in Thingworx Analytics (TWA). This is where you choose 1 or more fields for optimization, and TWA tells you how to adjust those fields to get an optimal outcome.

 

The functionality is based on a public sample dataset for concrete mixtures, full details are included in the attached documentation.

 

image

Comments

Can you help to explain the id fielfs amd lever fields in the function prescribeStrength() and how they are populated

Hi, I think the Lever fields are important but the Id fields are probably not (you could test the results with excluding the Id fields, i.e. removing parameter identifierFields: idFields from the call to RealtimeScore).

 

The Lever fields are populated due to an infotable called leverSelection which is passed in as an input from the mashup when the service is called. These are the fields which the user has selected in the list using multi-select. So for example if you highlight fields Age and FineAggregate, then these become the levers and Thingworx Analytics (TWA) will optimise these values to maximise (as per the call to RealtimeScore) the goal field which is CompressiveStrength. TWA will return the optimal settings for Age and FineAggregate (in this example), which are displayed on the mashup. If I remember correctly, theoretically the values shown for Age and FineAggregate aren't necessarily the optimal values but in practise usually they should be.

Hi,

 

Thank you very much for this demo, since I have found no other source for prescriptive analytics helpful like this.

 

I tried to duplicate all the entities you created and use it in my project, but at the end I get this message below when I run the "PredictStrength" service:

" Error executing service PredictStrength. Message :: Error returned from service [500]: Failed to score: Unable to retrieve results at results:/models/nq2019_NQ2019Model_46eba09a-2e88-4b1d-8994-48f0d7a1820a. Received response: {"code":404,"message":"Could not retrieve result [nq2019_NQ2019Model_46eba09a-2e88-4b1d-8994-48f0d7a1820a]"} - See Script Error Log for more details."

 

Can you help me on this? Thanks in advance.

 

 

Thanks. Am I correct in understanding that you are able to make the provided demo work, but when you try and port the code to your application/entities then it fails? If that's the case, please could you export your entities and attach them here so I can test them?

Yes, you are correct. Your demo worked. But I tried both predictStrenght and prescribeStrength but got same error. TWX files and the model is attached. Goal is T1401.

I tried importing your entities but I got this error:

 

Unable to process import: Validation Failure: DataShape nesquik_provider.concrete_concrete1_c2054f0a-afb2-4880-b471-3cd13a574efa.ResultDataShape Had An Invalid DataShape [nesquik_provider.concrete_concrete1_c2054f0a-afb2-4880-b471-3cd13a574efa.ResultimportantFieldsDataShape] assigned to field [importantFields]

 

So could you please re-export and include this data shape?: nesquik_provider.concrete_concrete1_c2054f0a-afb2-4880-b471-3cd13a574efa.ResultimportantFieldsDataShape

Hi, I think on Thing ConcreteHelper you should set ModelID = c2054f0a-afb2-4880-b471-3cd13a574efa

 

This should be the same ModelID that you see in Analytics Builder as shown in the below screenshot.

 

image

Thanks, modelID mistake was the reason for 403 error. Now I have a new one:

"Error executing service prescribeStrength. Message :: Wrapped com.thingworx.common.exceptions.GenericHTTPException - See Script Error Log for more details."

 

Entities with the right data shapes is attached.

Hi oaslan,

 

Are you still receiving the error:

"Error executing service prescribeStrength. Message :: Wrapped com.thingworx.common.exceptions.GenericHTTPException - See Script Error Log for more details." ?

If yes, what errors are reported in the Script Error Log?

The log can be found via path <>\ThingworxStorage\logs

 

Best,

Asia

As far as I know, this is now working. I had exchanged some private messages with oaslan, this was one of my last messages:

 

"I got it working now. If you try thing NesquikScoringTest (either service, predictStrength, prescribeStrength) then those should work. The problem was that you had underscores at the beginning of field names in your code, however the fields defined in the model (in Analytics Builder, Model > View > Model Details) do not have an underscore at the beginning. So I created a new datashape (NesquikDS2) and in the template I referenced this datashape instead. I created new entities (NesquikDS2, AnalyticsHelperScoringTest, NesquikScoringTest) and did not change your entities."

oaslan, could you please confirm if it's now working?

Hi could be because of the active connection of "Prescriptive Microservice" is not available. If you look for "PrescriptiveMicroservice" template, just check if you have any "YourServerName--AnalyticsServer" thing with active connection is available. This could be the only reason. You might have multiple thing dependent on "PrescriptiveMicroservice" template but make sure your "prescribeStrength" refers to "YourServerName--AnalyticsServer" thing only.

 

Regards

Shyam

Hi tsaifee-2,

 

This is an excellent example for reference. I tried to port it into ThingWorx 9.1 but found errors. I believe I may need to revise the scripts in somewhere. Attached please find the syndromes. 

 

Can you please help to check? Thanks!

Hi,

 

Just make sure, you have "ServerName-AnalyticsServer_PrescriptiveThing" connected in your system or you don't have any other things created under "PrescriptiveMicroserver" template.

 

Regards

Shyam

Hi Shyam,

 

I simply followed the manual attached to the project and did not create any extra thing.

 

The project works well in ThingWorx 8.5.7 but does not in ThingWorx 9.0+. I am wondering whether anything has been changed in ThingWorx 9.1. Thanks.

 

Regards,

Jianping

  

HI,

 

Can you please some error text?

 

Regards

Shyam

Thanks for your messages both, yes indeed there were some changes from TWX v9.0. Please see the attached entities / instructions which are updated for the new version.

 

Please note that the instructions are designed for a shared training environment where users duplicate entities to have their own copies.

 

Let me know if it works ...

Hi tsaifee,

 

Thanks a lot for prompt reply. I tried the new code but failed to get it work.

 

Can you please: 

     1) Give me a workable copy in ThingWorx 9.0+ without further renaming/editing the scripts, or,

     2) Let me know how to modify the original source code, so that we know what have been changed from    ThingWorx 9.0.

 

Thanks a lot.

 

Regards,

Jianping

Hi Jianping,

 

please can you email me direct ( tsaifee@ptc.com ) with a couple of suggestions for dates/times when we can have a call to share your screen and analyse the problem? I'm in the London/UK timezone and you should be able to see my free/busy times in my PTC calendar.

 

Best regards, Tanveer.

Version history
Last update:
‎Sep 27, 2018 01:13 PM
Updated by:
Labels (3)
Attachments