Cosmic Evolution Early Release Science Survey (CEERS): Multi-classing Galactic Dwarf Stars in the deep JWST/NIRCam

Low mass (sub)stellar objects represent the low end of the initial mass function, the transition to free-floating planets and a prominent interloper population in the search for high-redshift galaxies. Without proper motions or spectroscopy, can one identify these objects photometrically? JWST/NIRCam has several advantages over HST/WFC3 NIR: more filters, a greater wavelength range, and greater spatial resolution. Here, we present a catalogue of (sub)stellar dwarfs identified in the Cosmic Evolution Early Release Science Survey (CEERS). We identify 518 stellar objects down to $m_F200W \sim 28$ using half-light radius, a full three magnitudes deeper than typical HST/WFC3 images. A kNN nearest neighbour algorithm identifies and types these sources, using four HST/WFC3 and four NIRCam filters, trained on SpeX spectra of nearby brown dwarfs. The kNN with four neighbors classifies well within two subtypes: e.g M2$\pm$2 or T4$\pm$2, achieving $\sim$95% precision and recall. More granular typing results in worse metrics. In CEERS, we find 9 M8$\pm$2, 2 L6$\pm$2, 1 T4$\pm$2, and 15 T8$\pm$2. We compare the observed long wavelength NIRCam colours -- not used in the kNN -- to those expected for brown dwarf atmospheric models. The NIRCam F356W-F444W and F410M-F444W colours are redder by a magnitude for the type assigned by the kNN, hinting at a wider variety of atmospheres for these objects. We find a 300-350pc scale-height for M6$\pm$2 dwarfs plus a second structural component and a 150-200pc scale-height for T6$\pm$2 type dwarfs, consistent with literature values.


