# Reducing Forecast Errors of a Regional Climate Model Using Adaptive Filters
## 4 Proposed Framework for Climate Forecast Error Reduction
### Climate Series Clustering  
The K-means algorithm [25] is employed to cluster the grid time series from different cells. Clustering reduces the number of filters to be trained. One trains a filter for each clustered time series (a group of cells) instead of one filter for each time series (one cell), increasing the quantity of data available to adapt each filter. Using the K-means, one clusters the time series of different cells according to the (vector) distance between them. At each iteration, one evaluates the partitioning quality and reassigns the time series within the clusters so that they are more similar within a cluster and more different among clusters. Let \(\mathcal{Z}=\{\mathbf{z}_{i}\}_{i=1,\dots,Z}\) be the set of \(Z\) elements to be clustered. Consider \(K\) clusters \(\mathcal{C}_{k}\), \(\mathcal{C}_{i}\cap\mathcal{C}_{j}=\emptyset\) for \(1\leq i\), \(j\leq K\) and \(i\
eq j\), each cluster is represented by a centroid \(\mathbf{c}_{k}\), \(k\in\{1,\dots,\ K\}\). K-means clusters the elements in \(\mathcal{Z}\) using the distances to the centroids--that is, \(\mathbf{z}_{i}\) is assigned to the \(\hat{k}\)-th cluster if \(\arg\min_{k}\ \mathbf{d}(\mathbf{z}_{i},\mathbf{c}_{k})=\hat{k}\), where \(d(\cdot,\cdot)\) is the Euclidean distance between two vectors (For vectors \(\mathbf{v}\) and \(\mathbf{r}\), i.e., \(d(\mathbf{v},\mathbf{r})=\sqrt{\sum_{n}(v(n)-r(n))^{2}}\), \(v(n)\) is the \(n\)-th coordinate of \(\mathbf{v}\).). After assigning the elements to the clusters, each cluster centroid is updated as the arithmetic mean of its elements. The mean is an appropriate metric since it can be representative of magnitude of the variable in the season. At the first iteration, \(K\) elements in \(\mathcal{Z}\) are randomly selected as centroids [25; 31]. The process in the paragraph above is iterated until a predefined number of iterations is reached or the process stabilizes in terms that very small variations of assignments and centroids occur. Let \(C_{k}\) be the number of elements in cluster \(k\), the total clustering distance within cluster \(k\) is  
\[D_{k}=\frac{1}{C_{k}}\sum_{z_{i}\in C_{k}}d(\mathbf{z}_{i},c_{k}), \tag{3}\]  
Figure 4: Basic methodology for filter adaption in order to improve the forecast skill of climate models. The Eta forecast and the NCEP reanalysis are adjusted to the same grid. Then, in the Clusters Design block, unsupervised learning is employed to clusters cells presenting similar statistics. The time-series of the climate variables in each cluster are serialized in the Separation and Concatenation block. The resulting signals are used to adjust filter coefficients of the FIR filter that postprocesses the climate forecast cells on the time dimension, aiming at reducing forecast errors. Filter adaption uses the RLS (Recursive Least-Squares) algorithm. and the total clustering distortion (considering all clusters) is  
\[D_{s}=\sum_{k=1}^{K}D_{k}. \tag{4}\]  
Small changes in \(D_{s}\) between successive iterations represent small changes in the clusters, meaning that the assignment of the time-series to clusters stabilizes. The problem one must address is to find the best number of clusters \(K\) for a given dataset. This is an unsupervised learning problem. We do not need only to assign the time series within clusters to minimize the total distortion but also to discover the appropriate number of clusters for the dataset. To investigate this, we use the \"Validity\" index  
\[\text{Validity}(K)=\frac{\text{intra}(K)}{\text{inter}(K)}. \tag{5}\]  
Above,  
\[\text{intra}(K)=\sum_{k=1}^{K}D_{k}, \tag{6}\]  
which is the sum of the distances inside each cluster and  
\[\text{inter}(K)=\min_{i,\ j\in\{1,\dots,K\},\ i\
eq j}\parallel\mathbf{c}_{i}- \mathbf{c}_{j}\parallel, \tag{7}\]  
returns the smaller distance between cluster centroids. The \(K\)-means minimizes iteratively all the \(d_{k}\), maximizing also the distances between different cluster centroids [31].