How can I generate anomalies in a dataset?

I'm building a tensorflow model to detect anomalies in an electricity smart meter data and I'm using UK-DALE Dataset. How can I introduce anomalies in the data so I can test the model?

Topic anomaly-detection dataset

Category Data Science


Anomalies usually mean datapoints that are not making sense, so you can just insert random numbers between a given range.

Generating 10 random numbers:

import random
randomlist = []
for i in range(0,10):
    n = random.randint(1,30)
    randomlist.append(n)
print(randomlist)

Generate 10 random numbers as part of some timeseries:

np.random.seed(2019)
N = 10
rng = pd.date_range('2019-01-01', freq='MS', periods=N)
df = pd.DataFrame(np.random.rand(N, 1), columns=  ['readings'], index=rng)

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.