Pre-processing data and defining the model