# Transfer Learning: Video Prediction and Spatiotemporal Urban Traffic Forecasting +
## 3 Methodology
### Transferred Models
#### 3.1.1 Models Based on Spatial Kernels  
Spatial filtering by predefined kernels is widely used in image processing due to its simplicity and clear results. Dozens of kernels are developed for image smoothing, sharpening, edge detection, interpolation, image inpainting, and other popular tasks. We selected a regression-based technique [10] that uses spatial kernel values as regressors for image inpainting as a base for our model. Following [PERSON] and [PERSON] [10], we selected two spatial kernels for our experiments, weighted average and standard deviation:  
\[avg(i,r,t)=\sum_{j\in NB(i,r)}w_{ij}(\sigma,r)y_{j,t} \tag{4}\]  
\[sd(i,r,t)=\sqrt{\frac{1}{\left|NB(i,r)\right|}\sum_{j\in NB(i,r)}\left(y_{j,t}- avg(i,r,t)\right)^{2}} \tag{5}\]  
The spatially weighted average is a popular kernel for smoothing, while the standard deviation is a variant of edge detection kernels. The key parameter of spatial filtering is a radius of convolution. Smaller radius values correspond to local area characteristics, and larger values to the characteristics of wider areas, and their combination allows the representation of the spatial dynamics of the process. Thus, for our model specification, we simultaneously utilized kernel values for neighborhoods (1) for two radii, \(r_{1}\) and \(r_{2}\): \(NB(i,r_{1})\) and \(NB(i,r_{2})\). The sample neighborhoods are presented in Figure 1; neighborhood radii are tuned by the cross-validation procedure. Another potential issue with the definition of the spatial neighborhood is related to the forecasting horizon. Mostly, models are trained for one-step-ahead forecasts and further iteratively applied for longer forecasting horizons. Alternatively, models can be trained for a specified forecasting horizon. For the latter approach to longer forecasting horizons, the spatial neighborhood can be defined on the basis of the forecasting horizon value \(h\). Assuming that the acting spatial neighborhood can be wider for longer forecasting horizons, we tested the following specification of expanding spatial neighborhoods:  
\[r_{h}=r+step*h \tag{6}\]  
where \(step\) is a constant speed of neighborhood expansion (\(step=0\) corresponds to constant spatial neighborhood for all forecasting horizons). Figure 1: Two spatial neighborhoods. The resulting set of spatial kernels is defined as:  
\[SpX_{i,t,h}=\Big{\{}avg\big{(}i,r_{1,h},t\big{)},sd\big{(}i,r_{1,h},t\big{)}, avg\big{(}i,r_{2,h},t\big{)},sd\big{(}i,r_{2,h},t\big{)}\Big{)} \tag{7}\]  
Given the set of regressors \(SpX_{i,t}\), we consider the model to predict the traffic flow:  
\[y_{i,t+h}=g\big{(}\beta,SpX_{i,t,h}\big{)}+\varepsilon_{i,t} \tag{8}\]  
where \(g\) and \(\beta\) are the model function and a vector of its parameters, respectively, and \(\varepsilon_{i,t}\) is a vector of random terms. Two specifications of \(g\) functions are tested: linear and non-linear. The non-linear model specification is implemented using the support vector regression (SVR) [50]. Corresponding specifications are further referred to as SpX-lm (linear) and SpX-SVR (SVR-based model). Note that SpX-lm and SpX-SVR are based on spatial neighborhoods' states only, and do not include historical information on the spatial location itself. These specifications are fairly restrictive, but allow for transferring models between spatial locations--a model, trained for a spatial location with available historical information, can be applied for the forecasting of traffic flows at another spatial location where the historical information is not available. This approach corresponds to ideas of the cross-region transferring of traffic forecasting models, presented by [PERSON] et al. [51]. In contrast to the mentioned study, our model specification is purely based on traffic data in neighborhoods and does not utilize information on road density, nearby points of interest, and other traffic-specific features. If historical information on the spatial location is available, then the model specification can be enhanced by combining it with classical time series models.