A New Method to Classify Type IIP/IIL Supernovae Based on their Spectra

Type IIP and type IIL supernovae (SNe) are defined on their light curves, but the spectrum criteria in distinguishing these two type SNe remains unclear. We propose a new classification method. Firstly, we subtract the principal components of different wavelength bands in the spectra based on Functional Principal Components Analysis (FPCA) method. Then, we use Support Vector Machine (SVM) and Artificial Neural Network (ANN) to classify these two types of SNe. The best F1-Score of our classifier is 0.881, and we found that solely using Halpha line at 6150-6800 A for classification can reach a F1-Score up to 0.849. Our result indicates that the profile of the Halpha is the key to distinguish the two type SNe.


INTRODUCTION
Originated from massive stars(8 ∼ 20M ), Hydrogen Rich Core Collapse (CC) Supernovae(SNe) also known as type II SNe is one kind of SNe with conspicuous hydrogen spectral line at 6335Å (Gal-Yam 2017). Some type II SNe are generally divided into 4 subtypes: IIP, IIL, IIb and IIn. Moreover, some SNe with peculiar spectroscopic or light curve features are divided into type II-pec SNe, such as SN1987A (McCray 2017). Helium spectral lines at the wavelength 5876,6678,7065Å are observable in type IIb, while Type IIn spectra usually have a narrow H α line at 6563Å. As for Type IIP/IIL SNe, their definitions are based on the light curves.
The lumiosity evolution of SNe are generally dominated by 4 mechanisms (Arcavi 2017): shock breakout, shock cooling & ejecta recombination, radioactive decay and circumstllar material (CSM) interaction. Type IIP SNe are characteristic of its plateau-like lightcurves, which fast rises to the peak (∼ 15 days) after explosion and follows a plateau-phase (∼90 days) which is powered from the cooling of ejecta. After the 'plateau phase' the magnitude will linearly decline (>1.4 Mag/100 day) with the propulsion of the nikel decay 56 Ni → 56 Co → 56 Fe. In contrast, Type IIL SNe' cooling phase is much shorter than Type IIP (typically less than 10 days) and its luminosity linearly decrease (∼0.3Mag/15day)(Gal-Yam 2017) after reaching maximum. Notably, Type IIb SNe has the most various lightcurve and some of them even shows a double-peak light curves, the first of which is originated from the fast cooling effect after the explosion, while the second of which links to the high-energy photon escaping the relatively small-mass envelope (Arcavi 2017;Li et al. 2011;Richmond et al. 1994).
Many studies indicates the progenitor of Type IIP SNe is Red Super Giants (RSG) with mass range of 8.5-16.5M (Smartt 2015), while Type IIb SNe are generally originated from Yellow Super Giants (YSG) (Anderson et al. 2012). Moreover, some studies suggest Type IIn SNe' progenitors are Luminous Blue Variables because the interaction between the core and Circumstellar Materials (CSM) (Schlegel 1990). Nonetheless, the progenitor of Type IIL SNe is on debate and only one observational evidence on SN2009kr suggests RSG or YSG could be progenitor (Elias-Rosa et al. 2011;Fraser et al. 2010).
In the former studies on Type IIP/IIL SNe, the absorption-emission ratio of H α P-Cygni profile in Type IIL SNe is relatively smaller than Type IIP's, which is possibly because of Type IIP/IIL SNe's envelope mass and density gradient differences after the peak magnitude (Gutiérrez et al. 2014;Patat et al. 1994). Moreover, in a study on H α and O(I)7774 equivalent width(EW), the spectra of Type IIP SNe have a smaller ratio EW OI7774 /EW Hα (Faran et al. 2014a). Additionally, at the peak luminosity, Type IIL SNe' absolute magnitude is −17.44 ± 0.22 while Type IIP' is −15.66 ± 0.16 . However, unlike the classification in Type I SNe (Sun & Gal-Yam 2017), scant spectroscopic criteria are presented to determine Type IIP/IIL SNe.
Recently, with the advance of machine-learning algorithm and applications, new spectroscopic and photometric classification methods are introduced. Several studies have been conducted in photometric classification and instant detection of SNe and other transients via machine learning algorithms (du Buisson et al. 2015;Bloom et al. 2012;Richards et al. 2012). With Principal Component Analysis (PCA) and Functional Principal Analysis (FPCA) algorithm, the light curves of SNe are able to described into fewer parameters (Rubin & Gal-Yam 2016;He et al. 2018). Furthermore, combining PCA with other machine learning algorithms, i.e. Self Organizing Maps and K-means, the spectral features in different subtypes of Type Ia SNe has been studied (Sasdelli et al. 2016).
In this study, we applied Functional Principal Component Analysis (FPCA) on the different wave bands of Type IIP/IIL SNe' spectra, then use Support Vector Machine (SVM) and Artificial Neural Network (ANN) to classify the types of SNe from the principal components (FPCA scores). In § 2, we will introduce the data source and the algorithms (FPCA, SVM and ANN) used in the paper. In § 3, we will discuss the performance of our classifiers. The prospective and the summary will be presented in § 4. All the codes used in the analysis are uploaded onto https://github.com/GeronimoChen/IIL-IIP-SNe.
2. METHOD 2.1. Pre-processing the data All the spectra of Type II SNe (/IIP/IIL/IIb/IIn) are downloaded from WISeREP (Yaron & Gal-Yam 2012) for our analysis. Because there are only Type IIL in the database, we tried to find 6 more Type IIL SNe from other literatures to expand the dataset, which is shown in Table.2.1. As the unclassified Type IIL has been concluded, the dispersion of different types' SNe object and spectra are shown in Fig.1. The pre-processing of the spectra are discussed in the Section 5, which is constitute of removing redshifts, Savitz-Golay filter (Savitzky & Golay 1964), removing continuum spectra. Then, the as-prepared spectra are divided into 9 small wavelength windows and 2 long wavelength windows, as is shown in Fig.2. Refering to peer literatures (Singh et al. 2018;Smith et al. 2010;Taddia et al. 2016;Gutiérrez et al. 2018;Anderson et al. 2018;de Jaeger et al. 2018;Marcaide et al. 2002;Maguire et al. 2010), we have concluded the major spectral lines in SN identification into the Table 1. Because of the conspicuous hygrogen line in most Type II SNe, we carefully selected the H α and H β wave-windows to include all the absorption and emission parts for most spectra. Most the small wave-windows are denoted with the spectral lines in the spectra, except the wave-window 'Gap', which was excluded initially due to the H 2 O spectral line at 7165Å. However, some Type II SNe may embody calcium spectral line (Ca(II)7291,7323) in this reagion (de Jaeger et al. 2018;Maguire et al. 2010;Faran et al. 2014a), so this wavelength window is preserved. Furthermore, wavelength at 6800-7000 and 7400-7700Å are excluded from the small wavelength windows due to the  telluric spectral line (O 2 6867, 7620). Relating to a study in PCA analysis in Type Ia spectra (Sasdelli et al. 2016), we kept two long wave-windows here, which are the 'visible' wavelength at 4000-7000Å and 'expand' wavelength at 4000-9000Å. Because of the equipments limitation and redshift effect, some wave-windows are not fully sampled or even not sampled in a spectrum, which cause an extra data loss in the following training for the classifying algorithm. The number available spectra in each wave-windows are also counted in Table 1.