INTRODUCTION
With the successful start of operations of the NASA/ESA/CSA's James Webb Space Telescope (JWST) a new window has opened up on the lowest mass stars of our Milky Way.These near-infrared stellar objects are interlopers in the new, deep extra-galactic observations, but low-mass (sub)stellar members of the Milky Way also encode information on the shape and history of our Galaxy.Here, we report the numbers of such low-mass (sub)stellar objects found in the Cosmic Evolution Early Release Science Survey (CEERS, Finkelstein et al. 2022a) collaborations first NIRCam observations (Bagley et al. 2022).
Counting stars to infer the morphology and scales of the Milky Way is a classic experiment in Astronomy.This was the original motivation behind mapping the night sky, begun initially with photographic plates, moving to wide-field CCDs, and now space-based imaging with missions such as the Hubble and Webb Space Telescopes.
However, counting stars is also an approach that can easily fall into conceptual problems and incomplete information (e.g., Herschel 1785; Kapteyn 1922).The disk of the Milky Way was eventually measured and mapped using Giant stars with ever increasing precision (Gilmore & Reid 1983;Gilmore 1984;Siegel et al. 2002).The statistics are now such that individual stellar kinematic populations can be tracked (e.g.Hsu et al. 2021) and a link between the scales of the disk and metallicity is evident (e.g.Bovy et al. 2012).
Near-infrared mapping of the sky has revealed dwarf galaxy populations in the local solar neighbourhood (Reid et al. 2001;Cruz et al. 2004).Thanks to the WISE satellite (Wright et al. 2010), a near-complete census of the nearest 20 parsecs around our Sun, the numbers of these brown dwarfs are now known, adding a spectral class in the process (Reid et al. 2008;Kirkpatrick et al. 2021).
These lower-mass stars have gained attention as a nuisance population in the search with the Hubble Space Telescope and now James Webb Space Telescope for high-redshift ( >> 6) galaxies as both populations overlap in color space (Caballero et al. 2008;Wilkins et al. 2014;Finkelstein 2015).This provides a completely independent scientific motivation to characterize the number of ultracool dwarfs in the Milky Way.
Deep Hubble observations have constrained the size of the Milky Way disk thanks to the unambiguous identifications of stars as point sources as even high redshift galaxies are resolved and enough colours or grism spectra exist for type identification.Brown dwarfs have been identified in the Hubble Deep Field (Pirzkal et al. 2005), GOODS/CANDELS fields (Stanway et al. 2008;Pirzkal et al. 2009) and individual parallel fields (Ryan et al. 2005(Ryan et al. , 2011;;Holwerda et al. 2014b;van Vledder et al. 2016).But with low statistics and only a few lines of sight out of our Milky Way, these studies remain uncertain on the scale-height, especially as a function of brown dwarf (sub)type.Ryan et al. (2017) introduces a new concept to model the scaleheight for different sub-types of brown dwarfs: it implies that as brown dwarf's atmospheres cool (i.e.these objects age and thus become a later type), their population scatters and kinematically heats up, resulting in a greater Galactic scale-height.Depending on the star-formation history of the Milky Way, this cooling/aging effect with kinematic heating of the population as a whole, should be clear in the brown dwarf type-scale-height relation.Ryan et al. (2022) refined the above model and included the kinematic tracers showing direct evidence for the vertical mixing of this populationAganze et al. (2022a,b).Additional prior constraints can come from the local IMF (Kirkpatrick et al. 2021), local 3D T-dwarf kinematics (Hsu et al. 2021), and the previous determined scale-heights (Aganze et al. 2022a,b) from the WFC3 Infrared Spectroscopic Parallel Survey WISPS grism observations.These Hubble Space Telescope searches for brown dwarfs are limited to   = 24AB for pure-parallel photometry and grism observations.The challenge is therefore to type M/L/T/Y dwarf objects sufficiently accurately to map their distances photometrically.The broad filters typically employed on JWST/NIRCam deep observations such as CEERS (Finkelstein et al. 2022a) and PEARLS (Windhorst et al. 2023) programs may hold enough information to do so (Holwerda et al. 2018).The CEERS NIRCam observations were in a large part designed to identify sources for follow-up with the other JWST instruments to characterize their nature (see Bisigello et al. 2023;Carnall et al. 2023;Coogan et al. 2023;Costantin et al. 2023;Arrabal Haro et al. 2023b,a;Gómez-Guĳarro et al. 2023;Long et al. 2023;Magnelli et al. 2023;Shen et al. 2023a;Vega-Ferrero et al. 2023;Kocevski et al. 2023a;Larson et al. 2023).Our aim here is to evaluate how suitable such JWST/NIRCam observations are for Galactic science, specifically low-mass (sub)stellar objects.
Here, we explore the use of the colour space of the early CEERS NIRCam observations to identify (sub)stellar objects in these fields.We classify them using the templates of nearby examples using knearest neighbours.And finally we constrain the scale-height of the Milky Way using the identified (sub)stellar populations in the CEERS field, and compare these with existing estimates.

CEERS
The Cosmic Evolution Early Release Science Survey (CEERS, PI: S. Finkelstein; Finkelstein et al. 2017) is a JWST early release science (ERS) project to explore the early Universe and the early evolution of galaxies using a variety of instrument modes, shortly after telescope commissioning (Rigby et al. 2023b,a).
CEERS has covered ∼90 sq.arcmin of the EGS field with JWST (Menzel et al. 2023;McElwain et al. 2023;Gardner et al. 2023) imaging (and a portion with spectroscopy) using NIRCam (Rieke et al. 2023) described in Bagley et al. (2023), MIRI (Wright et al. 2023) described in Yang et al. (in preparation), and NIRSpec (Jakobsen et al. 2022;Böker et al. 2023) described in Arrabal Haro et al. (in preparation).CEERS demonstrates, tests, and validates efficient extragalactic surveys with coordinated, overlapping parallel observations in a field supported by a rich set of HST/CANDELS multiwavelength imaging (Grogin et al. 2011;Koekemoer et al. 2011).The CEERS NIRCam data were obtained in two epochs, in June and December 2022.
The CEERS science goals include the identification of highredshift galaxies through NIRCam colours (Akins et al. 2023;Finkelstein et al. 2022b), confirming candidate high-redshift sources with NIRSpec or ground-based follow-up (e.g.Fujimoto et al. 2022Fujimoto et al. , 2023)), and probe the physical conditions in these early galaxies using emission line diagnostics and mid-infrared emission (Arrabal Haro et al. 2023b,a;Jung et al. 2022Jung et al. , 2023;;Tang et al. 2023;Zavala et al. 2023).The NIRCam filters are sensitive to rest-frame optical emission and thus ideal to probe the evolution of structure starting at a much earlier epoch than ever before (Guo et al. 2023;Long et al. 2023;Huertas-Company et al. 2023;Magnelli et al. 2023;Shen et al. 2023b;Vega-Ferrero et al. 2023).These two science topics, the identification for follow-up of high-redshift targets and the structure of earlier epoch galaxies were the main drivers of the observational design.The early science methodology and results are presented in a series of Key Papers (Finkelstein et al. 2023;Kocevski et al. 2023b;Kartaltepe et al. 2023;Papovich et al. 2023;Pérez-González et al. 2023;Yang et al. 2023).Key for these science aims is the NIRCam imaging for discovery and characterization of sources in this field.However, these CEERS JWST/NIRCam observations have been de- signed from the start to explore and characterize extragalactic topics and no special consideration was given for Galactic science.

DATA
The JWST/NIRCam images used are the pixel-aligned mosaics described in Bagley et al. (2023), v0.6 on the CEERS website.Empirical PSFs were created by stacking stars for the entire mosaic in the case of HST and NIRCam.
We make use of the internal CEERS photometry catalog.This will be discussed in Finkelstein et al. (in prep.), but the methodology is summarized here.The PSF of F606W, F814W, F115W, F150W and F200W is matched to that of F277W (see Table ??).For bands with larger PSFs, the redder NIRCam filters, F356W and F444W, and all other HST/WFC3 filters, they calculated correction factors by convolving the shorter wavelength images to the larger PSF of the F444W, and measuring the flux ratio in the native image to that in the convolved image.By applying this correction factor the fluxes measured in the images with larger PSFs, this corrects for the missing flux under the assumption that the morphology does not change significantly.This is especially useful for small high-redshift sources or faint stellar photometry as it is used here.The photometry using Source Extractor (v2.25.0 Bertin & Arnouts 1996;Holwerda 2005) is described in Finkelstein et al (in prep).
The fits catalog contains photometry in units of nJy.We made use of the fiducial flux and flux error columns, which were corrected to total, and with flux errors calculated empirically from the images.Fluxes were converted to AB magnitudes using a conversion of m AB (FILTER) = −2.5 × log 10 (FLUX_FILTER) + 31.4.The F277W+F356W image was the detection image with the other filters run in dual-image mode to obtain photometry (see Finkelstein et al. 2022a, Finkelstein in preparation for details).The half-light radius from Source Extractor for the F200W filter image is included in this catalogue.The position of all the sources in the catalogue is shown in Figure 1.

