[rules-users] [drools-fusion] Detecting a Trend in Data
Davide Sottara
dsotty at gmail.com
Sun Nov 3 12:53:51 EST 2013
Quick ideas (not tested):
1) Detect an always increasing trend:
ensure that no previous value - possibly scoped by a sliding window - is
greater than the current
$current : MyPoint( $val : value )
not MyPoint( value > $val, this before $current ) over window:length(3)
2) A more robust approach, allowing for some noise:
create a custom accumulate function that computes a (linear) regression
and returns a
data structure with the basic output parameters (regression
coefficients, confidence intervals, etc..)
You would then constrain on that... something like
when
LinearRegressionData( k > .... ) from accumulate ( $x : MyPoints()
over window:length(3),
myCustomLinearRegressionAccumulateFunction $x ) )
then
Other options might be possible
Davide
On 11/03/2013 10:21 AM, code4dc wrote:
> Hey guys,
>
> I am trying to come up with a way to get Drools to detect a trend in a
> dataset. The data is very basic and looks something like this:
> (each row represents an object in the WM)
> Time Value
> 10:00 1
> 11:00 2
> 12:00 3
> 01:00 1
> 02:00 3
> 04:00 4
> 05:00 5
> 06:00 3
>
> I want to set up a rule that detects when there is an upward trend in the
> value for 3(configurable) or more consecutive data points.
>
> It's easy to set up a rule to detect when there is a two consecutive rows
> and the 2nd one has a higher value. But how can I set up a rule to detect
> when there are multiple consecutive rows each with a higher value than the
> previous one?
>
> Any ideas are welcome(even if they are not complete!).
>
> Thanks
>
>
>
>
> --
> View this message in context: http://drools.46999.n3.nabble.com/drools-fusion-Detecting-a-Trend-in-Data-tp4026609.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
More information about the rules-users
mailing list