We will execute the following steps for this recipe:
- First, we will import all of the libraries which we will need later. We will import pandas and numpy for data processing, keras for the ML models, sklearn for evaluations, and pickel and mlflow for storing the results:
import pandas as pd
import numpy as np
import keras
from keras.models import Sequential
from keras.layers import Dense, Dropout, LSTM, Activation
from sklearn import preprocessing
from sklearn.metrics import confusion_matrix, recall_score, precision_score
import pickle
import mlflow
- Next we will set the variables. We will set 2 cycles periods. In addition we use a sequence length variable. The sequence length allows the LSTM to look back over 5 cycles. This is similar to windowing that was discussed in Chapter 1, Setting Up the IoT and AI Environment. We are also going to get a list of data columns:
week1 = 7
week2 = 14
sequence_length = 100
sensor_cols = ['s' + str(i) for i in range(1,22)]
sequence_cols...