The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here
[Solved] - Using the prior value of an attribute to calculated the current value
I'm trying to label examples as to whether they're part of a trend that's gernerlly upward or generally downward. I've got the first part working. I'm calculating the difference between successive examples using the Differentiate operator and then using Generate Attribute to assign a label based on the sign of the difference. Here's an example:
MovingAvg DeltaMovingAvg Trend
0.629 ? Up (arbitary choice)
0.600 -0.029 Down
0.571 -0.029 Down
0.557 -0.014 Down
0.586 0.029 Up
0.583 -0.003 Down
0.583 0 Up
0.597 0.014 Up
So far so good. But I really don't want the little value of -0.003 to get in the way of a generally upward trend. So I'd like to add a rule that says - if the value of the difference is less than a threshold (say 0.02) then don't change the label on the trend from what it was in the previous example. After applying this rule I'd get:
MovingAvg DeltaMovingAvg Trend
0.629 ? Up (arbitary choice)
0.600 -0.029 Down
0.571 -0.029 Down
0.557 -0.014 Down
0.586 0.029 Up
0.583 -0.003 Up
0.583 0 Up
0.597 0.014 Up
I suspect I need a Loop Example to do this but I can't find a good example of how to use Loop Example. Can anyone point me to a simple tutorial on Loop Example? Or is there an easier way to do this?
MovingAvg DeltaMovingAvg Trend
0.629 ? Up (arbitary choice)
0.600 -0.029 Down
0.571 -0.029 Down
0.557 -0.014 Down
0.586 0.029 Up
0.583 -0.003 Down
0.583 0 Up
0.597 0.014 Up
So far so good. But I really don't want the little value of -0.003 to get in the way of a generally upward trend. So I'd like to add a rule that says - if the value of the difference is less than a threshold (say 0.02) then don't change the label on the trend from what it was in the previous example. After applying this rule I'd get:
MovingAvg DeltaMovingAvg Trend
0.629 ? Up (arbitary choice)
0.600 -0.029 Down
0.571 -0.029 Down
0.557 -0.014 Down
0.586 0.029 Up
0.583 -0.003 Up
0.583 0 Up
0.597 0.014 Up
I suspect I need a Loop Example to do this but I can't find a good example of how to use Loop Example. Can anyone point me to a simple tutorial on Loop Example? Or is there an easier way to do this?
0
Answers
corrected_Trend: if (Trend_1 != Trend_0 && DeltaMovingAvg<0.02, Trend_1, Trend_0)
Best, Marius
Unfortunately it's looking like I may have to process example by example.
Happy Mining!
~Marius