FPCA algorithm
We use Functional Principal Components Analysis (FPCA) for the first process of each wave-window in order to acquire a series principal scores of each spectrum. This algorithm was applied to SNe' light curve analysis before (He et al. 2018).
The FPCA algorithm aims to give a set of orthonormal functions, which could represent a series of trajectory via their linear combination (Hall et al. 2006;Jones & Rice 1992;Peng & Paul 2007). Considering n SNe spectra, X n (λ), which could be represented in the following equations:  Table 1.
Where β m is the m-th FPCS scores, φ m (λ) is the m-th basis functions and µ(λ) is the average spectrum of all selected spectra. Because the mean function has been subtracted into µ(λ), the average of each order FPCS scores for all spectra are zero. Every basis functions preserves orthonormal conditions, and the order of basis functions are sorted by the variance of FPCS socres: ∀m : V ar(β m,n=1,2...nmax ) > V ar(β m+1,n=1,2,...nmax ) As every basis functions are orthonormal, the m-th FPCS score of a single spectrum can be calculated via convolution in the selected wave-window λ min ∼ λ max : In order to preserve the most information of spectra X(λ), the FPCS scores of each order should as spacse as possible (the variance is as big as possible), and the selection of basis functions obeys the following equation.
In this literature, we adopt fpca package in R language (Peng & Paul 2007) for FPCA analysis, which use a gradient optimize method to acquire the best set of basis functions. With the order of basis function increases, the FPCS scores are converge to zero, which gives possible to set a highest order and perserves most informations in the raw spectra X n (λ).
We solved 30 basis functions for each small wave-windows Table 1. As for the large wave-windows, 50 basis functions are solved in 'Visible' wave-window and 40 basis functions are solved in 'Expand' wave-window. We select some basis functions and average functions shown in Fig.3. Also, we maneged to re-construct some spectra for the comparison with the original data, which is shown in Section 6

