Accurate surface ultraviolet radiation forecasting for clinical applications with deep neural network

Exposure to appropriate doses of UV radiation provides enormously health and medical treatment benefits including psoriasis. Typical hospital-based phototherapy cabinets contain a bunch of artificial lamps, either broad-band (main emission spectrum 280–360 nm, maximum 320 nm), or narrow-band UV B irradiation (main emission spectrum 310–315 nm, maximum 311 nm). For patients who cannot access phototherapy centers, sunbathing, or heliotherapy, can be a safe and effective treatment alternative. However, as sunlight contains the full range of UV radiation (290–400 nm), careful sunbathing supervised by photodermatologist based on accurate UV radiation forecast is vital to minimize potential adverse effects. Here, using 10-year UV radiation data collected at Nakhon Pathom, Thailand, we developed a deep learning model for UV radiation prediction which achieves around 10% error for 24-h forecast and 13–16% error for 7-day up to 4-week forecast. Our approach can be extended to UV data from different geographical regions as well as various biological action spectra. This will become one of the key tools for developing national heliotherapy protocol in Thailand. Our model has been made available at https://github.com/cmb-chula/SurfUVNet.


Methods
Surface UV and weather data acquisition. Surface UV radiation, total ozone column, cloud coverage, and aerosol optical depth at 500 nm (AOD500), were collected at the Faculty of Science, Silpakorn University, Nakhon Pathom, Thailand (13.82° N, 100.04° E) from January 2009 to May 2019. UV intensity was measured every 10 min from 5AM to 7PM at 1-nm wavelength interval from 280 to 400 nm in mW/m 2 unit using a DMc150 double monochromator (Bentham Instruments, Berkshire, UK). AOD500 and cloud coverage data were collected from 6 AM to 6 PM from January 2011 to December 2018. Hourly AOD500 data were measured by a ground based CE318 sunphotometer (Cimel Electronique, Paris, France) and calibrated by the Aerosol Robotic Network (NASA, Washington, DC, USA). Cloud coverage data were estimated on a 0-10 scale from recorded images of the sky every hour through a PSV-100 skyview instrument (Prede Company, Tokyo, Japan). Total ozone column data were measured daily in Dobson unit (DU) via an OMI/Aura satellite (NASA, Washington, DC, USA) from January 2011 to December 2019. The distributions of UV radiation, cloud, ozone and AOD500 in Nakhon Pathom throughout the year are shown in Fig. 1a-d, respectively.
Hourly downward surface UV radiation in J/m 2 , total ozone column in kg/m 2 , and mid cloud coverage were also downloaded from ERA5 41 for London, England (51.5° N, 0° E) and Tokyo, Japan (35.75° N, 139.75° E) from 5AM to 7PM from January 2011 to December 2019. It should be noted that ERA5 datasets were generated from a combination of actual observation (every 3-h) and computational reanalysis. ERA5 downward UV radiation data cover the 200-440 nm wavelength range.
Data cleaning and preprocessing. Surface UV radiation exhibits an annual seasonal pattern. We used this pattern as a justification for using UV data of the same dates from adjacent years to impute each missing data point. This is crucial because missing UV data often arise from sensor malfunction which typically spans multiple days. Also, because the artificial neural network model cannot handle missing values, imputation increases the number of data points that can be used to train and test the model. Specifically, we impute each missing data point with the average UV radiation from adjacent 10-min time steps, the same time steps from adjacent days, and the same dates from adjacent years. The ranges of adjacent time steps, days, and years that were used for imputation are 2, 5, and 2, respectively. Imputed data were visually inspected to ensure that the overall UV intensity follows the expected bell-shape pattern with a peak at around noon. In Thailand, this bell-shape pattern is often observed from October to January where there are few rainy and cloudy days. The Nakhon Pathom UV data from 2014 were excluded from further considerations as there is a technical problem with the instrument.
Nakhon Pathom UV data were split into a training set (2009-2017), for optimizing the parameters of artificial neural network models, a validation set (2018), for determining when to stop the optimization process, and a test set (2019), for evaluating the performance of the final models. We found that using the whole training set, i.e., using UV data from all dates and times, to train the models yielded the best performance. For the validation and test sets, we further exclude data from days with anomalous UV intensity profiles to prevent them from influencing the evaluation of the models. Specifically, we removed data from days whose UV profiles are highly skewed (absolute skewness greater than 0.3), disproportional (ratio between maximal and minimal irradiances greater than 15), or out of expected range (maximal irradiance above 400 or below 150 mW/m 2 ). The distributions of cloud coverage in the validation and test datasets are shown in Fig. 1e and f, respectively. Finally, the antipsoriatic irradiance at each time point was calculated from 280 to 400 nm UV data based on published psoriasis clearance action spectrum formula 17,42,43 .
For evaluating the impact of incorporating ozone and AOD500 information as input into SurfUVNet, because these data were available only up to 2018, we re-split the dataset by setting data from 2009 to 2016 as the training set, data from 2017 as the validation set, and data from 2018 as the test set. The same quality filter for excluding data from days with poor UV profiles defined above was also applied to these validation and test sets. SurfUVNet model variants with and without ozone and AOD500 as input were then trained and evaluated together on this data split.  44 and machine translation 39 . In the context of UV forecasting, an encoder-decoder model can be used to translate a sequence of past observed UV radiations into a sequence of future UV radiations. The model consists of two parts: encoder and decoder as shown in Fig. 2a. Both parts consist of multilayered LSTMs. As the names implied, the LSTMs in the encoder are used for encoding information from the input sequence while the LSTMs in the decoder decoded that information to generate the output sequence.
As the input to our model, for the main implementation which relies only on UV data, we use a sequence of 10-min interval antipsoriatic data from the previous days, denoted as [A 1 , A 2 , . . . , A t ] and a sequence of antipsoriatic data from the previous year, denoted as [B 1 , B 2 , . . . , B t ] . For the model variant which also accepts AOD500 and ozone, the inputs A i 's and B i 's will include these data of the same time-of-day from previous days and previous year as well. To handle differences in data resolution for various features (10-min for UV irradiance, hourly for AOD500, and daily for ozone), the values of features with lower resolutions were duplicated to match the highest resolution.
Since the antipsoriatic values are seasonal in nature, we also include day-of-year information as the input by encoding the day-of-year on a circular index defined as:  www.nature.com/scientificreports/ The circular date feature helps the model to learn the seasonal pattern. The model predicts future antipsoriatic values, y 1 , y 2 , . . . , y t .
Next, we provide detailed information of our model.

