Rilevare più anomalie in serie temporali stagionali

Introduzione all'Anomaly Detection in R

Alastair Rushworth

Data Scientist

Dati mensili di ricavi

head(msales)
  sales month
1 6.068     1
2 5.966     2
3 6.133     3
4 6.230     4
5 6.407     5
6 6.433     6

Il test di Grubbs non è adatto qui

  • Potrebbe esserci stagionalità
  • Potrebbero esserci più anomalie
Introduzione all'Anomaly Detection in R

Visualizzare i ricavi mensili

plot(sales ~ month, data = msales, type = 'o')

Introduzione all'Anomaly Detection in R

Uso dell'algoritmo Seasonal-Hybrid ESD

library(AnomalyDetection)
sales_ad <- AnomalyDetectionVec(x = msales$sales, period = 12, 
                                direction = 'both')

Argomenti

  • x: vettore di valori
  • period: periodo del pattern ricorrente
  • direction: trova anomalie piccole ('neg'), grandi ('pos') o entrambe ('both')

Scarica il pacchetto da https://github.com/twitter/AnomalyDetection

Introduzione all'Anomaly Detection in R

Output dell'algoritmo Seasonal-Hybrid ESD

sales_ad <- AnomalyDetectionVec(x = msales$sales, period = 12, 
                                direction = 'both')
sales_ad$anoms
  index anoms
1    14 1.561
2   108 2.156
Introduzione all'Anomaly Detection in R

Grafico dell'algoritmo Seasonal-Hybrid ESD

AnomalyDetectionVec(x = msales$sales, period = 12, 
                    direction = 'both', plot = T)

Introduzione all'Anomaly Detection in R

Passiamo alla pratica!

Introduzione all'Anomaly Detection in R

Preparing Video For Download...