Research Article

Sensors Anomaly Detection of Industrial Internet of Things Based on Isolated Forest Algorithm and Data Compression

Algorithm 1

Sensor data compression algorithm.
Input: data.txt sensor data T number of packets processed in a single group K, error threshold E.
 Output: out1.txt, out2.txt.
(1) for i = 1 to N
(2)  read the data from “test.txt”, and write them to “data.txt”
(3) if e of the “test.txt”
(4)  break
(5) end if
(6) for i = 1 to N
(7)  read the data from “data.txt” to T[i + 1]
(8) aver = sum(T)/i + 1;
(9) end
(10) if (aver < 0)
(11)  for i = 1 to k
(12)   aver < aver + T[i]
(13)   aver < aver/k
(14)  end
(15) else
(16)  for i = 2 to n
(17)   temp < aver
(18)    for j = 0 to k − 1
(19)     if i + j ≥= n
(20)      temp < −1
(21)      aver < aver + T[i + j]
(22)     end if
(23)    end
(24)   end if
(25)  end
(26) end if
(27) aver < aver/k
(28) if |aver-temp| >= e
(29)  put i + j −1 to “out1.txt”
(30)  put T[i + j −1] to “out2.txt”
(31) end if
(32) return “out1.txt”,“out2.txt”