Encoder.
The decoder takes the previous day sequence [A 1 , A 2 , . . . , A t ] and the circular date feature as input.
We use a bi-directional 45 LSTM as the first layer to help the model learns the temporal effect in both directions. The autorecursive mode for long-term UV forecasting. To forecast UV radiation for the next N days, SurfUVNet first forecast next-day's UV radiation profile and then uses the prediction as input to forecast UV radiation profile for the day after. This process is repeated until the forecasts for the next N days are generated. www.nature.com/scientificreports/ The latter layers are uni-directional LSTM that will capture the information and pass the information to the decoder via the final cell state, S t .
Decoder. The decoder takes [B 1 , B 2 , . . . , B t ] as input and uses it to future predict antipsoriatic values. The first layer of the decoder is a LSTM layer which uses S t from the decoder as the initial value of the cell state. We also add two fully connected layers with sigmoid activation function with the dropout 46 rate of 0.2 after the LSTM layer for the final output. Before feeding the input data to the model, we denoised the input antipsoriatic data with the Savitzky-Golay filter 47 . Applying the filter, smooth out the input data, removing any possible noise spikes in the data. However, we do not apply this processing to the target output data. If we train the model to predict the denoised data, the model is learning to predict the unrealistic data and will not be able to handle noises in the UV intensities. Then, we normalized the antipsoriatic data into a range of [0, 1]. We trained the model using quantile loss 48 defined as: where y i is the actual value and y i is the predicted value, q is a quantile value which balances the penalties of overestimates and underestimates. If q is more than 0.5, the quantile loss gives more penalty to overestimated predictions and vice versa. In our work, we set q to 0.33 to favor overestimation rather than underestimation because underestimated results can cause sunburn to patients due to a prescribed sunbathing time that is too long.
Model training. We used Adaptive Moment Estimation (ADAM) 49

