![Capture d’écran 2022-12-06 à 10.55.23.png](XMjq7EUif0Cq)

 1. The first step of the data preparation is to [pivot](recipe:compute_sensor_data_pivoted) the sensor dataset to have one column per sensor.

 2. Then the sensor data is [joined](recipe:compute_batch_and_sensor_joined) with batch data based with this formula : ```batch_start_time <= sensor_timestamp <= batch_end_time```

 3. To be able to feed our model with a reasonable amount of data, we use a group recipe to compute ```min, max, avg, stddev, count``` aggregations for each sensor, over each batch_id. 
 At this stage the [dataset](dataset:batch_and_sensor_by_batch_id) has one row per batch and one column by sensor aggregation.
 
 4. To build our predictive model, we need to transform this dataset to have on each row the previous batch information and the next batch failure column. This is done through the [window](recipe:compute_batch_and_sensor_next) recipe where the lag between the last and the next batch is done.
  
 5. The last step is the [training recipe](recipe:train_Predict_next_batch_failure). It is trained on the ```failure_last``` column based on all the previous batch information and the next batch parameters. It can learn to detect anomalies in the sensor values to predict an imminent failure and help a technician with preventive maintenance.

In a separate thread, the other [group recipe](recipe:compute_batch_data_by_recipe) at the top is used to compute all the different batch parameters combinations to be able to compute the available filters in the dashboard