假设我有 24 行数据,每行代表一天中的一个小时。我想要实现的是实现一种算法,该算法可以检测数据趋势并将其分为 2 个 block ——一个“好” block 和一个“坏” block 。例如,在附图中,您可以看到在第 6 行,一个好的 block 在第 19 行开始和结束。第 0 行也有一个很好的分数,但它不是 block 的一部分,所以算法应该知道如何处理这种情况。 我认为它与集群有关,但找不到满足我们需求的足够简单的东西。 期待任何建议。
最佳答案
start = -1
Append a below-threshold value to the end of the data array x[]
For i from 1 to n:
If x[i] >= thresholdValue:
if start == -1:
start = i
Else:
If start != -1 and i - start >= thresholdLength:
ReportGoodBlock(start, i-1)
start = -1
关于寻找趋势 block 的算法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35840536/