Results
SurfUVNet model architecture. The task of forecasting in general can be formulated as a problem of finding the best approximation for the relationship between past and future observations. For surface UV radiation, which exhibits an annual seasonal pattern, the profile of next-day UV radiation can be modeled using not only data from previous days but also data from previous years. Here, we adapted an encoder-decoder architecture, which can effectively capture relationship between sequence data, to develop an artificial neural network model for forecasting next-day surface UV radiation. Our model, named SurfUVNet, takes in UV radiation profiles of the past 7, 14, or 21 days through the encoder and passes the encoded information to the decoder. The decoder then takes in the UV radiation profile of the same date as the next day but from last year, combines it with information from the encoder, and then generates the next-day forecast (Fig. 2a). Intuitively, because UV radiation exhibits annual seasonal pattern, our approach models the next-day UV radiation profile as a transformed version of last year's data and uses recently observed UV pattern to learn the appropriate transformation. Finally, to forecast UV radiation profile further into the future, our approach essentially performs next-day forecast repeatedly via an auto-regressive approach. For example, if we define today as the day N, to predict the UV radiation profile for next week, or day N + 7, our model first uses data from days N − 6, N − 5, …, N to forecast UV for the day N + 1, and then uses the data from days N − 5, N − 4, …, N, and the forecast for the day N + 1 to forecast UV for the day N + 2, and so on (Fig. 2b).
Benchmark procedure. We evaluated the performance of SurfUVNet (also called Seq2Seq-14 here) against four alternative models: a simple model that uses the previous day UV radiation pattern as the prediction, an empirical approach that combined physics knowledge to define the interactions between UV-related factors with regression technique to learn coefficient values, which is currently in used by the Thai Meteorological Department 22 , a CNN-LSTM neural network model developed for solar power forecasting 27 , and an implementation of bidirectional GRU neural network model which is often used in time series forecasting applications.
As prior study has shown that the CNN-LSTM model benefits from additional smoothing of UV data from rainy days 27 , we considered two CNN-LSTM model implementations: one without smoothing and one with Savitzky-Golay filter 42 (denoted by CNN-LSTM and CNN-LSTM-SG in Fig. 3a and Table 1). To fairly compare model performance, the validation and test datasets were subjected to quality filtering to remove days with highly skewed and out-of-range UV irradiance values (see "Methods" section) where all models are expected to perform poorly on. However, it should be noted that this does not mean that our validation and test sets consist of only clear-sky data. The distribution of cloud coverage shows that both datasets contain many days with cloud coverage above 0.2 and up to 0.4 or more ( Fig. 1e and f).
Next-day antipsoriatic irradiance forecast for Nakhon Pathom dataset. All artificial neural network models were trained using the same UV data from 2011 to 2017 and evaluated on the same UV data from 2018 and 2019 while the regression model based on Earth-Sun distance and total ozone column was fit to UV and ozone data of the same year. All models were trained to forecast next-day antipsoriatic irradiance at 10-min resolution. Furthermore, as past UV radiation profile is a critical input data for artificial neural network models, we tried inputting data from 7, 14, or 21 days prior to the forecast date to explore whether the models benefit from seeing data from more distant past.
(2)  Fig. 3a and Table 1). It should be noted that while the CNN-LSTM-SG model can also reach similar levels of performance (MAPE of 11.39 and 11.84), it is highly sensitive to the length of input UV data. Changing the length of input UV data from 7 days to 14 or 21 days significantly raises the MAPE of CNN-LSTM-SG models to 13.87-17.74. In contrast, the performance of SurfUVNet is stable with respect to the length of the input. Furthermore, SurfUVNet achieves www.nature.com/scientificreports/ consistent forecasting accuracy throughout the day while the CNN-LSTM-SG model produce significantly higher forecast error during the morning and afternoon hours (8AM-9AM and 2PM-4PM) compared to the middle of the day (Fig. 3b and c). Lastly, comparison of ground truth antipsoriatic irradiance and SurfUVNet's forecast confirmed that SurfUVNet's prediction closely mimics the expected bell-shaped pattern of daily UV radiation in both validation and test sets ( Fig. 3d and e).

Next-day downward solar UV irradiance forecast for Tokyo and London datasets. All models
were further evaluated on hourly downward solar UV irradiance data obtained from ERA5 for Tokyo, Japan and London, England, which represent different weather regimes from Thailand's. In contrast to the seasonal cloud coverage pattern at Nakhon Pathom (Fig. 1b), cloud coverage for Tokyo and London fluctuates around 0.2-0.4 year-round (Supplementary Figure 1). Furthermore, day-to-day variation in UV radiation profiles are much higher in Tokyo and London compared to Nakhon Pathom, as indicated by much higher MAPE between today's and the next day's UV profiles (Tables 1 and 2 Figure 2).

