Let's begin by importing the necessary libraries and getting the dataset ready:
- Let's import the required libraries and function:
import numpy as npimport pandas as pdimport matplotlib.pyplot as pltfrom scipy.signal import find_peaks
- Let's load the Appliances energy prediction dataset:
data = pd.read_csv('energydata_complete.csv')
- The data type of the date variable is object; let's change it to datetime:
data['date'] = pd.to_datetime(data['date'])
- First, let's calculate the time between transactions, that is, the time between each energy record, expressed in minutes:
data['time_since_previous'] = data['date'].diff()data['time_since_previous'] = data['time_since_previous']/np.timedelta64(1,'m')