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

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

How to work with ordinal and categorical data in ThingWorx Analytics ?

No ratings

Datasets with ordinal or categorical goal cannot currently be used in ThingWorx Analytics Builder.

However this is only a UI limitation, ThingWorx Analytics Server can handle those data.

It does simply require to use the services from the AnalyticsServer-Training and AnalyticsServer-Prediction things to perform the operations.

 

This can be done using a mashup or via Rest API call (see https://www.ptc.com/en/support/article?n=CS271485 ) .

The below video expands on the mashup solution.

Attached are also the entities used during the video and a sample dataset with ordinal goal.

 

 

Update for ThingWorx 9.0 

The API has changed in 9.0, use the entities Entities-90-3Jun2020.xml for release 9.0

 

Comments

Chris @cmorfin , this doesn't seem to work with 8.3 (getting error from CMOCreateModelLearner service - "Please select at least one learner" on the first step, when creating the model)

Do I miss something, or could you please provide a list of parameters for a REST call?

Hi Dmitry

 

I did test it recently in 8.3 and that was working.

However there were some other issues, so I have attached anew version of entities that corrected some of those problems. It would be best if you reuse this new ones.

 

Regarding the error you get on Learners, the service reads the value from a property named Learner, by default it is empty, so you would get this error.

You need to first set some value in this Learner property to define at least one learner, then you can execute it.

Note that the services also calls some other properties for the training and scoring thing , if I recall correctly, so you need to set those properties with the correct value for your environment.

The properties are on the thing  cmo_Helper

 

Kind regards

Christophe

 

Hi Chris

 

Uhh... Those properties were not mentioned in the video.

Now, after setting them (Learner, PredictionThing and TrainingThing), I'm getting

 

[context: com.thingworx.webservices.context.HttpExecutionContext@2dde78b5][message: Execution error in service script [CMOCreateModelLearner] :: TypeError: Cannot call method "CreateJob" of null (CMOCreateModelLearner#109)] 

 

Do I miss some other properties / should I edit something inside the services?

Hi Dimitry

 

You will get this error if the TrainingThing property is not set in cmo_Helper

 

Kind regards

Christophe

 

Thank you, Chris

 

It works now, there was an extra space before the name of the Training thing.

One more question regarding the categorical data...

Are AnalyticsServer_SignalsThing and ProfilingThing supposed to work with models generated for categorical data?

Hi

 

Ordinal and categorical goal are currently  supported for training and scoring only.

 

Kind regards

Christophe

 

 

Hi, Cris

     I got the "Error executing service CMOCreateModelLearner. Message :: No enum constant com.thingworx.analytics.training.params.LearningTechnique.test - See Script Error Log for more details" in the 8.4

    Do I miss some other properties / should I edit something inside the services?

It looks like there is an error in the parameters when running the training service. The learners define which algorithms are being used, and there are special keys expected.  Check here and here.

Hi @qianqian024 

 

I have just downloaded and retested the entities and they do work on a 8.4.1 server.

However based on the error you received, the root cause seems to be that you added a new learning technique named test in the Learner property of cmo_helper2. Ash indicated by @Rocko , the learning technique take very specific values that define the type of algorithm the machine learning engine should use. test is not a valid value. You can see the valid values for learningTechnique in the API guide indicated by @Rocko  .

 

You should be able to move forward using valid values for learning technique.

For additional help you can also check in ThingWorx Analytics Builder, pretend to create a new model and go in Advanced Parameters, you will see the valid learners there too.

 

Kind regards

Christophe

 

thanks a lot. It can work according to your advice.

Hi Christophe,

 

I was not able to find 'CMOCreateModel' as service and its associated fields in cmo_helper thing.

 

I was tried to replicate this model and services in my local, and stuck in mapping for CMOCreateModel and modelOutputs as field.

 

Please let me know from where i can find CMOCreateModel as service and find modelOutputs fleld.

 

Regards,

Mayank

 

Hi @MayankSharma20 

 

If I am not mistaken you are using release 9.0 of ThingWorx. There has been a API change in 9.0, see Release notes under "Changes that Break Backwards Compatibility", so the modeloutput is no longer present.

I have attached some new entities that works in 9.0 with the new format.

Unless I missed somethign there is no service CMOCreateModel, but there is CMOCreateModelLearner

 

Regards

Christophe

Thank you so much Christophe for new Entities.

 

Actually I am using release of 8.4.3 Thingworx version.

 

Regards,

Mayank 

Hi @MayankSharma20 

 

I think there is an inaccuracy with the version you are using. From the screenshots it does not look like  a 8.4.x version, it should be at least 8.5.x. Can you double check what you get under Composer > Help > About.

 

Also I looked closely at your screenshots and it appears you are using old entities for the mashup, this is not the right version. Basically the mashup should be  CMOCreateModel2 not CMOCreateModel.
Could you let me know where did you download the entities from as we may have an old link somewhere.

I would advise that you delete the entities imported and re-import the ones in Entities12nov2019.xml if you are using a 8.5.x version or Entities-90-3Jun2020.xml if you are using 9.0.

 

Thank you

Christophe

 

Appreciated for quick response and detailed analysis. 😉

 

I have cross verified version were using 8.5.4. and yes your right screenshot was from old entities.

I will check with Entities12nov2019.xml Entities.

 

Regards,

Mayank

 

 

Hi @cmorfin Cris,

 

Thanks for this post!

It was quite helpful as a reference when working with categorical data.

 

I uploaded a dataset and then created a model but when executing the RealtimeScore service of the PredictionThing I get the following answer.

image

The value in the Internal_Pump_Leakage field is a String that looks like a JSON object but in fact it's not. It requires further processing to access the keys in it.

Is this the expected behavior?

Hi @nahuel 

 

Yes this is the expected output for categorical goal, the format is different than for ordinal and output the probability of each category - This is indicated in Help Center: Interpreting Predictive Scoring Results (ptc.com)

 

Thanks

Christophe

 

@cmorfin Thank you!

Version history
Last update:
‎Mar 28, 2018 08:29 AM
Updated by:
Labels (1)
Attachments
Tags (1)