Stellar Catalog
We use the effective radius measured in the F200W image of the twoimage Source Extractor run described above to identify unresolved objects in the stellar locus.Figure 2 shows the effective radius as a function of the F200W AB magnitude.The green dashed lines show the limits of the stellar locus, similar to the approach in Ryan et al. (2011) and Holwerda et al. (2014b).The unresolved stars' half-light radius is less than 0. ′′ 1 and declines slightly with fainter objects.This is a known effect in HST imaging because the growth curve from which Source Extractor derives the half-light radius loses the lower surface brightness pixels which make a larger fraction for the flux for fainter sources.The red marks in Figure 2 are the stellar candidates marked in Figure 1 as well.The utility of the half-light radius measured by Source Extractor translates well from HST to JWST with a slightly different dependence between the half-light radius and magnitude.We empirically determine that this stellar identification works well to m  ∼ 28 for the CEERS field.
We use AB magnitudes derived to determine colours for the three feature spaces, JWST/NIRCam, HST+JWST combined, or either ranked by filter wavelength or colours based on only HST and JWST filter pairs.
Figure 3 shows the NIRCam colours space with the SpeX Prism Library Analysis Toolkit (SPLAT) template stellar colours overplot of increasing type (Burgasser & Splat Development Team 2017;Holwerda et al. 2018).A majority of the stellar objects have colours similar to brown dwarf templates.

CLASSIFYING M-L-T-Y TYPE DWARFS WITH NIRCAM COLOURS
A problem in identifying M-L-T-Y dwarf stars from just photometry is that, while there are some clear absorption features in their spectra in the 0.5-2 micron range, these easily become a somewhat degenerate space when observed with wide filters of current and near-future nearinfrared imaging space observatories (Holwerda et al. 2018).Figure  The challenge is now to classify as well as possible with just NIRCam broad colours.Previous work (Ryan et al. 2011;Holwerda et al. 2014b) solved this with colour-colour spaces defined in HST filters.The issue is that these are hard cuts in colour space and the problem of broad classification is not as clear-cut as that.
Here, we use the JWST/NIRCam colour predictions based on SPLAT spectral library from Holwerda et al. (2018) to classify unresolved sources in CEERS.To do so, we tried k-means Nearest neighbour (kNN), a support vector machine (SVM) and a random forest (RF, an average of decision trees) on the bluest colours.Because the SPLAT spectra only extend to 2.5, the longest NIRCam wavelengths cannot be included for the training of the ML algorithms but we can compare the resulting type predictions to the standard stars for each type, for which there is analogue WISE satellite W1-W2 colour available.
Because the colour space of brown dwarfs represents a space with steep gradients and a mixture of physical parameters that drive the observed NIR spectra, we prefer this approach over fitting templates to each SED with assuming the lowest  2 is the optimal fit.By using SPLAT observed spectra rather than model templates, the kNN fit allows for observed but still unexplained variance in each type.

Training Sample
The full JWST/NIRCam colour sample available based on SPLAT spectroscopy (Burgasser & Splat Development Team 2017) is described in Holwerda et al. (2018).Briefly, there is JWST/NIRCam photometry estimates for the 30 standard stars which define the spectral type and for all the SPLAT spectra which capture the intermediate types and variance within spectral types.We use the latter as a training set.The photometry from Holwerda et al. (2018) is in Vega magnitudes and we convert to AB magnitudes first.There is NIR colours in both HST/WFC3 and JWST/NIRCam filters.We use three colour feature spaces, a NIRCam-only, a NIRCam and HST one with colours separated by instrument, and a third where colours use filters in wavelength order, mixing HST and JWST filters.
For the labels one can employ index-type or standard_type from the SPLAT catalog (Burgasser & Splat Development Team 2017), the latter a classification by the spectral index and the former the class to which standard star they resemble most.The indextype has fewer stars classified as intermediate than the standard_type does.We adopt the standard_type throughout.We assign a numerical type as follows: M-types are 0-0.9,L-types 1.0-1.9,T-types 2.0-2.9 and Y-types 3 and above.Later, when applying these labels to the kNN multi-classing, we multiply these by 10 because the kNN can only handle integer classes.Late M-and early L-types are much more represented in the SPLAT training set compared to the later types because their relative luminosity.But all types and subtypes are present in the training set with reasonable sampling (Figure 5).Ryan et al. (2011) and Holwerda et al. (2014b) used the nearinfrared colour-colour space to broadly type the M-L-T dwarfs in parallel HST/WFC3 fields.Figure 6 shows the original HST/WFC3 colour-colour space used for broad photometric typing of these objects.Broad classes are still mixed in this colour space and subtyping using hard cuts in colour-colour space is not possible.
Figure 7 shows a NIRCam equivalent of a colour-colour plot of the SPLAT catalog.A similar separation of objects could conceivably be used.Rather than picking a particular colour-colour combination for broad classification and hoping to sub-class these objects with the remaining information, we opt to subclass directly, varying the spectral subtype resolving power (Δ).As said above, we use three feature spaces: the bluer NIRCam colours, and two iterations of the CEERS HST+JWST complete photometry, one using only instrument specific colours (inst), i.e.only combining HST filters into a colour, and one with the colours arranged by wavelength (wav).For example, in the latter, we combine HST's F160W and NIRCam's F150W into a single colour.
Figures 7, 8 and 9 show the parameter space and the classification into broad types as the colour-coding.Colour-colour space has already proven itself to work well on broad type (e.g.M, L, T or Y?) but now we will attempt to refine the classification down to subclasses.
We start to classify based on 1271 SPLAT (Burgasser & Splat Development Team 2017;Holwerda et al. 2018) spectra from which photometry can be derived in Holwerda et al. (2018) with spectral classifications (standard type).There are 40 classes in this training set.

