Scaling values on metric evaluation

#1

I have PointMeasurement data of different scales (i.e. different unitConstraint in the corresponding PointPhysicalMeasurementSeries). e.g. for object id1 they are between 0 and 1, while for object id2 they are between 0 and 100.

When I evaluate a metric of the following form:

c3Viz(MyType.evalMetrics({
  "ids": [
    "id1", "id2", "id3", "id4"
  ],
  "expressions": ["MyMetric"],
  "interval": "QUARTER_HOUR",
  "start": "2018-02-21T00:00:00.000-00:00",
  "end": "2018-02-28T00:00:00.000-00:00"
}))

I see the graph mixes values between 0 and 100, with values between 0 and 1!

How I can ensure all values are scaled to 0 and 1?

0 Likes

#2

If the values have the right units set on each data point the engine will automatically convert the values to the desired unit for you. For e.g.

If the header specifies the desired unit to be “kilowatt”

PointPhysicaMeasurementSeries.make( {
  id:"test1",
  unitConstraint: {id:"kilowatt"}
})

And individual data points are a mix of various units, let’s say “kilowatt” & “watt” then each data point will be converted to “kilowatt” and normalized

PointMeasurement.make({
  parent:{id : "test1"}, start:"2010-01-01", 
  quantity: {value:1, unit: {id: "kilowatt"}}
})
PointMeasurement.make({
  parent:{id : "test1"}, start:"2010-01-02", 
  quantity: {value:1000, unit: {id: "kilowatt"}}
})

On day 1 value is : 1 kilowatt and on day 2 value is: 1000 watt, then based on the unitContraint specified on the tsField, all values will be converted to “kilowatt” and value for day 2 will be stored as “1 kilowatt”

you can specify the unitConstraint on the time series field as follows:

type PointMeasurement mixes ... {
  
  @tsField(unitConstraint="parent.unitConstraint")
  quantity: ExactDimension
}
1 Like

#3

Thanks @rohit.sureka, so in my case I need to remix PointMeasurement to add the unitConstraint and also set one unique unitConstraint in the series header (i.e. PointPhysicalMeasurementSeries).

What should I use so that the values will be scaled between 0 and 1, is there a unit for this?

0 Likes

#4

in your case, simplest would be to handle it in the metric expression, something like:

MyMetric > 1 && MyMetric < 100 ? MyMetric / 100 : MyMetric

1 Like

#5

Thanks @rohit.sureka , I thought of this solution but was thinking of creating a unit (as I can’t find unit for [0-1]) e.g. probability. Then find a way to define an automatic conversion like with watt and kilowatt in your example above.
Is this possible?

0 Likes

#6

probability is not a unit of measure so in this case I would say it would be wrong to create a unit called probability

1 Like

#7

I know @rohit.sureka, that’s just a name. What I want is define the conversion from % to this new unit.

Is this possible?

0 Likes

#8

yes, that is possible

0 Likes

#9

Can you point to how I can achieve this?

0 Likes