Support Vector Machine
From the as-discussed FPCA algorithm, all the spectra can be represented with a series of FPCA scores. Althoght some tendencies of different type SNe can be observed in some selected dimensions of FPCA scores' parametric space Section 7, we firstly choose Support Vector Machine (SVM) (Chen et al. 2005;Chang & Lin 2011;Cristianini & Ricci 2008) for the classification of Type IIL/IIP SNe.
SVM is a popular machine learning method for classification which aims to find the optimal hyperplane to seperate two sets of dots with largest margin distance, as is shown in Fig.4. This method is firstly proposed in 1992 (Boser et al. 1992) Consider two kinds of nodes in a hyperspace, the target of SVM is to find a hyperplane which could seperate the data, which is written in the form: Where X is the coordination on the hyperplane, ω is the weight of each dimension and b is the biase. The dots which are closest to the hyperplane are denoted as support vectors, the distance between the support vector and the hyperplane is: Where X i is the coordination of the nodes. The minimal is reached if the X i is the support vector. To construct an optimize hyperplane, the distances between the support vectors and the hyperplane should be as large as possible, the optimization target: If the distance between the support vector and the hyperplane is denoted to 1, then the optimization target is: Where y i = ±1 is the sign of the nodes, which marks their tags (IIP or IIL). Considering the intrinsically not seperable nodes, an slack variable is introduced to gauge the misclassification: The cost function for the optimization is written as below: In this paper, we use python.sklearn.svm for SVM classification, radial basis function (RBF) is used for non-linear classification, the kernel function and the distance are written as: If no further explanation are given, we set the default parameters C = 3020 and γ automatically generated by the machine, which promises the best performance of SVM algorithm in most classifications in this literature.

Artificial Neural Network
A simple Artificial Neural Network (ANN) is composed of three parts: input layer, hidden layers and the output layer (LeCun et al. 2015). Nodes in adjacent layers are linked with different weights. In the ANN, data are propogated from the imput layer to the output layer with the equation: Where ω i is the weight, b is the biase and f i+1 (z i ) is the activition function of nodes in each layer. The output layer will give the probablistic classification upon a certain input data. In this paper, we use recitfied linear unit (f (z) = max(0, z)) as the hidden layer's activition function, and sigmoid function (f (z) = 1/(1 + exp(−x))) as the output layer's activition function.
The weight and bias parameters are trained using backpropogation procedure. In this paper, we choose binary cross entropy (Shannon 2001) as the loss function, which is written as: Where y r is the true probablity 0 or 1, y p is the probablity given by the neural network. For each training epoch, the upload of weight and biase are uploaded upon the gradient of the loss function, g ω = ∂L ∂ω , g b = ∂L ∂b In this paper, we use Adam algorithm (Kingma & Ba 2014) for optimization, from which the weights and biase are updated with: Where θ is weight or biase, m t and v t are the t-th epoch first and second momentum, = 10 −8 is set to avoid overfull. We use the default decay parameters β 1 = 0.9, β 2 = 0.999 and the learning rate α = 0.001.
In this paper, we use the integrated deep learning package python.keras for ANN training and testing. Regulizations are not introduced considering they cannod increase the performance in this paper.