Adding weather information does not improve forecasting. As atmospheric conditions can reflect
and scatter UV radiation before it reaches the Earth's surface, we tried incorporating total ozone column, atmospheric aerosol (AOD500), and cloud coverage data into SurfUVNet. However, cloud coverage data contain many missing values that could not be imputed due to the irregularity of the data and had to be excluded from model development. Instead, we used cloud coverage data to evaluate whether SurfUVNet overestimates the amount of UV radiation when the weather is cloudy. This reveals that SurfUVNet's forecasting errors weakly correlate with cloud condition (Fig. 4, spearman rank correlation = 0.16776, − 0.04546, and 0.20229 for Nakhon Pathom, www.nature.com/scientificreports/ Tokyo, and London 2019 datasets). For Nakhon Pathom dataset, SurfUVNet's forecast error stays roughly the same before shifting upward when cloud coverage goes above 0.7 (Fig. 4a). For Tokyo dataset, SurfUVNet's error is not correlated with cloud coverage at all (Fig. 4b). SurfUVNet's error shows the clearest correlation with cloud coverage in London dataset (Fig. 4c). Addition of ozone and AOD500 data into SurfUVNet does not improve the performance of the base model that utilizes only UV data (Supplementary Figure 3). The model with ozone and AOD500 data achieves MAPE of 15.33 on the validation set (data from 2017) and MAPE of 13.91 on the test set (data from 2018), while the base model achieves MAPE of 14.32 and 13.60, respectively. This may be because ozone and AOD500 data were collected at lower frequency (hourly vs every 10 min) and at a shorter time period during the day (6AM-6PM vs 5AM-7PM) than UV data. Although data from the early morning and late evening hours where the amount of UV radiation is almost nonexistence should not contribute much to the forecasting of UV radiation during daylight hours, we found that withholding UV data from 6AM to 8AM and 4PM to 6PM from the model slightly raises error from 10.51 to 11.78 MAPE (Wilcoxon signed rank test result is not significant with p value = 0.5567). Lastly, to evaluate the impact of uncertainty of next-day ozone and AOD500 on the forecast performance, a variant of SurfUVNet was trained with the actual values of next-day ozone and AOD500. This does not reduce the forecast error (MAPE of 15.70 and 15.50 on the validation and test sets, respectively), indicating that the limitation lies elsewhere.  Hospital. Each data point that constitutes the violin plots correspond to the error between predicted and actual antipsoriatic irradiances that a patient would be exposed to if he or she were to sunbath according to dermatologist's planning. www.nature.com/scientificreports/ Long-term antipsoriatic irradiance forecasting. Long-term UV forecasting is essential for heliotherapy applications as it allows clinicians and patients to plan sunbathing schedule in advance and make necessary adjustments to the schedule to achieve the desire UV radiation dosage. We explored two approaches for forecasting antipsoriatic irradiance for up to a month into the future (Fig. 5a). The first approach is to train a collection of artificial neural network models, each making the forecast for a specific date that is a certain number of days into the future. In other words, we trained one model for making the next-day forecast, one model for making the forecast for the day after that, and so on. The second approach is to train a single model for making the nextday forecast and then autoregressively use the next-day forecast as in input to make the forecast for the day after that. Evaluation on Nakhon Pathom 2018-2019 UV datasets showed that the performance of the autoregressive approach is quite stable with average MAPE of 13.70-15.79 for forecasting up to 28 days into the future (Table 3 and Fig. 5b). On the other hand, developing specific models for specific days performs well on the 2019 dataset but poorly on the 2018 dataset (MAPE of 11.46 vs 18.38 for forecasting up to 28 days into the future). We also additionally explored the possibility of training a model that can forecast UV profiles of multiple days at once, but the performances were much worse than the two methods described above (MAPE of 29.49 and 49.69 for forecasting the next 7 days at once on the 2018 and 2019 datasets, respectively). Hence, we decided to choose the autoregressive approach for SurfUVNet. It should be noted that the regression approach based on Earth-Sun distance and ozone information performed poorly on Nakhon Pathom's UV data even for next-day forecast (

