scieee AI-readable full text Open interactive document viewer

Robust data sampling in machine learning: A game-theoretic framework for training and validation data selection

Mo, Zhaobin,Di, Xuan,Shi, Rongye

Abstract

EconStor is a publication server for scholarly economic literature, provided as a non-commercial public service by the ZBW.

Full text

Mo, Zhaobin; Di, Xuan; Shi, Rongye Article Robust data sampling in machine learning: A gametheoretic framework for training and validation data selection Games Provided in Cooperation with: MDPI – Multidisciplinary Digital Publishing Institute, Basel Suggested Citation: Mo, Zhaobin; Di, Xuan; Shi, Rongye (2023) : Robust data sampling in machine learning: A game-theoretic framework for training and validation data selection, Games, ISSN 2073-4336, MDPI, Basel, Vol. 14, Iss. 1, pp. 1-13, https://doi.org/10.3390/g14010013 This Version is available at: https://hdl.handle.net/10419/330006 Standard-Nutzungsbedingungen: Die Dokumente auf EconStor dürfen zu eigenen wissenschaftlichen Zwecken und zum Privatgebrauch gespeichert und kopiert werden. Sie dürfen die Dokumente nicht für öffentliche oder kommerzielle Zwecke vervielfältigen, öffentlich ausstellen, öffentlich zugänglich machen, vertreiben oder anderweitig nutzen. Sofern die Verfasser die Dokumente unter Open-Content-Lizenzen (insbesondere CC-Lizenzen) zur Verfügung gestellt haben sollten, gelten abweichend von diesen Nutzungsbedingungen die in der dort genannten Lizenz gewährten Nutzungsrechte. Terms of use: Documents in EconStor may be saved and copied for your personal and scholarly purposes. You are not to copy documents for public or commercial purposes, to exhibit the documents publicly, to make them publicly available on the internet, or to distribute or otherwise use the documents in public. If the documents have been made available under an Open Content Licence (especially Creative Commons Licences), you may exercise further usage rights as specified in the indicated licence. https://creativecommons.org/licenses/by/4.0/ Citation: Mo, Z.; Di, X.; Shi, R. Robust Data Sampling in Machine Learning: A Game-Theoretic Framework for Training and Validation Data Selection. Games 2023,14, 13. https://doi.org/ 10.3390/g14010013 Academic Editors: Concetto Paolo Vinci and Ulrich Berger Received: 1 January 2023 Revised: 16 January 2023 Accepted: 19 January 2023 Published: 30 January 2023 Copyright: © 2023 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https:// creativecommons.org/licenses/by/ 4.0/). games Article Robust Data Sampling in Machine Learning: A Game-Theoretic Framework for Training and Validation Data Selection Zhaobin Mo 1, Xuan Di 1,2,* and Rongye Shi 1 1Department of Civil Engineering and Engineering Mechanics, Columbia University, New York, NY 10027, USA 2Data Science Institute, Columbia University, New York, NY 10027, USA *Correspondence: shar[email protected]; Tel.: +1-212-853-0435 Abstract: How to sample training/validation data is an important question for machine learning models, especially when the dataset is heterogeneous and skewed. In this paper, we propose a data sampling method that robustly selects training/validation data. We formulate the training/validation data sampling process as a two-player game: a trainer aims to sample training data so as to minimize the test error, while a validator adversarially samples validation data that can increase the test error. Robust sampling is achieved at the game equilibrium. To accelerate the searching process, we adopt reinforcement learning aided Monte Carlo trees search (MCTS). We apply our method to a car-following modeling problem, a complicated scenario with heterogeneous and random human driving behavior. Real-world data, the Next Generation SIMulation (NGSIM), is used to validate this method, and experiment results demonstrate the sampling robustness and thereby the model out-of-sample performance. Keywords: two-player game; Monte Carlo tree search; reinforcement learning; car-following modeling 1. Introduction Algorithms, computing resource, and data are three pillars of current machine learning (ML) models. While ML has witnessed significant breakthroughs in multiple domains with the help of the state-of-the-art algorithms and powerful computing systems, data collection and quality remains non-negligible issues, making data a bottleneck that hinders the development of ML models. On one hand, collecting real-world data is difficult and time-consuming. Even if several solutions have been proposed to address the data sparsity issues, such one/zero shot ML [ 1 ] and physics-informed ML [ 2 – 5 ], data scarcity still limits the development of ML model as abundant data is usually needed to train powerful and reliable models. On the other hand, real-world data is noisy and imbalanced [ 6 , 7 ], and adversarial attack may take advantage of it and poison training datasets, leading to catastrophic predictions. Thus, it is important to consider how to better exploit existing data by improving sampling methods. Several methods have been proposed to tackle the data imbalance and heterogeneity. Biased sampling puts more weights on the critical samples or corner cases. This branch of methods decreases the sampling weights of the majority (i.e., downsampling) or increases the chance of sampling the minority (i.e., upsampling), such as SMOTE [ 8 ] and importance sampling [ 9 ]. Adversarial training aims to train robust neural networks that are robust to adversarial attacks [ 10 – 12 ]. In particular, [ 11 ] integrates the selector, discriminator, and adversarial attacker into one network leveraging generative adversarial nets. In this work, a robust classifier is trained along with a robust adversarial example selector as a by-product. These studies, however, only focus on changing the sampling proportions of training data and randomly sampling validation data, underestimating the role of validation data in training the ML models. Even if training data is incomplete and free of noise, validation data can be biased in model performance evaluation. For instance, if Games 2023,14, 13. https://doi.org/10.3390/g14010013 https://www.mdpi.com/journal/games Games 2023,14, 13 2 of 13 the validation dataset contains the same regimes as those in the training data, the model prediction may not be significantly affected. In other words, it is not only the training data but the completeness of both training and validation data that determines the model performance on the holdout test data. Thus, the strategic selection of both training and validation datasets should be taken into account. In this paper, we aim to develop a methodological framework for robustly training ML models by strategically selecting training and validation data. Accordingly, we need to model the actions of two game players, namely: 1. training data selector (trainer): selects an optimal set of training data that minimizes the test error; 2. validation data selector (validator): selects another set of vehicle trajectory records that maximizes test error. In this game, the trainer selects the optimal training set, while the validator decides a validation set that may deteriorate the model’s performance on a holdout test set. This adversarially selected validation data serves as a complement to the trainer’s previously selected training data. Each player is perfectly informed and takes turns to select the next data point according to the previously selected ones. As the game continues, the data traversed by two players will be intelligently balanced among data of different quality, which ensures a stable model that will not overfit on specific regimes. A neural network is developed to represent a complicated mapping from the game state to a value function, where a Monte Carlo tree search (MCTS) [ 13 ] is used to estimate a reward for each selection of the data. Reinforcement learning is used to update each player’s strategy, and enables both players to collectively find an optimal model with limited data availability in an accelerated fashion. We apply the proposed sampling method to train an ML model (neural network) to learn the human car-following (CF) behavior. The CF modeling problem is selected as it is theoretically straightforward for demonstration but practically challenging because of the driver’s random and heterogeneous behavior. The remainder of this paper is organized as follows. In Section 2, related works are introduced, including CF modeling and MCTS. In Section 3, the methodology is introduced, including the two-player game, MCTS, and reinforcement learning. In Section 4, an example experiment using NGSIM data, a real-world driver trajectory dataset, is presented. Finally, conclusions and future works are presented in Section 5. 2. Related Works 2.1. Car-Following Models Traditional CF models are not capable of predicting traffic oscillation [ 14 ]. In other words, a driving model calibrated by one dataset may not be capable of predicting the emergent dynamics arising from another dataset. Ref. [ 15 ] summarized eight levels of trajectory completeness based on the number of driving regimes. They found that the impact of completeness on CF modeling is model-specific and CF models perform better on average if training datasets contain a higher number of complete trajectories. To capture the complex decision-making process involved in human driving, an increasing amount of studies have started using neural networks to represent a complex mapping from information input to driving actions [ 16 ]. Since the present driving strategies are highly correlated with previous traffic conditions, recurrent neural networks are further used to model the driving behavioral sequence in [ 14 ]. To address the poor generalization issue, reinforcement learning (RL) is applied in [ 17 , 18 ]. Instead of estimating parameters, RL learns decision-making mechanism from training data, so as to achieve better generalization capability. Nevertheless, all these studies assume training and validation data are randomly sampled. This work also differs from existing works because we focus on how to enhance the model performance merely by altering the sampling method. Games 2023,14, 13 3 of 13 2.2. Reinforcement-Learning-Aided MCTS (RL-MCTS) RL-MCTS is considered one of the key ingredients leading to the breakthrough in AlphaGo Zero [ 19 ]. This method has also been applied to [ 20 ], which develops a two-player cooperative sequential game for experiment design of material testing. Their game is comprised of one modeler and one experimenter. The modeler aims to write a model to reflect the elasto-plasticity, and the experimenter decides training and validation data to improve the performance of model prediction. However, the selection of validation data was only achieved by the partition of the original dataset, and validation data was always the complementary set of the training data. 3. Methodology In this section, we will define the problem of selecting data for training ML models. Then, we will formulate this problem as a two-player game, which is followed by the introduction of the states, actions, rules, scores, and rewards of the game. 3.1. Problem Statement Suppose f is a machine learning model mapping features to labels, f:X→y . Function f represents the general form of machine learning models like neural networks. We consider a 1-dimensional label y for simplicity in this paper, and note that the results and conclusion persist if a multi-dimensional label is considered. Given a model f and a dataset D={D(i)}N i=1={(X(i) , y(i))}N i=1 , the whole process of machine learning is divided into three stages. 1. Sampling: The dataset D is divided into training, validation, and test sets, i.e., D=Dtrain ∪ Dval ∪ Dtest . The training set Dtrain is used to update the model parameter θ by implementing back-propagation algorithms. The validation set Dval is used to monitor the model’s out-of-sample performance during training, and the test set Dtest is for the final evaluation of model f after training. The sizes of the training, validation, and test datasets are Ntrain,Nval, and Ntest, respectively. 2. Training: The training set Dtrain is used to update the model parameter θ , and the validation set Dval is used to avoid overfitting. 3. Evaluation: The trained model fis evaluated using the test set Dtest. The goal of this paper is to propose a new sampling method that makes the trained model more robust and generalizes better on unseen data. To compare the effectiveness of different sampling methods, the test set Dtest is pre-selected by random sampling. That is, the sampling methods differ in their ways of splitting the training and validation sets, and they use the same test set for evaluation. Following this, the problem of training an ML model can be formulated as follows: min Ntest ∑ i |y(i) test −f(X(i) test|θ∗)|2/Ntest s.t.Dtrain,Dval =Sampling(D\Dtest) θ∗=Training(f,Dtrain,Dval,θ0), (1) where θ0 and θ∗ are the initial and optimal parameters, respectively. This problem can also be viewed as a bi-level optimization problem. In the high level, optimal sampling is found to split the training and validation sets, which are then used to find the optimal model parameter in the low level. In this paper, we focus on optimizing the sampling process, and use the existing training method to update the parameter. 3.2. Two-Player Game We formulate the sampling process as a two-player game, which is illustrated in Figure 1. A trainer aims to select the training data that minimizes the test error, while the validator selects the validation data to maximize the test error. The purpose of the validator Games 2023,14, 13 4 of 13 is to provide adversarial examples during the training process so as to enhance the model generalizability. The game information, including each player’s move and the game result, is stored to update the strategy of each player. After several rounds of games and the convergence of the player’s strategy, the equilibrium is achieved so that the optimal data set components and sizes (i.e., Ntrain and Nval) are determined. Figure 1. Illustration of sampling training and validation sets as a two-player game. The game starts with empty training and validation sets, and the trainer and validator take turns to select or skip the next data point (i.e., next feature-label pair) until all data points have been chosen. Below is an example game built on a small dataset with 10 data points in total. The validator moves first by selecting the first data points into the validation sets, and the trainer then decides to skip the first data. The validator moves on according to the historical moves of both the trainer and validator. After 10 turns, the validator selects the 1st, 6th, and 8th data points into the validation set Dval , and the trainer selects the 2nd, 3rd, and 9th data points into the training set Dtrain . The training and evaluation processes are followed to calculate the reward, which will be used to update the trainer and validator. In the remainder of this section, we will introduce the details of the two-player game, including its states, actions, rules and scores. The architecture of each game player, which contains reinforcement learning (RL) and Monte Carlo tree search (MCTS) components, will also be detailed. Games 2023,14, 13 5 of 13 3.2.1. Game State The game is fully observed, i.e., both the training and validation player has access to the historical data selection. The current game state can be mathematically represented as a binary indicator vector s= [t1 , . . . , tN , v1 , . . . , vN] to indicate whether the corresponding training and validation data points are selected, where N is the size of the dataset, ∑N i=1ti=Ntrain and ∑N i=1vi=Nval . For example, t1= 1 means the 1st data point is selected into the training set, i.e., D(1)∈ Dtrain. In the initial state, all elements of the game state are 0. 3.2.2. Game Action In the example game, the actions of both players are the same: given the current state, each player chooses whether to select the next data point or not. We denote the action set as A={ 0, 1 } , where 0/1 indicates selecting/skipping the next data. Each player starts with the first data, which corresponds to the leftmost side of the dataset, and determines the choice of the next data by outputting the action a∈A . The player policy, i.e., the probability of each action set element to be selected, will be discussed later as shown in Equation (4). The player will not have legal moves when all data has been traversed, and the game stops when both players don’t have any legal moves. The final state records our data selection. 3.2.3. Game Rule The game is initialized with an empty game state. The game starts with the validator making the first move. Each player determines the action to select/skip the next data, starting from the leftmost data point (i.e., D(1) ). After making the selection, the current player is switched. The game terminates when both players have considered all the data, and the selected data is applied to train the model f , which will then be evaluated using the holdout test set. 3.2.4. Game Score In the example game, the mean squared error (MSE) is used to evaluate the performance of the model, and thus can be considered as a score to evaluate the data selection. If the score is high, the validator wins the game, and vice versa. Then, a non-trivial question is how to determine the MSE threshold for claiming a winner. In contrast with traditional two-player games, like chess and go games, the trainer and validator play asymmetric roles in the game of sampling data. To address the matter, we first measure the average test MSE of a random sampler, which we call the base MSE. We claim the trainer (validator) as the winner if the test MSE is significantly lower (higher) than the base MSE. Suppose our two players play randomly for sufficient games; the test MSE of the trained model is then a random variable, denoted as M=∑Ntest i|y(i) test −f(X(i) test|θ∗)|2/Ntest , where θ∗ is the optimal parameter. The test MSEs of different games are independently and identically distributed. The expectation of M , which is in fact the base MSE, should be a moderate value because both players lack intelligence, and thus there is no guarantee one could always outperform the other. To win the game, the test MSE should be significantly higher (for validator) or lower (for trainer) than the base MSE E(M) . In practice, we use the mean of Mto approximate E(M):∑Mi/n≈E(M), where nis the number of games played. Another non-trivial question is that, in implementation the player may use as much data as possible, which is a conservative policy. However, the redundant data will incur computation costs and also may hide the essential one. To solve that, we penalize the amount of data each player chooses. We encourage both players to choose as little data as possible while trying to win the game. The benefit of this trick is to unveil the most optimal and efficient data points. Our score definitions are as follows: Strain =MSE +α||s||0 Svalid =MSE −α||s||0(2) Games 2023,14, 13 6 of 13 where s is the final game state, α controls the penalty for the selected data size, and || · ||0 is the L0 norm that computes the number of non-zero elements. It is hard to find a unified form of the score for both the trainer and validator because they have opposite targets. Therefore, scores are calculated for both the trainer and validator separately, and the means of scores after sufficient games are Strain =∑n i=1S(i) train/n and Svalid =∑n i=1S(i) valid/n for the trainer and validator, respectively. 3.2.5. Game Reward The game reward, usually ranging from − 1 to 1, describes how favorable the game outcome is towards each player. As two players in our game play competitively, the rewards for the trainer and validator are opposite. We adopt a mapping function to convert the scores to rewards. Let Snew train and Snew valid denote the score of a new game. If both the scores are bigger or lower than the average scores Strain and Svalid by a tolerance, we may announce a winner, and reward for the winner is +1 and for the loser is − 1. Otherwise, the game result is a tie. The reward is defined as follows: 1. If Snew train <Strain −tol and Snew valid <Svalid −tol, then rewardtrain =1 and rewardvalid =−1 2. If Snew train >Strain +tol and Snew valid >Svalid +tol, then rewardtrain =−1 and rewardvalid =1 3. Otherwise, a piece-wise linear function is adopted to map the score to the reward, which is shown in Figure 2. We randomly sample the training and validation data, then train and evaluate a CF model (the CF model will be introduced in Section 4), and Figure 2shows the distribution of the test MSE (left y-axis). The blue line shows the piece-wise mapping function of the reward (right axis), and the validator’s score- to-reward mapping is the opposite of the trainer. Figure 2. Score-reward mapping function of the trainer. The range of tol is the same as the average scores Strain and Svalid . Otherwise, if tol is too large, most games will end up with draws and return zero rewards; if tol is too small, a win with a narrow margin will receive a high reward value, imposing fluctuation on the game results. In experiments, tol is a hyperparameter to tune. 3.3. Monte Carlo Tree Search (MCTS) In avoidance of myopic and greedy moves, a player always chooses its next action considering its opponent’s future moves. In other words, each player solves a search problem, where the size of the search tree grows exponentially if multiple moves ahead are taken into consideration. To tackle this issue, MCTS iteratively explores the searching space, and gradually adjusts its exploration towards the most promising region. Below, we briefly introduce the tree components before moving on to the tree search strategy. Anode s represents the state of the game at a certain stage. For example, a root node represents the initial game state with empty training and validation sets, and a termination node represents the final game state where the training and validation sets are sampled. All nodes, except for the termination node, connect to their children nodes through edges, Games 2023,14, 13 7 of 13 which represent actions of the current player. A tree starts with the root node as its only component and grows by appending one child node. The newly added child node is called aleaf node, and it turns into a non-leaf node if one of its children nodes is also appended to the tree. Note that either the leaf or non-leaf attribute is specifically for the existing nodes of the tree. The termination node is not a leaf node until it is visited and appended to the tree. The search iteration (Figure 3) involves traversing the existing tree from the root node to one leaf node, together with extending the tree by appending a new leaf node. In Figure 4, the red circle means the current player is the validator, and the blue square means the current player is the trainer. Specifically, each iteration includes four phases: • Selection. The first phase starts with the root node and sequentially selects the next node to visit until a leaf node is encountered. Each selection is based on: SELECT argmax a {¯ r(s,a) + cpuct p∑bn(s,b) 1+n(s,a)}, (3) where ¯ r(s , a) is the average reward gathered over all tree-walks, n(s , a) is the number of visit of edge a , and ∑bn(s,b) is the number of visit of node s . cpuct is a constant determining the level of exploration. • Expansion. When a leaf node is encountered, one of its children nodes is appended and the tree thus grows. • Playout. After the expansion phase, a random playout is used to finish the remaining search. That is, each player will randomly move in the rest of the game the termination node is reached and computing the associated reward. • Backup. The node and edge statistics are updated in the last phase of a searching iteration. First, the number of the visit of all traversed nodes and edges are incremented by one. Second, the current reward computed in the playout phase is back-propagated along the traversed path, and is used to update the average reward ¯ r(s,a). After the statistics of the nodes and edges are finished being backed up, MCTS starts the next iteration from the root node. The searching process terminated when the number of iterations reaches a preset value numIters , which is tuned to allow the game to reach equilibrium while avoiding excessive iterations. Then, the current player makes its next move based on the following policy π(a|s) = n(s,a)1/τ ∑bn(s,b)1/τ, (4) where τ is a tunable hyperparameter that controls the level of exploration. A large τ encourages random move selection, and a small τ prefers the move with the highest number of visits. After that, the other player takes turns to continue the game. Figure 3. Illustration of MCTS. Games 2023,14, 13 8 of 13 Figure 4. Neural network CF model. 3.4. Reinforcement-Learning-Aided MCTS (RL-MCTS) Taking inspiration from AlphaGo Zero [ 19 ], we adopt reinforcement learning (RL) to further narrow down the searching space by gradually biasing the search to a more promising region. 3.4.1. Value Network The key idea of applying RL to MCST is to replace the random and time-consuming playout with a function evaluation. When a leaf node is encountered, the current player approximates the average reward by a surrogate model instead of using the random playout. We employ two value network qT θ(s , a) and qV θ(s , a) for the trainer and validator, respectively. The networks take in the game state and action, and return the position value for the current player. We use the replay buffer to train the value network, where the states traversed together with the game results are fed into the value network as the training examples. As introduced in Section 2, the difference between two networks is that they are fed with different rewards after the game is completed. 3.4.2. MCTS with Value Networks Aided with RL, the RL-MCTS processes are updated as follows • Selection. Each selection is based on: SELECT argmax a {qθ(s,a) + cpuct p∑bn(s,b) 1+n(s,a)}. (5) Compared with Equation (3), the difference of RL-MCTS’s selection phase is that the average reward is replaced with the evaluation of the value function. • Expansion. This phase is the same as the MCST. • Playout. The reward attained from a random playout is replaced with the evaluation of the q value function. • Backup. The backup is the same as the MCTS, except for that the qvalue rather than the average reward is the statistic to be updated. 3.5. Summary The architecture consisting of a simulation platform and the two player game is bilevel. The trainer and validator play the sequential competitive game. After the game is finished and the data is generated, the test MSE is calculated at the simulation level, in which a neural network CF model is trained with the trainer’s data and validated by the validator’s data. The reward is then computed by the pre-defined rules and returned to the game level as the target for training the value network. The whole process is shown in Algorithm 1.