# Detecting Plasma Detachment in the Wendelstein 7-X Stellarator Using Machine Learning
## 2 Methods
### The Dataset  
An important experimentally measured indicator of detachment is the fraction of radiated power \(f_{rad}\), which can be calculated as radiated power divided by the plasma heating power \((P_{rad}/P_{heat})\). As seen in [19], the most advanced simulations of the W7-X detachments predicts that when \(f_{rad}\) exceeds approximately 0.5, the radiation zone begins to detach from the target and starts to move inward; between 0.8 and 0.9 the temperature and the pressure on the last closed flux surface (in our case, the separatrix) falls drastically. Being aware of these results, we used \(f_{rad}>0.85\) as indicator for detachment and built our dataset accordingly.  
Our dataset consists of images taken during the OP1.2 campaign in 2018, using the camera in the AEQ50 port (for the particular discharges we refer to Table 1). The dataset was divided into three parts: training data, validation data and test data. The training set is made of approximately 7770 images from 16 different discharges; from these, 3889 are detached and 3882 are non-detached. For the latter we found it important to contain a wide variety of images, e.g., plasma start-up, plasma end and non-detached images from discharges with and without a detachment phase. Besides that, three additional discharges were reserved. One, discharge 20181016.016, to serve as a validation dataset during the cross-validation process (for more detail see later), and two shots, 20180814.023 and 20181010.035, to calculate the performance metrics of the models (test). Both have detached intervals from 4.18 s to 7.84 s and from 2.89 s and to 6.75 s, respectively.  
After gathering these images, we extracted the appropriate pixel intensity profiles (our workflow can be seen in Figure 4). We represent each profile as a vector, these vectors make up a matrix X. This matrix, paired up with a vector y containing binary values for each profile in the matrix, indicating if the profile is detached (1) or non-detached (0), are the inputs to the models.  
The dataset was created while keeping in mind that we only want to decide if on the given image the fusion plasma is in a dedicated detached state or not. In the dedicated detached state the plasma is stable despite its reduced contact with the machine walls, filling up the available space in the vacuum chamber as much as possible, without exhibiting  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Discharge ID** & **Detached Interval [Frames]** & **Non-Detached Interval [Frames]** \\ \hline
20180814.016 & 768–1282 & 0–600 \\
20180814.025 & 676–783 & 0–500 \\
20181010.030 & 298–902 & - \\
20181010.034 & 323–902 & 0–200 \\
20181010.036 & 298–698 & 0–200 \\
20  
significant heat load onto the divertor. There are various other plasma states when the plasma is not in contact with the divertor either, and in which the radiation belt moves deeply inside the core plasma, far away from the separatrix. Technically, these states are also detached, but usually unstable--we aim to get a negative response from our algorithm for these states, hence we use the term \"non-detached\" instead of simply using \"attached\".