# Dynamic Line Scan Thermography Parameter Design via Gaussian Process Emulation
## 2 Materials and Methods
### Active Learning  
The process of simulating the values for the temperature difference given a large amount of inputs is very time consuming. The strategy to overcome this via emulation is to train a machine learning algorithm to predict those values. The aim is now to train the model as accurately as possible, given a limited number of data points. This is achieved by the following steps:  
1. A small selection of data points is sampled uniformly from the dataset. Alternatively, those points could lay an n-dimensional grid, or be a Latin hypercube sampled or chosen from a Sobol sequence. In [12], a comparison between the different sampling methods is made. In this work, we restrict ourselves to uniform sampling, as it is the most simple method. For a more comprehensive study on this topic, we refer the reader to [16; 17].  
2. The model (in our case, the Gaussian process) is trained on this initial small dataset.
3. The point from the input space with the highest uncertainty (variance) in the GP's posterior distribution is chosen and added to the dataset of the GP, which is then retrained. This method is called uncertainty sampling (US). Alternatively, the point which reduces the total variance of the posterior could be chosen. This method is called integrated variance reduction (IVR). We implement US because it is cheaper to compute [18].
4. Step 3 is repeated until a certain criterion is met. When limited by a computational budget, this could be a fixed number of iterations. Another criterion is convergence in the posterior distribution, which means that adding new data points no longer has a significant result on the predictions of the GP.  
This process is called active learning and has been well studied by the machine learning community [9; 19; 20; 21]. A more recent view on the subject in the context of information theory can be found in [22]. This algorithm is summarized in Algorithm 1.  
```
1:trainset \(\leftarrow\) dataset(\(n\)) \(\triangleright\) start with a training set of n random points
2:testset \(\leftarrow\) dataset - trainset \(\triangleright\) put remaining points in test set
3:GP.train(trainset) \(\triangleright\) train Gaussian process on trainset
4:oldPosterior \(\leftarrow\) GP.predict(testset + trainset) \(\triangleright\) get the GP posterior
5:while nrOfterations < maxNrOfterations \(\triangleright\) check computational budget
6:ordiffPosterior > minDiffPosterior do\(\triangleright\) check for convergence
7: ActiveLearningIteration(GP) \(\triangleright\) perform one iteration
8: newPosterior \(\leftarrow\) GP.predict(testset + trainset) \(\triangleright\) get the GP posterior
9: diffPosterior \(\leftarrow\) newPosterior - oldPosterior \(\triangleright\) calculate the change
10: oldPosterior \(\leftarrow\) newPosterior \(\triangleright\) store for next iteration
11:endwhile
12:procedureActiveLearningIteration(GP) \(\triangleright\) Active Learning iteration
13: trainset \(\leftarrow\) dataset(US(testset)) \(\triangleright\) update training set
14: testset \(\leftarrow\) dataset - trainset \(\triangleright\) update test set
15: GP.train(trainset) \(\triangleright\) retrain GP
16:endprocedure
17:procedureUS(testset) \(\triangleright\) Uncertainty Sampling
18:for all\(\mathbf{x}_{\text{test}}\in\) testset do\(\triangleright\) evaluate every test point
19:if\(\text{var}(\mathbf{x}_{\text{test}})>\text{var}(\mathbf{x}_{\text{mostVar}})\)then
20:\(\mathbf{x}_{\text{mostVar}}\leftarrow\mathbf{x}_{\text{test}}\)\(\triangleright\) this point becomes new candidate
21:endif
22:endfor
23:return\(\mathbf{x}_{\text{mostVar}}\)\(\triangleright\) return test point with most variance
24:endprocedure
```  
**Algorithm 1** Active learning with uncertainty sampling.