kNN Classifications
K-Nearest Neighbour classifies objects using the N nearest neighbours in the feature space.Historically, kNN classifies in to two classes (0 or 1).MultiClass classification can be defined as the classifying instances into one of three or more classes.Multiclassing is possible with the sklearn implementation of kNN and this is what we employ here.kNN classification has successfully been used on brown dwarf photometry in Marengo & Sanchez (2009).Splitting This illustrates the issue with hard cuts: in a two-dimensional space like this, there is still ample mixing of types.A photometric classifier based on proximity in this space is expected to perform better than these initial colour-colour cuts.
the SPLAT sample into the typical 80/20 per cent split between training and test set, we classify into the 40 classes of standard type.We initially use the HST+JWST(wav) feature space where colours are computed going from longest to shortest wavelength of the filter, regardless of instrument used.
We want to know a few different classification specific questions: (1) How many neighbours are optimal for classification in this feature space?(2) To what degree of accuracy can one classify within 0.1 of a subtype, 0.2, 0.5 or just the full type?(3) How well does it still perform if only JWST or HST information is used?

Number of Neighbours
Figure 10 shows the dependence of the kNN performance trained on the full HST+JWST(wav) feature space as a function of the number of neighbours used, the key hyperparameter for kNN classifiers.Metrics are calculated based on the number of true and false positives and negatives (TP, FP, TN and FN) in case of two classes.Our metrics are accuracy (TP+TN / TP+TN+FP+FN), precision (TP/TP+FP), recall (TP/TP+FN), and F1 (2× precision × recall / precision+recall).A good classifier strikes a balance between accuracy (fraction of accurate classifications), the accuracy of positive identification (precision), and the completeness of the identified sample (recall) or a metric of the balance of the previous two (F1).The optimal performance in terms of accuracy occurs between n=3 and n=7.Precision and F1 peak at n=4.We use n=4 for the remainder of our applications of kNN on these data-sets as the optimal number of neighbours to determine subtype with kNN.This is comprable to k=3 adopted for Spitzer colour classification adopted by Marengo & Sanchez (2009).The full feature space of the photometric catalog generated from SPLAT spectra of nearby brown dwarfs for the JWST/NIRCam filters in CEERS.Some parts of the colour-colour space are well-suited to broadly classify these objects but the space is degenerate, an ideal scenario to maximize return with a machine learning approach.

