Hello, I'm trying to test this library to a simple sinusoidal signal with some anomalies, but it's not working as I expected.
This is the sinusoidal:
And this is the script:
import matplotlib.pyplot as plt
import numpy as np
from pyculiarity import detect_ts
import pandas as pd
import random
from datetime import datetime, timedelta
def datetime_range(start, end, delta):
current = start
while current < end:
yield current
current += delta
# Creating the base signal
Fs = 8000
f = 5
sample = 8000
now = datetime.now()
dts = [now + timedelta(hours=index) for index in range(sample)]
x = np.arange(sample)
y = np.sin(2 * np.pi * f * x / Fs)
# Now lets add some anomalies
for x in range(7200, 7270):
y[x] = random.random()
# We call the library for detecting the anoms
data = pd.DataFrame({'dates':dts, 'values':y})
results = detect_ts(data,
max_anoms=0.1,
alpha=0.1,
direction='both')
print(results)
plt.plot(dts, y)
plt.xlabel('date')
plt.ylabel('voltage(V)')
plt.show()
Do you know why it's not working, @nicolasmiller ?
Hello, I'm trying to test this library to a simple sinusoidal signal with some anomalies, but it's not working as I expected.
This is the sinusoidal:
And this is the script:
Do you know why it's not working, @nicolasmiller ?