Closed kaituo closed 1 year ago
Thanks for posting the issue -- this is a bug due to line 105 in https://github.com/aws/random-cut-forest-by-aws/blob/main/Java/parkservices/src/main/java/com/amazon/randomcutforest/parkservices/preprocessor/InitialSegmentPreprocessor.java
Instead of
tempList[j + 2 * inputLength].update(initialValues[i][j] - tempList[j].getMean());
the correct line should be
tempList[j + 2 * inputLength].update( tempList[j].getMean());
The original produces an incorrect transformation with the negatives. After the change the output looks like
0 6780.0 1 11175.0 2 9924.0 3 6173.0 4 11685.0 5 9244.0 6 13095.0 7 14248.0 8 10481.0 9 9462.0 10 14882.0 11 8794.0 12 7979.0 13 7674.0 14 18300.0 15 9985.0 16 7772.0 17 8216.0 18 11025.0 19 7903.0 20 7748.0 21 12291.0 22 10015.0 23 15658.0 24 13253.0 25 11362.0 26 13895.0 27 9050.0 28 14327.0 29 8944.0 30 13687.0 31 8761.0 32 5426.0 33 8754.0 34 8757.0 35 5571.0 36 10897.0 37 8840.0 38 12298.0 39 7259.0 40 4782.0
40 1000
17 0.0 0.0 0.0 0.0 3776.2095 -3776.2095 0.0 18 0.0 0.0 0.0 0.0 3776.2095 -3776.2095 0.0 19 0.0 0.0 0.0 0.0 3776.2095 -3776.2095 0.0 20 0.0 0.0 0.0 0.0 3776.2095 -3776.2095 0.0 21 0.0 0.0 0.0 0.0 3776.2095 -3776.2095 0.0 22 0.0 0.0 0.0 0.0 3776.2095 -3776.2095 0.0 23 0.0 0.0 0.0 0.0 3776.2095 -3776.2095 0.0 24 0.0 0.0 0.0 0.0 3776.2095 -3776.2095 0.0 25 0.0 0.0 0.0 0.0 3776.2095 -3776.2095 0.0 26 0.0 0.0 0.0 0.0 3776.2095 -3776.2095 0.0 27 0.0 0.0 0.0 0.0 3776.2095 -3776.2095 0.0 28 0.0 0.0 0.0 0.0 3776.2095 -3776.2095 0.0 29 0.0 0.0 0.0 0.0 3776.2095 -3776.2095 0.0 30 0.0 0.0 0.0 0.0 3776.2095 -3776.2095 0.0 31 0.0 0.0 0.0 0.0 3776.2095 -3776.2095 0.0 32 0.0 0.0 0.0 0.0 3776.2095 -3776.2095 0.0 33 0.0 0.0 0.0 0.0 3776.2095 -3776.2095 0.0 34 0.0 0.0 0.0 0.0 3776.2095 -3776.2095 0.0 35 0.0 0.0 0.0 0.0 3776.2095 -3776.2095 0.0 36 0.0 0.0 0.0 0.0 3776.2095 -3776.2095 0.0 37 0.0 0.0 0.0 0.0 3776.2095 -3776.2095 0.0 38 0.0 0.0 0.0 0.0 3776.2095 -3776.2095 0.0 39 0.0 0.0 0.0 0.0 3776.2095 -3776.2095 0.0 40 0.0 0.0 0.0 0.0 3776.2095 -3776.2095 0.0
40 10073.035 13849.244 6296.8257 41 9500.144 13276.354 5723.934 42 9307.606 13083.816 5531.397 43 9191.14 12967.35 5414.93 44 9382.338 13158.547 5606.1284 45 8911.4375 12687.646 5135.228 46 8946.831 12723.041 5170.6216 47 8806.98 12583.189 5030.771 48 8667.129 12443.338 4890.9194 49 8339.072 12115.281 4562.863 50 8543.231 12319.441 4767.022 51 8072.33 11848.539 4296.1206 52 8107.7246 11883.934 4331.515 53 7967.873 11744.082 4191.6636 54 7828.022 11604.231 4051.8125 55 7499.9653 11276.175 3723.7559 56 7704.124 11480.334 3927.9146 57 7233.2236 11009.434 3457.0142 58 7268.617 11044.826 3492.4077 59 7128.766 10904.976 3352.5566 60 6988.915 10765.125 3212.7056 61 6660.8584 10437.068 2884.649 62 6865.017 10641.227 3088.8076 63 6394.116 10170.326 2617.9067
This may also be related to issue #390, which is also producing artifacts in anomaly detection. But just this fix does not seem to completely solve #390, so likely there are other issues as well. PR coming shortly.
Resolved.
I wrote a test for RCFCaster:
Here is the output:
In the training data, there is no negative value. But the forecasted values have a lot of negatives.