Performance and type accuracy
Figure 11 shows the confusion matrix over all 40 types of standard type classes in the training set Δ = 0.1, the highest type accuracy possible.Accuracy was 66% and the other metrics are in Table 1.The same feature space using the indextype as the label performed notably worse.This level of performance is not useful in classification but the confusion matrix in Figure 11 is encouraging in that it may improve with a somewhat coarser type resolution.
Secondly, we explore if just broad class (M/L/T or 0/1/2) classifications can be done with this feature space.Accuracy dramatically improves to 85% with equally good precision and recall scores.These values were even higher for indextype, probably because it does not contain M-type which is somewhat featureless in the NIR at the spectral resolution of these filters.Figure 12 shows the confusion matrix for standard type class for just the broad class for classification.Broad types one can do very well with these four broad JWST/NIRCam filters.There is a slight tendency of kNN algorithm to class brown dwarfs as later type (below the diagonal).
Our question is now how much better the classification can do than broad class?First, we classify within half a class, within Δ = 0.5, where the integer is the broad M, L or T class and then we shall explore 0.4 and 0.2 of a class.Because kNN algorithm does not allow for fractional classes, we multiply the class by 10 (e.g.L1 thus becomes 11 and we divide by 10 afterwards).
Figures 12 and 13 show the confusion matrices for the different Figure 8.The full feature space of the photometric catalog generated from SPLAT spectra of nearby brown dwarfs for the HST/WFC3 filters in CEERS.Some parts of the colour-colour space are well-suited to broadly classify these objects but the space is degenerate, an ideal scenario to maximize return with a machine learning approach.resolutions in spectral type for the test set.Figure 14 shows the metrics of the test set for kNNs trained with different spectral type resolution and these metrics for each kNN run are listed in Table 1.
Figure 15 shows the optimal type resolution of Δ = 4 with k=4.This is the optimum we can achieve with the mix of filters available in CEERS.We note that HST or JWST filter combinations alone also perform optimally with this spectral type resolution but with lower overall metrics (Figure 16).
We varied the number of neighbours for each classification scheme (e.g.n=2 to n=20) but this made no real difference in the metrics.Just under half a type (Δ = 0.4) clearly is the optimal resolution for the HST three-colour feature space to classify in.This is a substantial improvement the hard colour cuts into broad type by Ryan et al. (2011) andHolwerda et al. (2014b) but falls just short of grism spectroscopy classification which can discriminate between subtypes (Aganze et al. 2022a,b).
Figure 16 shows the type resolution of HST-only and JWST/NIRCam-only colour feature spaces.Surprisingly, the HST filter combination performs almost as well as HST+JWST/NIRCam in classification accuracy with type resolution (Figure 14).In effect, it appears that kNN classification can be almost as accurate if the HST NIR imaging is sufficiently deep enough to identify the relevant stars.This will be an inherently smaller volume than JWST/NIRCam can reach.

RESULTS
We will now examine the use of the kNN classification on the NIR-Cam observations of CEERS described in §3.

Application to CEERS
We now apply the kNN classification on the CEERS photometry of unresolved sources identified in Figure 2. Figure 1 shows the distribution of unresolved sources in the ten CEERS fields.We identified a total of 518 stars with a classification (    > 0.5) with the majority of probabilities at 0.8 (Table 2).These classifications are based on the colours using the F115W, F150W, F200W, and F277W filters.We can now verify these kNN type predictions with the red NIRCam colours.

