Predicting EV Charging with AutoML

Soeren Frey
Mercedes-Benz Tech Innovation
6 min readOct 19, 2021

Great electric vehicles (EVs) need a powerful and reliable charging network. To make this possible, infrastructure providers strive to prevent capacity bottlenecks and unforeseen peak loads. We show that AutoML can be used for predicting the short-term (up to a day) regional energy demand of EV charging operations and we compare this forecasting method with other established approaches.

We fuel the underlying data basis with a discrete-event simulation (DES) that can simulate the charging behavior of EV drivers using both home and public charging stations. This allows us to build a resilient training and prediction pipeline where simulation data can later be swapped with real data once it is broadly available for all charging options.

Data Acquisition via Simulation

DES uses events that can be triggered recurrently (e.g. a DrivingEvent or a PublicChargeEvent) based on a certain rule set. Hence, they also determine our simulation flow.

Simulation flow and corresponding events
Simulation flow and corresponding events

As soon as an EV finishes a tour, it must be decided whether the EV has to charge. If charging is required, either a private or public charging station is used, depending on the current location of the EV. After the vehicle has been sufficiently charged it will wait until another tour is initiated. Additionally, a charging operation can also be triggered during a tour of an EV if this becomes necessary. In this case, the nearest charging station is used and the tour is continued as soon as the EV has enough energy to reach its destination.

The simulation can be configured using 71 parameters. They enable to adjust general settings (e.g. population or amount of EVs) as well as the driving and charging behavior of the EVs itself. In the following, you can see an excerpt of these parameters. In the simulation run whose output data will later be used to train the ML models, the parameters were set to match the city of Stuttgart, Germany.

Simulation input parameters (excerpt)

  • ChargingStation.Location: Location of the charging station
  • ChargingStation.MaxCPower: Max. charging power of charging station
  • ChargingStation.NrCP: Nr. of charging points at charging station
  • Context.NrEV: Nr. of simulated EVs
  • Home.Location: Home location of the EV’s owner
  • StartOfWork.NDist.Mean: Mean start time of work
  • StartOfWork.NDist.Sd: Standard deviation start time of work

Some reasonable assumptions derived from (1) reported observations in the literature as well as (2) experience from corresponding in-house projects constitute the foundation of the simulation. For example, it is assumed that on weekdays, more people drive to workplaces and offices, whereas on weekends, leisure destinations become more important. It is also assumed that on weekdays, after work, trips are occasionally made to places of private life. The time when an EV starts a certain tour (e.g. to the work site) and how long the EVs stay at the respective destination can be individually configured with the help of the mentioned parameters.

Due to the the varying driving behavior of the simulated EVs, the amount of charging operations during a weekday and weekend day differ. The figure below compares the overall charging behavior of the EVs on weekdays and weekends and simultaneously shows the difference in the amount of public and private charging operations during a week. The total number of charging operations on weekends decreases compared to those on weekdays.

Public and private charging over a simulated week
Public and private charging over a simulated week

We now zoom in even further. On a weekday, around the morning hours, private charging operations decrease noticeably, while charging operations at public charging stations increase. This can be attributed to the fact that EVs are being driven to work sites or other locations. In the evening, the private charging operations then increase which means that the EVs reach their home location again. The amount of public charging operations over time is exactly the opposite. That means, when the private charging operations decrease, the public charging operations increase instead. This behavior is plausible as the EV are on the road and cannot charge at home.

Learning the Charging Patterns

We use AutoML (auto-sklearn) to make predictions about regional energy demands in a geographical area. AutoML is able to automatically generate and optimize machine learning models. Like any other ML approach, AutoML requires a training and test data set. In our case, we utilize the charging operations of a whole year generated by the simulation described above. For data preparation, we preprocess the simulation data using the following three major steps. (i) All charging operations that occur in a given partition are aggregated. A partition is a rectangle whose height and length are adjustable, i.e. the number of partitions decreases or increases. (ii) Charging operations are aggregated by time intervals. (iii) All other values describing a charging operation (e.g. charged amount of energy in kW) are aggregated and averaged.

As we will see below, the aggregation of charging operations by different partition sizes and time intervals allows us (1) to derive multiple feature sets, (2) to train corresponding competing models based on the alternative feature sets, and (3) to select the best suited model candidate.

In order to influence the learning behavior of AutoML, various additional parameters can be set (e.g. maximal ensemble size or meta-learning configuration to boost hyperparameter optimization). As we are interested to explore the potential of vanilla (out-of-the-box) AutoML, we do not modify the default automated model creation process.

To test the quality of the automatically generated models, we first compare the AutoML models with models created with sklearn’s standard Random Forest Regressor (RF). To get a rough overview of the quality of all created models, the metrics Mean Squared Error and R2 Score are applied (see Figure 4) while initially ignoring the type of model creation (AutoML or RF). A Mean Squared Error score closer to 0 and an R2 score closer to 1 denote better performance.

As can be seen in the next figure, some of the created models achieve good to very good results.

Performance of all created models (AutoML and RF)
Performance of all created models (AutoML and RF)

Now we investigate the difference between the two model creation types and also analyze the influence of varying partition sizes and time intervals for aggregating the charging operations. The corresponding R2 results for both AutoML (left) and RF (right) can be seen below.

Performance of AutoML (left) and RF (right) models according to partition size and time interval combinations
Performance of AutoML (left) and RF (right) models according to partition size and time interval combinations

Again, it can be seen that both techniques (AutoML and RF) train very good models for some combinations of partition size and time interval. In both cases, the best four models tend to cluster around combinations with (midsized) partition sizes of 100–200 meters and (larger) time intervals of 21,600–86,400 seconds (6–24 hours). In this comparison AutoML generates the best model using a partition size of 100 meters and a time interval of 86,400 seconds.

Finally, we compare the best models of multiple ML regressors (including the RF from above) with AutoML’s best one in the figure below.

The highest R2 score per regressor and AutoML
The highest R2 score per regressor and AutoML

It is noticeable that not AutoML, but a conventional regressor generated the best model. However, this result could change as soon as AutoML’s parameterization gets optimized beyond the vanilla default settings.

Conclusion

Simulating EV charging behavior can support numerous use cases in the context of electric mobility. In our application example, we utilized the simulation results to train ML models for predicting the short-term, regional energy demand that is induced by EV charging operations. Here, vanilla AutoML yielded well-suited models that constitute a very good baseline.

References

M. Schneider, S. Frey, Simulating Plug-in Electric Vehicle Charging for AutoML-Based Prediction of Regional Energy Demand, Proceedings of the 13th International Conference on Advances in System Simulation (SIMUL 2021), pp. 44–48, Barcelona, Spain, 2021.

F. Hutter, L. Kotthoff, and J. Vanschoren, Eds., Automated Machine
Learning: Methods, Systems, Challenges
. Springer, 2019.

N. Matloff, Introduction to Discrete-Event Simulation and the SimPy Language, University of California, Davis, Dept of Computer Science, vol. 2, 2008.

Authors

Sören Frey, Senior IT Architect at Daimler TSS GmbH
Matthias Schneider, Software Engineer at Daimler TSS GmbH

--

--