Performance evaluation
In each trainning and testing process, we randomly discard some Type IIP SNe at the outset, in order to keep a same number of Type IIP/IIL spectra in our dataset. Secondly, the dataset is splited into training set and testing set, which contains 80% and 20% of the data. When the classifier has trained on the training set, we use F1-Score to evaluate the performances of our classifiers. the definition of F1-Score is as follows (Olson & Delen 2008): Where true positive is the number of 'positive' spectra retrived by the classifier, true negative is the number of 'negative' spectra that didn't retrived by the classifier, false positive is the number of 'negative' wrongly retrived by the classivier and false negative is the number of 'positive' spectra didn't retrived by the classifier. We calculated the precision, recall and F1-Score of Type IIP and Type IIL seperately, then adopt the average of two types.
Because the number of Type IIL/IIP spectra are too small and biased, as is shown in Table 1, we adopt a cross validation method to evaluate our classifiers' performance. The training-and testing-process will repeat several times and the dataset are re-splitted before each training process. Finally, we calcuate the average precision, recall and F1-Score to evaluate the classifier. In addition, the standard error of precision, recall and F1-Score are also calculated in order to evaluate the stability of classifiers.

The Performance of Classifiers in One Wave-Window
We firstly test the performance of SVM using only one wave-window and calculate the F1-Score, the results are shown in Table 9. In this trial, only first 30 FPCA scores of the 'Visible' and 'Expand' are selected, to perform an unbiased test to compare the performance of smaller and larger wave-windows. We notice that both 'Visible' and 'Expand' wavw-windows have a relatively high F1-Score, which reaches to 0.815 and 0.83. In contrast, the 'NaMg' wave-window's F1-Score is the lowest among others. Moreover, we notice the F1-Score of 'H α ' window reaches 0.809, which is the third highest among 11.
Additionally, we utilized several ANN models for the classification using 30 FPCA scores in one wave-window, the results of which is shown in Table 6. A simple three-layered neural network is constructed in python.keras framework, the parameters are listed in Table 3.1. In the list of classification results Table 6, only the scores of best-performed model are shown in the table. The F1-Score of ANN is higher than SVM's in all wave-windows. Notably, the F1-Score of 'H α ' wave-window, which reaches 0.849, is the highest among other 8 small wave-windows.
Although large wave-windows are not excel at re-constructing every details of a spectrum Section 5, its performance is higher than small wave-windows, we suggest this phenomenon is caused by the normalization process in pro-processing the spectra. For the precision in solving FPCA basis functions, every wave-windows are normalized seperately. As a consequense, the flux ratio between each small wave-windows are omitted. Considering this part of information is directly linked to the element ratios in SNe, it is persumable to obtain a worse result when solely small wave-windows are utilized. In contrast, a comprehensive wave-window contains multiple spectral lines, and the information about the element ratios are preserved, which promises a better performance.  Figure 6. The F1-Score in SVM and ANN of every wave-windows. Error bars are plotted in the picture. The F1-Score of ANN are generally higher than SVM's. Data from Table 6, Table 9 With more basis functions, it is possible to re-construct the spectra with a higher fidelity, albeit more computational costs in solving basis functions. However, whether more FPCA scores will increase the accuracy in classification remains a question. In this section, we tried to change the number of basis functions in FPCA analysis, and discuss the minimal number of basis functions for the classification. Relating to the F1-Scores in Section 3.1, we choose the best small wave-window and the best large wave-window, 'H α ' and 'Visible' for the following discussion. The models of ANN are the same in Section 3.1 We plotted our results into Fig.7, the relating data are shown in Section 2.1. In 'H α ' wave-window, F1-Score reaches 0.839 when 10 basis functions are utilized, while the F1-Score in 'Visible' wave-window for 10 basis functions is 0.842. If the dimension is larger than 10, the F1-Scores of two wave-windows are more than 90% of the wave-windows' best F1-Score, while the outcome slopes when the dimension is smaller than 10. Moreover, we can observe fluctuations in 'Visible' bands, indicating the instability of the ANN model in the chosen wave-window, which is also confirmed by the relatively large variation (0.5 − 0.9) of F1-Score. Accordingly, we suggest 10 basis functions is adequete for the classification of Type IIP/IIL SNe.  Moreover, we availed the most data and attempt to test the stratosphere. We tested the classifiers' performance in using 9 small wave-windows or all 11 wave-windows, the total number of FPCA scores of which reaches 270 and 360. So, the imput dimension is 270 or 360. Using the default parameters in SVM C = 3020 still performs well. However, Note-In this scenario, the parameter for SVM C=3020.
we found that using neural-network with 90 or 30 nodes in the hidden layer performs the best. The results are listed below.
Comparing to the SVM in one wave-window Table 9, the results in using multiple wave-windows did not increase whatsoever, probably because the higher dimension of features infects SVM's performance (Chou & Ko 2017;Nakayama et al. 2017). In using ANN for classification, we found the F1-Score reaches 0.881, which is the best among other classification methods in this paper.