NIRCam Red colours
Figure 17 shows the kNN type versus the F444W-F356W and F444W-F410M colours.These colours are not included in the SPLAT derived filters as these wavelengths are outside the SpeX spectrograph bandwidth.However, WISE W1-W2 colours are available for the standard stars for each type from Pecaut & Mamajek (2013) and these are close stand-ins for the F444W-F356W colour.These colours can be computed for the models of Saumon et al. ( 2012 9.The overall metrics can be found in Table 1 for a type resolution of Δ = 0.1 stars agree well with these atmospheric models, specifically those of Saumon et al. (2012).We note that there is almost a magnitude of variance in colour in the models of Morley et al. (2012), reflecting a wider range of parameters.
The CEERS kNN identified late brown dwarf types ( > 2.5, T5 dwarf or later) appear to be bluer in the NIRCam reddest filters, the ones not used in the kNN classification.These are some 7 highconfidence brown dwarfs (() > 80%) that do not line up in the redward colour space.The discrepancy is as much as a magnitude  1.The metrics for the different binning in type for the kNN algorithm.
An optimal resolution is Δ = 0.5 for this colour-space.in F444W-F356W colour.The remaining late-M and late-T types are much more consistent with the NIRCam long filters.
Figure 4 gives a hint to the discrepancy between the classification based on the short wavelength filters and the colours observed in the long NIRCam filters.The F410M and F444W both cover a wavelength range where a Sulfur and a Phosphorus molecule is influencing absorption (Leggett et al. 2021).If these are T/Y dwarfs with relatively more of such compounds, perhaps it could skew the reddest NIRCam colours towards redder values?
The Saumon et al. (2012) and Morley et al. (2012) models are for Solar metallicity brown dwarfs only.This explains why they align with the standards for brown dwarfs and hints at lower metallicity as a possible explanation for the red colours of these late-type brown dwarfs.Future infrared spectroscopy of these could confirm this.

NIRSpec prism observations
Two of the kNN brown dwarf candidates were ob0served with CEERS NIRSpec Multi-Shutter Assembly (MSA) spectroscopy (Arrabal Haro et al., in prep.) using the low-resolution ( = 30-300) prism disperser (Figure 19).These targets were not originally selected to be stars, but as candidates for distant extragalactic objects.

Scale-height of Brown Dwarfs
To model the scale-height of the Galactic disk along the one lineof-sight of the CEERS field, we use the cumulative count of brown dwarfs as a function of apparent magnitude (similar to Pirzkal et al. 2005Pirzkal et al. , 2009)).Assuming a brown dwarf type and the local density within 20 parsec from Reid et al. (2008) and Kirkpatrick et al. (2021) and a scale-height, one can compute the numbers of brown dwarfs along the line-of-sight.This works best with a single brown dwarf type, a cleanly selected sample, and only the thin disk of the Milky Way considered.
Figure 18 shows two cumulative histograms of the brown dwarf candidates identified in CEERS.The early types (T=0.6,i.e.M6) show an over-density compared to the thin disk.At the lower apparent luminosities, there is a clear over-density that cannot be explained  2016) found for M-dwarfs in the HST pure-parallel fields.The cumulative histogram is consistent with a thin disk with a scale-height of  0 = 250 − 300pc, similar to the scale-heights found before (Ryan et al. 2005(Ryan et al. , 2011;;Pirzkal et al. 2005Pirzkal et al. , 2009;;Holwerda et al. 2014b;van Vledder et al. 2016;Aganze et al. 2022b).A second Galactic structural component is needed to explain the numbers of M-dwarfs in deep JWST/NIRCam fields.
The second panel of Figure 18 shows the distribution of late dwarfs (T=2.6,i.e.T6±2).Their distribution is mostly consistent with a thin disk alone as they are intrinsically much fainter (  = 17.06AB).A second component is not fully evident from the counts in CEERS.The cumulative histogram is consistent with a thin disk with a scaleheight of  0 = 150 − 200pc, similar to the scale-height of 175pc found before (Ryan et al. 2011;Aganze et al. 2022b).There is the matter of types in-between the early and late brown dwarfs apparently missing in this field.There are two L-dwarfs and one early T-dwarf in this field with reasonably high confidences.This is not yet enough statistics to infer a scale-height with much confidence.To infer scale-heights accurately, one will need many more lines-of-sight though the Milky Way disk.

DISCUSSION
JWST opens up a new parameter space in the near-infrared, thanks to both more collecting area and much improved efficiency compared to other NIR observatories.CEERS is meant to demonstrate this potential, especially in extra-Galactic science.However, the depth and colour resolution that benefits extra-galactic science can benefit science examining our own Milky Way's stellar population just as much.
Figure 2 illustrates the first improvement: the identification of stellar objects in drizzled NIRCam images increases from HST (∼ 25) to ∼28AB mag using otherwise identical techniques.This alone opens a wide volume of the Galaxy for low-mass stellar objects.
The much greater filter suite available onboard NIRCam is a second capability that expands our discovery space over HST/WFC3.The bluest NIRCam filters combine into a similar feature space (Figure 7 compared to Figure 8) but the addition of longer wavelength information with NIRCam immediately allows us to check kNN classifications.For these colors atmosphere models can stand in for the SPLAT observations (see Appendix A) but performance is not quite as reliable as SPLAT.This can be attributed to the much larger training sample in SPLAT (∼1200) over these models (∼300) which captures the range of characteristics inherent in the population.The models however extend to later types of brown dwarfs and cover longer wavelengths, opening up the possibility to train on models and then use the full NIRCam wavelength range to classify stellar objects.
The late-type candidates for example appear to have too blue colours in the reddest NIRCam filters (Figure 17).This could be mis-identification or an issue with calibration of the kNN.The effect is quite pronounced and could speculatively be explained by more sulfur and phosphorus compounds in these substellar objects (Figure 4).
The F444W-F356W colours of the brown dwarfs are very similar to the F200W dropout galaxies identified in Bisigello et al. (2023), their figure 4 (see Figure 20) but with F200W and bluer detections.The accurate identification of brown dwarfs is therefore critical in the removal of potential interlopers in the identification of new (low redshift) dwarf galaxy populations ( < 2).Similarly, some kNN identified late-type ultracool dwarfs reside in the HST-dark section of the colour space identified in Pérez-González et al. (2023).These authors took care to select these samples using other colour cuts and SED fits. Figure 20 illustrates the possibility that brown dwarfs could be included without such precautions.In such cases, a high probability assigned by the kNN classifier that the unresolved object is a brown dwarf may be a good reason to remove an object from a selection.
A major consideration in the successful identification of brown dwarfs in extra-galactic JWST data is to remove them as contaminant in searches for high-redshift sources ( > 8) 1 Figure 21 shows the bluer NIRCam colours of the brown dwarfs identified with kNN and the high-redshift sources from Finkelstein et al. (2023).The  > 12 sources are dropouts in the F115W and therefore not shown in the bluest colour F115W-F150W.Both the high-redshift sample and the brown dwarf kNN selection do not rely on hard colour criteria but instead on good SED fits to a template and redshift or a close set of kNN templates in colour space.
Figure 21 illustrates that a colour-cut in F115W-F150W can separate the two popylatins well but that the redder NIRCam colours are very similar for brown dwarfs and high-redshift galaxies alike.
Photometric identification of brown dwarfs in JWST data is ongoing (Nonino et al. 2023;Beiler et al. 2023;Wang et al. 2023).Like all photometric identifications, the kNN classifications here would benefit from spectroscopic confirmation using NIRSpec.Figure 19 shows a first such spectroscopic confirmation with a low-resolution NIRSpec prism spectrum.This would be the second ultracool brown dwarf spectroscopically confirmed with JWST after Beiler et al. (2023).
Wang et al. ( 2023) identify a T dwarf in the public CEERS data.This object is not in our kNN classified sample as it too faint to be included ( 200 = 28.45AB,see Figure 2).However, a kNN classification trained on just the blue JWST/NIRCam filters (F115W, F150W, F200W, and F277W) predicts a L7 dwarf (    = 1530K,     (  ) = 100%), a higher effective temperature than (    = 1300, T0 ?)s classified by Wang23e.The reported F444W-F356W colour (-0.14) is consistent with the kNN classification as well as the Wang et al. ( 2023) one (Figure 17).We can note here that L7 and T0 are less than 4 subtypes apart.
The difference between kNN classification and spectroscopic classification for individual sources highlights the statistical nature of the kNN classifications.It shows that kNN classifications are good enough for a population of sources to be used in a statistical manner to infer the shape of the Milky Way.An MCMC model such as employed by van Vledder et al. (2016) has the benefit of explicitly dealing with a fraction of the data as bad as a fit parameter.
The inferred vertical profiles of M and T-dwarfs is 300-350pc for the 6 ± 2 dwarf candidates in the CEERS field with a clear second component starting at  200 ∼ 24 in Figure 18 The photometric identification of M-L-T-Y dwarf stars in deep extragalactic observations such as CEERS has a success rate (85% or better) with existing photometry.It seems only a matter of time before enough sightlines through the Milky Way will be available for an accurate assessment of their distribution and total numbers.

CONCLUSIONS
We have applied kNN identificataion of brown dwarf types on the unresolved sources in the stellar locus of CEERS photometry with the aim of identifying this Galactic population Broad filters onboard JWST/NIRCam are sufficient to identify brown dwarfs photometrically to within 2 subtypes using k-Nearest Neighbour classification using the four nearest neighbours.We only use the four bluest filters for this (F115W, F150W, F200W and F277W).The SPLAT library is optimal as a training set with sufficient size and coverage of type.Conceivably atmospheric models of M-L-T-Y dwarfs may replace these as the training set.
The late-type brown dwarfs identified in CEERS are bluer in the NIRCam red filters than expected on the kNN classification based on NIR blue filters.This remains unexplained by standard stars or atmospheric models. The

APPENDIX A: MODELS
We test the kNN classifier based on the models from Saumon et al. (2012) and Morley et al. (2012).In total 337 different models are available.Figure A1 shows the colour feature space.Brown dwarf type was assigned to each model using the table from Pecaut & Mamajek (2013) matching model temperature to a brown dwarf type with similar temperature.This is not as big a training set as the SPLAT catalogue.
Figure A3 shows the confusion matrix of the models.Like the SPLAT catalogue, there is a tendency for the kNN to classify brown dwarfs slightly later.Coverage of type is not as uniform as SPLAT and this hinders interpolation with kNN some.The performance as a function of type resolution is shown in Figure A2 and this lack of coverage is evident in an erratic increase in most metrics.
There are two major benefits of these models over the SPLAT catalog: first the feature space includes the red NIRCam filters as well.One can use all the NIRCam photometry to classify.Secondly, the models extend to much later types than SPLAT.Future suites of models (e.g.improved line lists, disequilibrium chemistry, improved treatment of clouds etc.), once verified with spectroscopy, could well serve as the training set for future kNN classifications.

Figure 1 .
Figure 1.Small black dots denote all objects in the CEERS photometric catalog used for this work.The red dots denote the positions of stellar objects identified in Figure 2.

Figure 2 .
Figure 2. The apparent magnitude of objects in the CEERS photometric catalogue in the F200W detection filter (AB magnitude) and the effective radius computed by Source Extractor in the same filter.The green dashed lines delineate the locus of unresolved sources.We identify the red objects as unresolved stellar candidates.

Figure 3 .
Figure3.The F115W-F150 and F200W-F277W, F200W-F277W and F356W-F444W colour-colour space for the stellar objects identified in Figure2with the brown dwarf standard stars overplot as tracks in increasing type.With the intrinsic variation in colour with brown dwarf type, this shows it is plausible a majority of the stellar sources are possibly brown dwarf type objects.No F410M filter information is available for the standard brown dwarfs.

Figure 4 .
Figure 4.An example of a Y-dwarf from Leggett et al. (2021) with some of the absorbing molecule species marked and the CEERS NIRCam filters used annotated at the bottom.The JWST/NIRCam blue filters (F115W, F150W, F200W and F277W) are sensitive to the molecular absorption features that define the classes.The longer wavelength filters (F356W, F410M, and F444W) are more sensitive to overall temperature and different molecular absorption features.

Figure 5 .
Figure 5.The distribution of standard types for the SPLAT training set.The training set is dominated by late M-and early L-dwarfs.

Figure 6 .
Figure 6.The distribution of HST/WFC3 colours for the standard types for the training set.The colour-colour selections from Ryan et al. (2011) and Holwerda et al. (2014b) for M-, L-, and T-dwarfs are indicated with coloured boxes.This illustrates the issue with hard cuts: in a two-dimensional space like this, there is still ample mixing of types.A photometric classifier based on proximity in this space is expected to perform better than these initial colour-colour cuts.

Figure 7 .
Figure7.The full feature space of the photometric catalog generated from SPLAT spectra of nearby brown dwarfs for the JWST/NIRCam filters in CEERS.Some parts of the colour-colour space are well-suited to broadly classify these objects but the space is degenerate, an ideal scenario to maximize return with a machine learning approach.

Figure 9 .
Figure9.The full JWST+HST feature space of the photometric catalog generated from SPLAT spectra of nearby brown dwarfs for the HST/WFC3 and JWST/NIRCam filters in the CEERS catalog, sorted by wavelength.This extensive colour feature space may well be suited to classify sources in deep HST+JWST data but mixing instruments for the colours may be susceptible to systematics.
Figure17shows the kNN type versus the F444W-F356W and F444W-F410M colours.These colours are not included in the SPLAT derived filters as these wavelengths are outside the SpeX spectrograph bandwidth.However, WISE W1-W2 colours are available for the standard stars for each type fromPecaut & Mamajek (2013) and these are close stand-ins for the F444W-F356W colour.These colours can be computed for the models of Saumon et al. (2012) and Morley et al. (2012) L/T/Y atmospheric models as well.The standard

Figure 10 .
Figure 10.The precision, recall, F1, and accuracy, each expressed as a dimensionless fraction, as a function of number of neighbours (n) of the test set of the kNN classifier on the SPLAT photometry using the HST+JWST(wav) feature space.

Figure 11 .
Figure 11.The confusion matrix of the kNN classification into individual subtypes of M, L, T-dwarfs using the HST+JWST(wav) feature space shown in Figure 9.The overall metrics can be found inTable 1 for a type resolution of Δ = 0.1

Figure 13 .Figure 14 .
Figure 13.The kNN classification confusion matrix on the HST+JWST(wav) feature space with a much lower type resolution of Δ = 0.5

Figure 15 .
Figure 15.The kNN classification confusion matrix on the HST+JWST(wav) feature space with the optimal type resolution of Δ = 0.4.This is the kNN classifier used on the CEERS photometry

Figure 16 .Figure 17 .
Figure 16.The metrics of the kNN classification, each expressed as a dimensionless fraction, as a function of the type resolution (Δ) for the HST-only filter colour-space (left) and the JWST-only filter colour-space (right).For HST, all metrics climb steadily with coarser type resolution.If one wants to classify within a type (Δ = 0.5), the metrics are ∼ 85%.Notably, Δ = 0.4 would perform almost equally well.For JWST-only, the blue NIRCam filers perform poorer than in combination with HST (Fig. 14) or HST-only (left) until almost full type resolution Δ ∼ 1 by a Galactic thin disk alone.This is similar to what Holwerda et al. (2014a) and van Vledder et al. (

Figure 18 .
Figure 18.The cumulative histogram of apparent magnitude in F200W for the kNN identified types T=M6±2 and T=T6±2 and the expected distribution assuming this type and different Galactic vertical scale-heights.

Figure 19 .
Figure 19.NIRSpec prism spectra of two of the unresolved objects identified by the kNN classification method.The 2D spectra are shown above, with the extraction window marked with a white border.The 1D extracted spectra are shown below.Left: CEERS NIRSpec MSA ID #1558 shows broad absorption bands at 1.5, 2 and 2.5 microns typical of later type brown dwarfs (see Figure 4).Right: CEERS NIRSpec MSA ID #20821 is a galaxy at  = 1.94 with strong emission lines that perturb the NIRCam photometry, leading to misclassification as a brown dwarf.
. This is consistent with what van Vledder et al. (2016) found for HST/WFC3 pure-parallel fields (300pc).The scale-height of the candidate T-dwarfs is more consistent with 150-200pc.This is remarkably consistent with what Aganze et al. (2022b) found from HST grism observations (175pc).
scale height of the MW disk is consistent with the 350 pc for type M-types, similar to what van Vledder et al. (2016) found.The vertical distribution of later T-types is consistent with a scale-height of 150-200pc, in line with the value from Aganze et al. (2022b).

Figure 20 .
Figure 20.A comparison to Figure 4 of Bisigello et al. (2023) and Figure 1 from Pérez-González et al. (2023) for the kNN classified stellar objects.Marker size is indicative of the kNN probability assigned to each object's classification.The dashed lines are the lower limits for the selection criteria for dusty dwarfs (left) or HST-dark galaxies (right).Both populations can suffer from contamination from brown dwarfs.

Figure 21 .
Figure 21.The F115W-F150W and the F150W-F200W vs F200W-F277W colours of the brown dwarf candidates identified in this paper and the same colours of the Finkelstein et al. (2023) selection of high ( > 8) redshift galaxies.

Figure A1 .
Figure A1.The colour-colour feature space from the models of Saumon et al. (2012) and Morley et al. (2012).The type space is a few late L-type, most T-types and early Y-type.The full feature space does include all CEERS filter colour combinations.

Figure A2 .
Figure A2.The performance of the kNN using the colours based on the models of Saumon et al. (2012) and Morley et al. (2012).The higher dimensionality but lower type coverage results in some erratic behavior.

Figure A3 .
Figure A3.The confusion matrix of the kNN model based on the colours based on the models of Saumon et al. (2012) and Morley et al. (2012).Compared to the SPLAT confusion matrix in Figure 11.

Table A1 .
The CEERS unresolved sources identified in Figure2with kNN type  and probability  ( ), RA and DEC position and the HST and JWST/NIRCam AB apparent magnitudes.