{'fraction_non_alphanumeric': 0.03763263381278, 'fraction_numerical': 0.029096911105871256, 'mean_word_length': 4.254212091179386, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 2, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 9, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
On the Use of Logistic Regression for stellar classification. An application to colour-colour diagrams

We are totally immersed in the Big Data era and reliable algorithms and methods for data classification are instrumental for astronomical research. Random Forest and Support Vector Machines algorithms have become popular over the last few years and they are widely used for different stellar classification problems. In this article, we explore an alternative supervised classification method scarcely exploited in astronomy, Logistic Regression, that has been applied successfully in other scientific areas, particularly biostatistics. We have applied this method in order to derive membership probabilities for potential T Tauri star candidates from ultraviolet-infrared colour-colour diagrams.

has been applied by Kurcz et al (2016) to the WISE catalogue to obtain star, galaxy and quasar catalogues, and it is also the main algorithm used to classify all the Gaia sources (Bellas-Velidis et al (2012)). There exist other algorithms based on bayesian methods such as those proposed by Picaud et al (2005) or Bailer-Jones (2011) that allow to improve the accuracy of the classification. All these methods are designed to cope with huge amounts of sources and are suited for data with multidimensional nature. However, in some cases the simplicity of the problem or a reduced sample are not worth the effort.
The logistic function was introduced by Verhulst (Verhulst (1845(Verhulst ( , 1847) in the 19 th century to describe population growth in biological experiments and was early applied on chemical processes (Reed and Berkson (1929)); a later formulation was given by Cox (1958). Currently, Logistic Regression is one of the most used techniques in Biostatistics (see Hosmer et al (2013)). Logistic Regression is a multivariate analysis model that predicts the probability of membership to any class based on the values of some predictor variables; these variables are not constrained to follow a given (normal) distribution, not even be continuous. Although this method is not widely used in astrophysics, it has been recently applied by Huppenkothen et al (2017) in order to study the variablility of the galactic black hole binary GRS 1915+105. Moreover, a variation of the method (Boosted Logistic Regression) has been compared with Random Forest by Saz Parkinson et al (2016) to classify gammaray sources into two groups and they have shown that similar accuracy is achieved with both methods.
The Galaxy Evolution Explorer (GALEX) mission (Martin et al (2005)) has surveyed the sky in two ultraviolet bands, the far ultraviolet (FUV) band (1344Å-1786Å) and the near ultraviolet (NUV) band (1771Å-2831Å). Already decommissioned, during its life time GALEX detected about 200,000 million sources (Bianchi et al (2014)) that together with the 2MASS survey (Skrutskie et al (2006)) provide an incredible wealth of information to study star formation and the interstellar medium in the Galaxy. Some applications to the Taurus and Orion star forming regions can be found in Gómez de Castro et al (2015a,b); Sánchez et al (2014); Beitia-Antero and Gómez de Castro (2017).
In Gómez de Castro et al (2015a) (hereafter GdC2015) several colour-colour diagrams were used to identify T Tauri Stars (TTSs) from the background stellar population. Although the classification method was purely empirical, some areas were identified where reliable candidates should be located but it neither assigned an uncertainty nor a probability of membership to a given class of the candidates. This is a serious drawback to elaborate sensible lists of candidates for subsequent observation. Logistic Regression algorithms model robustly the probability of membership, providing a measure of the classification errors.
In this work, we apply Logistic Regression to the empirical classification done in GdC2015 and show how membership probabilities can be calculated. In Section 2, the method is described and in Section 3 is applied to the sample in GdC2015. In Section 4 results of the application of the algorithm to a sample of Main Sequence stars are shown and the computational details are included in the Appendix. A short summary of the results is provided in Sec. 5.

Logistic Regression
Logistic Regression is a machine learning model used to solve supervised classification problems: given a sample of objects characterised by the values of some predictor or independent variables, and knowing the class (dependent variable) of each one, the variables are used to classify the objects in the given groups. The solution of the Logistic Regression model will be a function that, given a new set of values of dependent variables, will compute the probability of belonging to any of the pre-defined classes.
Mathematically, (see for instance Hastie et al (2013) or Pradhan and Lee (2010)), the probability of occurrence of some event, in our case the probability that an object belongs to a particular class or category, is modelled as: where z is a linear combination of some predictor variables: The probability p varies from 0 to 1 on an S-shaped curve, β 0 is the intercept of the model and β i (i = 1, 2, . . . , n) are the coefficients of the Logistic Regression model. An appropriate selection of the predictor variables x 1 , x 2 , . . . , x n is crucial for an accurate modelling and any combination of the original variables is allowed by the method: x j = x 2 1 ; x k = x 1 x 2 ; .... Hence, the classification problem can be expressed as, Given a set of classes {1, 2, . . . , K}, and given an astronomical object o ∈ O characterised by a a set of variables , the probability that the object belongs to any of these classes?
In this type of problems, the Classification Table or Confusion Matrix is commonly used. This is a square matrix C with dimension K, the number of classes, and such that any element c i, j indicates the number of objects of class i that are classified by the model into class j, for all i, j ∈ {1, 2, . . . , K} (see Table 1).

Classification of T Tauri stars
Our scope is to use the Logistic Regression model to assign a given star with known FUV, NUV, J and K magnitudes a probability of being either a classical or weakline TTS. GdC2015 obtained a qualification sample of 47 TTSs detected in the Taurus molecular cloud that had been observed either by the International Ultraviolet Explorer (Gómez de Castro and Franqueira (1997)) or by GALEX and that have a 2MASS counterpart; that sample consists on 16 weak line TTSs (WTTSs) and 31 Classical TTSs (CTTSs). As pointed out by GdC2015, though WTTs are close to the main sequence and it is difficult to identify them directly from the diagram, a regression line was found; this was not the case of the CTTSs, that were sparsely distributed over an area far from the main sequence. In addition, both groups seem to be mixed. For this reason, the crucial issue in this work is to define properly the location of the Main Sequence in the FUV-NUV versus J-K colour-colour diagram.

Model 1: Main Sequence defined by the Field Stars in the area
In a first attempt, we used a sample of 7348 stars observed by GALEX in Taurus, with both FUV and NUV magnitudes, that also had a 2MASS counterpart (see GdC2015 for details); this plain sample will be referred to as Field Stars (FS) and is shown in Fig. 1 (red dots). Note that the separation between the WTTs and FS is rather fuzzy due to variations on the extinction values of some FS, and will complicate the differentiation of both classes. Besides, the size of the FS sample is enormous compared to the CTTs and WTTs ones and will bias the results. The problem will consist on discerning the probability that any of the FS is a CTTS or WTTS (or neither of them, and so they will remain as FS). Following the Logistic Regression formulation (Sec. 2), we will determine the membership probability to any of the three classes: CTTS (k = 1), WTTS (k = 2) and FS (k = 3), where higher probability of belonging to the FS class means that the object is not likely to be a TT. The variables considered are 2 and x 5 = x 1 x 2 ; variables x 3 , x 4 and x 5 are introduced due to the nonlinear nature of the sample (Fig. 1). The family of parameters to be estimated is:  where k = 1 corresponds to the first class, CTTs, and k = 2 corresponds to the second class, WTTs. A computational application was programmed in MATLAB (Math-Works (2014)) to estimate the parameters as well as to obtain the associated graphics.
The results are given in Table 2. In Fig. 2, the most likely class for each point of the (J-K)-(FUV-NUV) plane has been determined from the Logistic Regression results (coloured mesh grid corresponds to the colour code of the sample: blue for WTTs, green for CTTs and red for FS). As occurs with every automated classification procedure, we find misclassified objects among our sample (mainly the WTTs population, that has been ignored) that should be minimum if the algorithm behaves properly. The contours delimit the areas inside which the membership probability is higer to 0.5 (solid line), 0.8 (dashed line) and 0.9 (dotted line). Note that given the definition of the probabilities (Eqs. 3 and 4) and the fact that we are establishing three groups, the areas of, e.g. P ≥ 0.5, may Fig. 2 Results of the Logistic Regression fit of the FS and TTs sample from GdC2015. Each point of the plane has been assigned the most probable class with a color code: vertical red lines for FS and green points for CTTs. Also three probability lines have been plotted in order to separate the 0.5, 0.8 and 0.9 probability regions for FS (red) and CTTs (green). The algorithm has ignored the WTTs class. not be closed areas but rather open ones, as happens with the FS sample. As mentioned above, virtually no point has been assigned to WTTs class. This is positively due to a lack of balance in the sample as the most numerous population corresponds to FS whereas the WTTs sample is the least populated. Moreover, FS are submitted to different extinctions resulting in a broadening of the MS branch and as WTTSs lie pretty near of the FS population, the algorithm is obviously confusing both classes. The discouraging results of the confusion matrix (see Table 3) support this fact. Hence, it is necessary to compensate the sample in order to achieve better results. 3.2 Model 2: Main sequence from a balanced sample of field stars.
As we will show below, the best solution is achieved by reducing the statistical weight of field stars. From a statistical point of view, it is sensible to have equal probability of belonging to any of the three classes (CTTS, WTTS or other, FS), supposing the sample is a simple random one. Given the fact that the FS population is much numerous than the TTs population, the algorithm could ignore the WTTs without a significant penalty on the results, as we have shown in the first approach. A possible solution for this problem is to balance the CTTs and WTTs sample sizes by integer factors λ 1 and λ 2 , respectively, in order to obtain more flexible probability distributions that fit better to the spatial distribution of the sources. An upper limit for these parameters is established by the size of the FS sample (7348), i.e., λ 1 = 7348/31 ∼ 237 and λ 2 = 7348/16 ∼ 459. If we perform again the Logistic Regression using these upper limits (see Table 4 for the slope coefficients), the results are highly improved as clear from Fig. 3, in the sense that the WTTs class has not been ignored and most of the sources lie inside their P > 0.5 probability area. Formally, this improvement can be tracked through the Rate matrix, R. R is a K × K matrix with elements r i, j defined as the fraction of the total sources belonging to class i that have been classified as class j, where i, j ∈ {1, 2, . . ., K} (K = 3 in this case). This matrix is similar to the confusion matrix in that the classification improves as the elements outside the main diagonal decrease toward 0. The rate matrix for model 1 (see Sec. 3.1) is, 0.61 0.00 0.39 R = 0.12 0.00 0.88 0.00 0.00 1.00 that shows clearly that the FS class is overestimated. However, for the scaled model considering λ 1 = 237, λ 2 = 459, the rate matrix is: 0.74 0.26 0.00 R = 0.12 0.88 0.00 0.01 0.02 0.97 The case R = I, the identity matrix, will correspond to the perfect classification, where the predicted class of every source will be the real one. The difference between matrices R and I can be considered a quality measure of the classification algorithm. The final step is to determine λ 1 and λ 2 values in order to improve as much as possible this rate matrix R. These integer values should be in the ranges λ 1 ∈ {1, · · · , 237} and Fig. 3 Results of the Logistic Regression fit with a sample balanced using the upper limits for the scaling coefficients, λ 1 = 237,λ 2 = 459. Some points of the plane has been assigned to the WTTs class (blue horizontal lines). Also three probability lines have been plotted in order to separate the 0.5, 0.8 and 0.9 probability regions. λ 2 ∈ {1, · · · , 459}. After several experiments, we have found that the best values in the sense of the matrix R − I are λ 1 = 69, λ 2 = 86, providing the confusion matrix showed in table 5 and rate matrix, 0.94 0.06 0.00 R = 0.19 0.81 0.00 0.01 0.01 0.98  The results are shown in Fig 4. This time there are some regions of the plane where the membership probability to WTTs class is non-zero and greater than 0.5 and the majority of the WTTs population lies; the slope coefficients are listed in Table 6. With these parameters, we have assigned a membership probability to all TTSs candidates 1 ; they are listed in Table 7 and represented in Fig. 4 as black crosses. It is clear from the plot that there are many FS lying inside the P > 0.8 areas of WTTs and CTTs that were not selected as likely candidates to TTs by GdC 2015. We want to highligh that statistical methods are useful to derive probability distributions but as intrinsic variations inside the sample are not considered, plenty of objects might be misclassified. GdC2015 performed a careful examination of the FS sample and even analysed the spectral energy distribution curves of some of the sources in order to elaborate a reduced but clean sample of TTs candidates. Thus, the combination of both methodologies is instrumental to achieve reliable results.

On the possibility of Main Sequence definition from spectroscopic data
An additional approach, which is worth exploring, is to define the main sequence (MS) from spectroscopic observations as has been done for the TTSs. Our qualification sample has been extracted from the high quality photometric catalogue derived by Beitia-Antero and Gómez de Castro (2016) (hereafter BAGdC) using IUE spectra. We selected sources from BAGdC's catalogue with both FUV and NUV synthetic 1 As a reminder, GdC2015 labeled the potential TTS as Candidate WTTS, Candidate CTTS or just Candidate if it was not clear to which class the star might belong to. Logistic Regression allows us to assign a membership probability to those objects. in GdC2015's Taurus survey to select in the future the best ones for follow up observations and subsequent characterisation Fig. 4 Results of the Logistic Regression fit with a sample balanced using the selected values of the scaling coefficients, λ 1 = 69,λ 2 = 86. The plane seems to be well organised in three different regions assigned to each of the three classes, FS, WTTs and CTTs. Some probability lines have been plotted in order to separate the 0.5, 0.8 and 0.9 probability regions. Black crosses correspond to the TTs candidates selected by GdC2015. magnitudes and cross-correlated the results with the 2MASS catalogue (Skrutskie et al (2006)) in a search radius of 3 ′′ to obtain J and K magnitudes; the spectral types were retrieved from the SIMBAD database (Wenger et al (2000)). Unfortunately, only B and A spectral types had a representative number of sources (we found less than five stars with O, F, G or K spectral type); also sdO and sdB populations were numerous enough. Details of the final sample are listed in Table 8. Due to the poverty of the sample we have not been able to characterise the MS population as precisely as needed in order to distinguish it from the young stellar objects. The details of the calculation can be found in the Appendix (Sec. 6).

Conclusions
In this article we have shown that Logistic Regresion, a mathematical tool seldom used in astronomy, can be implemented in classification problems. The algorithm has been applied to assign a probability of being a T Tauri star from FUV-NUV versus J-K colour-colour diagrams. This methodology, combined with a careful qualitative analysis of the diagrams (as in GdC2015), provides potential candidates to for further scrutiny. Both observational and statistical analysis should be carried out together since the method has proven to be very dependent on the shape and size of the sample. In this manner, once a sample of candidates has been selected according its properties from colour-colour-diagrams, Logistic Regression can be applied in order to obtain a membership probability distribution.

Appendix
Provided the poverty of the initial sample of MS stars (see Sec. 4), we decided to combine the four clases into two big groups: MS stars (B and A classes) and sub-dwarfs (sdO and sdB); the spatial distribution of the sources in the x 1 =J-K vs x 2 =FUV-NUV plane is shown in Fig. 5. In a natural way, the stars are confined in a subregion of the whole plane R 2 , so it is coherent to define a smaller area or feasible region that is expected to contain the vast majority of the sources and that facilitates the obtention of more accurate results; in this case, it has been defined as −0.6 ≤ J − K ≤ 0.7 and −0.8 ≤ FUV − NUV ≤ 1.8. This subspace has been further divided by adjusting the sequence of A and B stars following a third degree equation that passes through four simulated points (see Fig. 5): x 2 = 0.97 + 11.42 · x 1 + 42.81 · x 2 1 + 57.08 · x 3 1 . Once all these assumptions were made, we dropped from the sample the two points that were out of the feasible region as well as other MS stars that showed abnormally infrared excesses.

Logistic Regression -Application to two classes
In this case, the classification problem consists on distinguishing between two classes (K = 2): AB (k = 1) and sd (k = 2) . Therefore, given one of these objects O the problem reduces to determine the probability of belonging to the first class, AB: and so, the probability of membership to the sd class is: The independent variables of the regression model are in a natural way x 1 = J − K and x 2 = FUV − NUV . It is clear in Fig. 5 that the classification cannot be linear and so, after some computational experience, the variables have been extended to x 3 = x 2 1 , x 4 = x 2 2 and x 5 = x 1 x 2 to perform a quadratic Logistic Regression. Thus, the linear combination of the predictor variables is given by f (x) = β 1,0 + β 1,1 x 1 + β 1,2 x 2 + β 3 x 3 + β 1,4 x 4 + β 1,5 x 5 = (8) β 1,0 + β 1,1 x 1 + β 1,2 x 2 + β 1,3 x 2 1 + β 1,4 x 2 2 + β 1,5 x 1 x 2 The parameters are listed in Table 9. Using these results, we have plotted as a guidance the probability lines for p 1 = 0.5, p 1 = 0.9 and p 1 = 0.1 over the original data (Fig. 6). The two populations are fairly separated and more than half of the AB points lie inside the 0.9 probability region. The object classification in this framework is made in a simple and natural way: where the probabilities are given by Eqs. 6, 7. The ideal situation would be that where both probabilities are the same, that is to say, p 1 = 0.5; the confusion matrix is shown in Table 10. Nevertheless, the variable nature of the data suggests that a better classification may be achieved, in the sense that the confusion matrix could be improved to get a minimum number of misclassified objects. We have tested several values for the p 1 parameter, among which are p 1 = 0.487, p 1 = 0.474 and p 1 = 0.462 (see their confusion matrices in Table 11) and found that an acceptable result is achieved with p 1 = 0.474. Graphically (see Fig. 7), the vast majority of the data are well classified except for three B stars, PG 1210+429, BD-13 4920 and CSI+81-09137, that lie among the sd population and one sdO star, PG 2219+094, located among the AB population. The quality of this classification is also supported by the excellent results obtained for the area under the Receiver Operating Characteristic (ROC) curve (see Fig. 8), AUC, for the positive condition for MS and sd classes; in both cases AUC = 0.9645. ROC curve represents the probability of detecting the true condition versus the probability of detecting the false condition , and thus it is restricted to the plane [0, 1] × [0, 1]. AUC has become a standard for evaluating classification procedures; the greater the values under the curve, the better the classification. To sum up, an object of the MS population is classified as part of the AB class if p 1 ≥ 0.474, and of the sd class in another case, with a 4.6% probability of misclassification.