SUMMARY
We decomposed Type II SNe spectra into different basis functions via FPCA algorithm. Based on the FPCA scores of every spectra, we have trained SVM and ANN to classify Type IIP and IIL SNe, two types of which has scant spectroscopic discrepancies. The spectra are divided into 9 small-size wave-windows and 2 large-size wave-windows for FPCA analysis respectively. The best F1-Score we got is 0.881. It is, for the first time, the effectively spectroscopic classification of Type IIP/IIL SNe.
Using the FPCA algorithm in different wave-windows, we successfully compressed the data of some certain spectral lines into 30-50 FPCA scores with minimal data loss. This processing trick do not only preserves the most informations about the elements explosion speed, but also enables us to apply some simple machine-learning models for classifications.
Moreover, we notice that only using a small-scale wave window at 6150-6800Å, which covers the P Cygni profile of H α line, outperforms to other spectral features in classification with its F1-Score up to 0.849, probable because of the higher signal-to-noise ratio. We suggest FPCA analysis directly on spectral line of a specific element could be a new approach in SNe classification analysis.
In the future, we will investigate the relationship between the basis functions (the principal components in spectra) and the explosion profile of SNe to expand the classification method on Type I SNe. Moreover, we will integrate other informations, such as temperature and the color evolution of SNe into the model for a higher accuracy.

METHODS
The raw spectrum from telescopes will firstly remove the redshift by using the equation λ RF = λ obs /(1 + z), where λ RF is the wavelength in the rest-frame, λ obs the wavelength in the observer frame. Then, a Savitzky-Golay filter is applied to smooth the spectra, which is shown in Fig.8. Considering the black body radiation in the spectra, we adopt an univariate spline method python.scipy.UnivariateSpline for continuum removal, instead of fitting the blackbody radiation spectra, because the iron-blanketing effect may cause extra continuum absorption at the wavelength small than 5000Å (Faran et al. 2018). Furthermore, every spectra' fluxes are re-normalized to average equal zero and variance equal 1. After this step, we have obtained the spectra preserves most informations of their element compositions.
In the whole pre-processing process, we omitted the color and the temperature information in the spectra, but most informations about the element composition (the position and the depth of spectral lines) and the explosion speed (the P-Cygni profile and the psudo-Equivalent-Width of spectral line) are preserved. Although the classification results are desirable, we will attempt to integrate these information into the model in the future researches.  Figure 8. An example spectrum before and after the Savitzky-Golay filter. The window and the order of Savitzky-Golay filter in this plot is 2 × int(10/∆λ) + 1 and 1, ∆λ is the average wave interval of each spectra. ID45232 is the sppectra number in WISeREP.