Discussion
We have developed SurfUVNet, an artificial neural network model for predicting surface UV radiation that achieves around 10% error for next-day forecast and 13-16% error for 7-day up to 4-week forecast. This affirms that quantitative UV forecast is appropriate for heliotherapy applications, which tolerate up to 10-25% error level. SurfUVNet's performance is competitive on UV data from multiple regions, Thailand, Japan, and England, and on both antipsoriatic and downward irradiance. Hence, SurfUVNet can be adapted for forecasting other useful UV action spectra such as vitamin D production and erythemal UV index as well. In fact, our model can even be trained to forecast antipsoriatic irradiance from input erythemally-weighted UV data from a UV Biometer instrument with a small performance reduction (data now shown). This capability is necessary for establishing a national heliotherapy network in Thailand because there is only one full-spectrum UV sensor located in the central region of the country while the rest of the country is covered by a network of UV Biometers.
A key limitation of artificial neural network is that it tends to overfit to the training dataset and does not generalize well to other datasets that come from different distributions. In the context of UV forecasting, this dictates that the model must be retrained with data from particular weather station in order to be usable for that geographic region. Indeed, the accuracy of each model varies by 5-6% across the three geographical regions, Thailand, Japan, and England and even across 2018 and 2019 in the case of London dataset (Tables 1 and 2). For the case of London dataset, comparison of UV profiles between consecutive days in 2019 showed an extremely www.nature.com/scientificreports/ high average variation of 43.57%. The discrepancy in performance of the regression model based on Earth-Sun distance and total ozone column developed by the Thai Meteorological Department 22 between Nakhon Pathom and ERA5 datasets (25% error on Nakhon Pathom and 16-19% error on ERA5 41 datasets) could be attributed to the fact that ERA5 data, which contain more detailed ozone measurements (hourly compared to daily) and were computationally interpolated, are likely to be more easily fitted by regression. The fact that SurfUVNet's forecast error only weakly correlates with cloud coverage (Fig. 4) is unexpected but may be explained by the fact that cloud coverage in Nakhon Pathom exhibits clear seasonal pattern (Fig. 1b) and that the UV radiation profiles are stable over consecutive days (Table 1, MAPE of 13.94-14.58 for previous day model). On a geographical region with highly variable weather condition, such as London in 2019, artificial neural network models' performance drop significantly (Table 2) and the error of SurfUVNet exhibits higher correlation with cloud coverage (Fig. 4c). Hence, artificial neural network models seem to be able to exploit seasonal weather pattern and day-to-day variation to achieve good performance without relying on explicit cloud coverage information. This capability of the model to extract seasonal patterns may also explain why addition of ozone and AOD500 information did not improve the performance of SurfUVNet (Supplementary Figure 3), particularly as AOD500 level at Nakhon Pathom closely follows the same seasonal pattern as cloud coverage (Fig. 1d).
We explored two approaches for forecasting long-term UV radiation. Initially, we expected that developing a specific model for making the forecast for a specific date a certain number of days into the future would yield better performance than an autoregressive approach which use the next-day forecast as input for making the forecast for the day after because forecasting errors would accumulate through autoregressive steps. However, the models for specific date seem to overfit the training data, performing well on the 2019 dataset but poorly on the 2018 dataset (Table 3, 11.46% vs 18.28% error for forecasting up to 28 days into the future). In contrast, the autoregressive approach performs more consistently (13.70% and 15.79% error). An explanation for the overfitting of the model trained for specific date may be because the relationship between today's and next week's UV radiation profiles is so weak that the models learn mostly patterns that are specific to the training dataset. The poor performance of models for multi-day forecast (29.49-49.69% error for 7-day forecast) is likely due to the sheer number of outputs that the models must optimize. To make a 7-day forecast at 10-min resolution, the model has to output 595 values. From these results, we recommend the autoregressive approach for making long-term UV forecast with SurfUVNet. Table 3. Mean absolute percentage errors (MAPE) for long-term antipsoriatic irradiance forecasting for up to 28 days into the future on Nakhon Pathom dataset. www.nature.com/scientificreports/ To prospectively examine whether SurfUVNet's performance is sufficient for heliotherapy applications, we asked photodermatologist at King Chulalongkorn Memorial Hospital to plan a 3-month sunbathing course based on SurfUVNet's output and then compared their schedule with the ground truth antipsoriatic irradiances of the same time interval. This reveals that the error in antipsoriatic dose that the patient would receive by following the clinician's sunbathing protocol remains well within the acceptable 10-25% up to 0.3 cloud coverage (Fig. 4d, MAPE of 11.23). A possible solution for accounting for weather effects on UV radiation that we are exploring is to have each patient carry a portable UV sensor or a smartphone equipped with light sensor and use that data to adjust SurfUVNet's forecast in real-time.