SlowGuess/NeurIPS_2023_OCR huggingface dataset:
>>> from ml_for_road_safety import MultitaskTrainer
# Generate task groupings from previous task grouping methods, such as TAG or HOA
>>> task_list = ["DE'accident_classification", "IL'accident_classification",
"MA'accident_classification", "MD'accident_classification", ...]
>>> task_groups = group_tasks(method = "hoa", task_list)
# Generated task grouping is a list of grouped tasks
>>> task_groups = [
  ["DE'accident_classification", "IL'accident_classification"], ...
  ["MA'accident_classification", "MD'accident_classification", ..., ]
  ["IA'accident_classification", "NV'accident_classification", ...]
]
>>> for task_name in group_task_list:  
>>> state_name, data_type, task_type = task_name.split("_")  
>>> taskDatasets[task_name] = TrafficAccidentDataset(state_name)  
>>> task Evaluators[task_name] = Evaluator(task_type)  
# Initialize a trainer with the combined datasets of a group  
>>> trainer = MultitaskTrainer(model, tasks = group_task_list, task_toDatasets=taskDatasets, task_tovaluators=taskvaluators, ...)  
# Conduct multitask learning on one group of tasks  
>>> trainer.train()
Code Snippet 8: Training multitask learning models on groups of tasks
For transfer learning, we consider two regularization methods for fine-tuning a model trained on a source task to a target task. These methods include soft penalty (SP) and sharpness-aware minimization (SAM). Soft penalty regularizes the fine-tuned model distances to the initial model weights. Sharpness-aware minimization simultaneously minimizes loss value and loss sharpness with regard to the model weights. For example, as shown in Code Snippets 9, one can define a trainer to add the soft penalty loss by modifying the training loss in the base trainer class. Then, the user can use the trainer to fine-tune a model with a soft penalty on the fine-tuned distances.
>>> from ml_for_road_safety import Trainer
# Define a trainer for soft penalty inherited from the base Trainer class
>>> class SoftPenaltyTrainer(Trainer):
# Modify the training loss in the training logic
>>> def train_epoch(self):
# Combine the soft penalty loss with the cross-entropy loss
>>> loss = cross_entropy_loss + \
lambda*addsoft_penalty(model, initial_state_dict)
>>> ...
# Initialize a soft penalty trainer
>>> trainer = SoftPenaltyTrainer(model, dataset, evaluator, initial_state_dict, ...) 
# Conduct training and evaluation inside the trainer
>>> log = trainer.train()
Code Snippet 9: Implementation of fine-tuning with soft penalties
We find that using these methods improves the test performance over simple methods by  $0.6\%$  on average over four states. More comprehensive evaluations of related methods are left for future work.
C Additional Related Works and Discussions
Spatiotemporal graph neural networks. Previous works have proposed spatiotemporal graph neural networks to capture spatial and temporal dependencies for time series analysis on graph-structured data. DCRNN [39] captures the spatial dependency using bidirectional random walks on the graph and the temporal dependency using the encoder-decoder architecture with scheduled sampling. Instead of applying regular convolutional and recurrent units, STGCN [68] builds the model with complete convolutional structures, which enable much faster training speed with fewer parameters. Bai et al. [1] propose AGCRN with two adaptive modules for enhancing GNNs, including one module to capture node-specific patterns and another to infer the inter-dependencies among different traffic series automatically. Wu et al. [62] develop Graph WaveNet with an adaptive dependency matrix to capture the hidden spatial dependency in the data and a dilated 1D convolution component to handle very long sequences. We refer interested readers to a comprehensive survey [58] on spatio-temporal models.
Graph contrastive learning. The use of contrastive learning on graph-structured data has been extensively explored in recent work [67]. A refined optimization algorithm is introduced in You et al. [66]. For spatiotemporal graph learning, Qu et al. [50] formulate a contrastive self-supervision method to predict fine-grained urban flows considering all spatial and temporal contrastive patterns.
Zhang et al. [71] build a heterogeneous graph neural architecture to capture the multi-view region dependencies concerning POI semantics, mobility flow patterns, and geographical distances.
Explainability in graph neural networks. Yuan et al. [69] provide unified and taxonomic explanations regarding the importance of a node/an edge/a subgraph in a graph neural network, etc. In our leave-one-out analysis, because we are interested in which categories of information (graph structural vs. weather vs. traffic volume) are most useful, our analysis can be viewed as a first-order explanation of the importance of graph structural features. Further applying the methods of Yuan et al. [69] to explain our findings is a research question for future studies.
Multitask and transfer learning. Our methods for conducting multitask learning are based on recent theoretical developments regarding negative transfer in multitask learning, thus calling for more robust procedures [64]. In particular, Li et al. [36] propose surrogate modeling to approximate multitask predictions. Li et al. [35] introduce a boosting procedure as an ensemble method for multitask learning on graph-structured data. Our methods for transfer learning are based on recent developments for robust fine-tuning [37, 33]. Ju et al. [32] develop a spectrally-normalized generalization bound for graph neural networks and design a noise-stability optimization algorithm for improved fine-tuning.
Development of our dataset. Our dataset includes the road network features and weather information for all the states in the US. The bottleneck is the traffic volume and the accident records. For the eight states in our current dataset, both types of data are published by the Department of Transportation on the respective state's website. See the links to each state's government website in Table 6.
For the other states, we have checked their Department of Transportation websites, and we could not find detailed data, including accidents and traffic volume (like the eight states we currently have). Once the data is updated, we would be happy to update our dataset as well.
For a few states, for example, California and New York, the traffic volume data and accident information are both available for a few counties through their transportation departments, such as Los Angeles and New York City. For New York City, we have collected 2.02 million accident records from 2012 to 2023, including the latitude and longitude of each accident. For California, we have 0.4 million Motor Vehicle Crashes from 2016 to 2021. However, these do not have the latitude and longitude information, so we cannot match a record to a particular edge/node of the network.