FPCA FIDELITY DISCUSSION
Considering our computer compatibility, we didn't use all the spectra we downloaded for FPCA analysis. Instead, we randomly choose 15% of them to solve the basis functions. According to some comprehensive research on the Type II SNe (Faran et al. 2014b,a) which suggesting the potential continuum between the subtypes of Type II SNe, II/IIb/IIn are also used in FPCA analysis. With these basis functions, the FPCA score of the rest spectra can be calculated from Eq.4. The basis functions of each time may varies, however, we didn't observe basis functions from different spectra affecting the performance of classifiers or the fidelity when re-constructing the spectra. We also choose only Type IIP and Type IIL spectra for FPCA analysis, the average function and first two basis functions in 'H α ' window is shown in Fig.6. Comparing to Fig.3, the sharp feature in the first basis function at around 6700Åis absent, which is probably contributed to the relatively narrow H α line in Type IIn SNe' spectra. Nonetheless, with an unknown reason, using these sets of basis functions didn't increase the performance in classifing Type IIP/IIL SNe.
We choose the last (40th) basis function in 'Expand' wave-window. Also, this basis function contains the most (24) peak among other 'Expand' basis functions. The average distance between two peaks in the basis function is approximately 208Å, so we suggest that the spectral resolution of 'Expand' wavewindow is 208Å. In contrast, the distance between the two peaks is approximately 200Å, which is similar to the wave resolution of 'Expand' wavewindow. If the relating spectra contains some extreamely sharp features like circumstellar material and the spectra of host galaxy, more basis functions are required to render the spectra. Alternatively, using multiple smaller wavewindows can avoid this problem. In the last (30th) basis function in 'S' wave-window, there are 15 peaks and the resolution is 37Å, which indicates a better fitting result Fig.11.     Figure 11. Left: the fitting of SN2017few in 'S' wave-window. In this scenario, the fitting fidelity is higher than 'Expand' wave-window. To notice, because of the computational capacity, the spectra for FPCA in 'Expand' window are down-sampled, which results in the data loss of the peak at 5350. Furthermore, the y-axis scale here differs from Fig.10 because the flux of different wave-windows are re-normalized seperately. Right: the 30th basis function in 'S' wave-window.

DISCUSSION ABOUT THE RELATION OF FPCA SCORES
We plot some figure to illustrate the relation between two FPCA scores of different types of SNe. More plots are uploaded to the website. In Fig.12, we notice Type IIb SNe are close to the lower-left side of the plot, while Type IIn SNe are clustered in the middle-upper side of the plot. For the other types of SNe, it is quite hard to distinguish them. A similar plot concentrated on Type IIP/IIL SNe is shown in Fig.13, the dispersion of Type IIP and IIL SNe are not wholly overlapped, however, it is hard to simply seperate them with a curve. Plots using other FPCA scores stumbled upon same problem. We also discussed the evolution of spectra in the FPCA scores' parametric space, Fig.6 is a paradigm. No conspicuoous tendencies are observable in the plot. Because not all the SNe are intensively observed, most SNe are not well-observed in their whole lifetime, so we didn't take the phase of SNe' spectra into consideration.

THE PERFORMANCE IN HIGH REDSHIFT SPECTRA
In this paper, no attempt for K-correction (Hogg et al. 2002) is done because most Type IIP/IIL objects' redshift are relatively low. However, we analyzed the performance of our classifiers on all 27 objects with redshifts higher than 0.04 (Pierel et al. 2018), all of them are Type IIP SNe. We use the cross validation method as is discussed in Section 2.5, then count how many times the spectra is divided in the test set and how many times the spectra are misclassified. Considering the wavelength ranges of these spectra, we only choose 'H α ' wave window for trial. e To sum up, the precision of high-redshift spectra in SVM is 0.610, the precision of high-redshift spectra in ANN is 0.627. The classifiers we have trained are not biased, the precision of Type IIP and Type IIL SNe are equal. Comparing to the overall precision of SVM (0.751) and ANN (0.851), we surmise the classifiers' performance are influenced by the redshift.