Clusternets: A deep learning approach to probe clustering dark energy

Machine Learning (ML) algorithms are becoming popular in cosmology for extracting valuable information from cosmological data. In this paper, we evaluate the performance of a Convolutional Neural Network (CNN) trained on matter density snapshots to distinguish clustering Dark Energy (DE) from the cosmological constant scenario and to detect the speed of sound ($c_s$) associated with clustering DE. We compare the CNN results with those from a Random Forest (RF) algorithm trained on power spectra. Varying the dark energy equation of state parameter $w_{\rm{DE}}$ within the range of -0.7 to -0.99, while keeping $c_s^2 = 1$, we find that the CNN approach results in a significant improvement in accuracy over the RF algorithm. The improvement in classification accuracy can be as high as $40\%$ depending on the physical scales involved. We also investigate the ML algorithms' ability to detect the impact of the speed of sound by choosing $c_s^2$ from the set $\{1, 10^{-2}, 10^{-4}, 10^{-7}\}$ while maintaining a constant $w_{\rm DE}$ for three different cases: $w_{\rm DE} \in \{-0.7, -0.8, -0.9\}$. Our results suggest that distinguishing between various values of $c_s^2$ and the case where $c_s^2=1$ is challenging, particularly at small scales and when $w_{\rm{DE}}\approx -1$. However, as we consider larger scales, the accuracy of $c_s^2$ detection improves. Notably, the CNN algorithm consistently outperforms the RF algorithm, leading to an approximate $20\%$ enhancement in $c_s^2$ detection accuracy in some cases.


INTRODUCTION
The standard model of cosmology (ΛCDM) is in agreement with many observations, including anisotropies in the Cosmic Microwave Background (CMB) (Aghanim et al. 2020a,b), the Baryon Acoustic Oscillations (BAO) (Alam et al. 2017), and supernovae observations (Perlmutter et al. 1999).This model is based on the existence of the cosmological constant (Λ) and Cold Dark Matter (CDM).Despite its successes in explaining cosmological observations, the physical origins of these components are not explained within the ΛCDM model.In addition to the theoretical concerns, some observational anomalies have been pointed out in cosmological studies.For instance, the Hubble tension which indicates around 4σ discrepancy between the late and early time measurements ⋆ a.chegeni@umail.leidenuniv.nl† farbod.hassani@astro.uio.no‡ alireza.vafaeisadr@unige.ch§ n-khosravi@sbu.ac.ir ¶ martin.kunz@unige.ch(Valentino et al. 2021a;Riess et al. 2022Riess et al. , 2018)).Some milder tensions/anomalies are also reported in the literature, for example, the growth rate (σ8) tension (Valentino et al. 2021b;Abdalla et al. 2022), the BAO curiosities (Aubourg et al. 2015), and the CMB anomalies (Perivolaropoulos 2014) (see (Perivolaropoulos & Skara 2022) for an overview).These tensions and anomalies may be a hint of beyond ΛCDM cosmology.
In recent years, cosmologists have proposed various alternatives to address the accelerating expansion of the universe (Hu & Sawicki 2007;Amendola et al. 2007;Copeland et al. 2006;Ishak 2018;Banihashemi et al. 2019), including clustering Dark Energy (DE), also known as w − c 2 s −CDM model.This model is characterized by the equation of state wDE and the speed of sound cs, and is a viable candidate for the latetime cosmic acceleration when wDE is close to −1.Clustering DE models can be thought as an effective field theory of kessence (Armendariz-Picon et al. 2000, 2001), which involves a single scalar field that is minimally coupled to gravity.Clustering DE has been widely studied and implemented in some Boltzmann and N -body codes (Lesgourgues 2011;Lewis et al. 2000;Zumalacá rregui et al. 2017;Hu et al. 2017;Hassani et al. 2019;Adamek et al. 2016b;Hassani et al. 2020b,a).
In the next few years, cosmological surveys such as Euclid (Laureijs et al. 2011), the Dark Energy Spectroscopic Instrument (DESI) (Collaboration et al. 2016), the Legacy Survey of Space and Time (LSST) (Collaboration 2012), and the Square Kilometre Array (SKA) (Santos et al. 2015) will provide precise measurements of large-scale structures, including modes in the highly non-linear regime.The future data give us a great chance to test our cosmological models accurately, particularly those that aim to explain the late-time cosmic acceleration (Tegmark 1997;Goobar & Leibundgut 2011).However, studying the non-linear regime analytically is a difficult task, which underscores the need for accurate numerical simulations (Springel 2005;Bagla 2002;Adamek et al. 2014;Teyssier 2002;Bryan et al. 2014;Hassani & Lombriser 2020).For cosmologists, a key challenge will be to determine the nature of the late-time accelerating expansion and whether the physical mechanism behind it is the cosmological constant or other theories of gravity (Clifton et al. 2012;Peebles & Ratra 2003).
In this direction, we utilise the Convolution Neural Network (CNN) (Koushik 2016) and Random Forest (RF) (Louppe 2015) algorithms to classify various clustering DE models based on their speed of sound cs and equation of state wDE, as compared to the cosmological constant scenario.In this study, we use sub-boxes of matter density snapshots to train the CNN algorithm and matter power spectra extracted from these sub-boxes to train the RF algorithm.Subsequently, we use the confusion matrix to compare the accuracy of these two algorithms and to study the power of each algorithm in distinguishing clustering DE cosmologies parametrised by different clustering DE parameters.Furthermore, we particularly explore the performance of the CNN algorithm in comparison to RF, especially on small scales, where non-linear structure formation is dominant.
The paper is organised as follows.In Section 2 we discuss the simulations, the ML algorithms we employ and the evaluation criteria that we use to find the accuracy of the algorithms.Our results and their physical interpretations are discussed in Section 3. Finally, we summarise and discuss the main results of this work in Section 4.

METHOD
In this section, we discuss the data, the ML algorithms, and the evaluation strategy that we use in this work.In subsection 2.1 we introduce the simulations we use to train the ML algorithms.We discuss the ML algorithms (CNN and RF) and the evaluation strategy that we use in this work in detail in subsection 2.2.

Simulations
In this paper, we utilize the k-evolution code (Hassani et al. 2019) to investigate the clustering DE scenario.k-evolution is a relativistic N -body code based on gevolution (Adamek et al. 2016b,a).In k-evolution, the coupled equations for the k-essence scalar field, and dark matter particles are solved consistently.Furthermore, the k-essence is considered as an effective field that can be parameterised by the equation of state wDE and the speed of sound cs.The effective field theory of k-essence is also referred to as clustering DE which is a terminology we use in this paper.The ΛCDM simulations are based on gevolution N -body code.
In gevolution and k-evolution, matter and gravitational potentials are treated non-linearly and they are sourced by the dark energy density.In k-evolution, dark energy is implemented as an independent component and can form nonlinear structures in response to non-linear matter clustering.A lower speed of sound for clustering DE can lead to increased non-linear behaviour in the dark energy component (Hassani et al. 2019).However, when the equation of state of the dark energy is fixed and is close to -1, the effect of the speed of sound on matter power spectrum is relatively small, and it is hard to constrain clustering DE using changes in the matter power spectrum.
In our clustering DE simulations, we investigate a wide range of values for the equation of state and speed of sound.Specifically, we consider w ∈ {−0.7, −0.8, −0.85, −0.9, −0.95, −0.97, −0.98, −0.99} and c 2 s ∈ {1, 10 −2 , 10 −4 , 10 −7 }.Moreover, we consider the following fixed values for the cosmological parameters; the reduced Hubble parameter h = 0.67556, the spectral index ns = 0.9619, the amplitude of scalar perturbations As = 2.215 × 10 −9 at the pivot scale kp = 0.05 Mpc/h, the baryon and CDM component densities w b = 0.02203, wCDM = 0.12038, and the CMB temperature TCMB = 2.7255 K. To examine the accuracy of the ML algorithms across different physical scales, we consider three different simulation box sizes: L = 128 Mpc/h, L = 512 Mpc/h, and L = 2048 Mpc/h.In our simulations, we use an equal number of lattice points and particles (N pcl = N grid ).For the majority of our simulations, we fix the value of N grid to 256 3 .However, to investigate the convergence of our results, we also consider a case where N grid = 512 3 .Moreover, we conduct six simulations for each scenario, using different seed numbers.Taking into account the three box sizes, different wDE-c 2 s parameters, and 6 unique seed numbers for each case, our study incorporates approximately 600 simulations in total.To compute the density field from the particle snapshots we utilize the Pylians31 library.The corresponding matter power spectra are calculated using the cloud-in-cell mass assignment method.In our ML training process, we extract 2000 sub-boxes from each density snapshot, resulting in a total of 10,000 sub-boxes for each cosmology when all the seed numbers are taken into account.These sub-boxes may overlap and are subsequently fed as input for the algorithms during the training process.This particular number of sub-boxes has been determined based on the convergence of accuracy for the ML algorithms which is discussed in Appendix A. We consider various cosmological scales by considering different simulation box sizes and sub-box cut fractions of 1/2 and 1/4.To mitigate aliasing inaccuracies, we restrict the RF analysis to a portion of the power spectrum that is well below the Nyquist frequency.However, excluding higher wavenumbers results in a reduction of approximately 3% in overall accuracy.Interestingly, it appears that the algorithms can still learn from these seemingly inaccurate wavenumbers, suggesting potential for improving accuracy with their inclusion.

Machine Learning Algorithms
In our study, we initially considered several widely used ML algorithms for classification tasks.These include the Logistic Regression (Chung 2020), Naive Bayes (Vikramkumar et al. 2014), Decision Trees (Zhang 2021), Support Vector Machine (Noble 2006), K-Nearest Neighbours (Cunningham & Delany 2021), and Random Forest (Louppe 2015).We applied these algorithms to power spectra for some values in (w − c 2 s ) parameter grid.Our results suggest that the RF has the best performance among these.That is why we choose the RF for the comparison with the CNN algorithm.
• Random Forests: The RF (Ball & Brunner 2010;Carliles et al. 2007;Baron 2019) is a widely used supervised algorithm for classification tasks.This algorithm has been used in numerous areas of science (Zhang 2021;Louppe 2015).In this work, we train the RF algorithm over the matter power spectra.The power spectra are computed from the matter density sub-boxes, which are also used to train the CNN algorithm.In order to optimise the performance of the RF algorithm, we adjust its hyperparameters.The RF algorithm relies on two primary hyperparameters: the number of trees and the maximum depth (Louppe 2015).In our analyses, we construct a hyperparameter grid encompassing a range of values for the number of trees (from 10 to 2000) and the maximum depth (from 10 to 100).Subsequently, we evaluate the accuracy of the RF algorithm across this grid to determine the optimal hyperparameters.It is important to note that we adjust the hyperparameters for all cases discussed in Section 3.
• Convolutional Neural Network: CNN is a highly effective and widely used technique for object recognition and classification in the field of ML.These networks employ a hierarchical architecture consisting of multiple layers, including convolutional and pooling operations.Through this architecture, the CNN can automatically learn and extract meaningful features from input images, enabling them to process complex visual data with remarkable accuracy.The CNN has demonstrated exceptional performance in various computer vision tasks, including image recognition, classification, and generation.In our study, we use a CNN on three-dimensional (3D) simulation density maps to make the most of this technique in distinguishing clustering DE models with different speeds of sound and equations of state, compared to the cosmological constant scenario.The architectural design, parameter selection, and hyperparameter optimization of the CNN algorithm employed in our work are described in Appendix B.

Evaluation criteria
To assess and compare the results of the two ML algorithms, it is crucial to establish suitable classification criteria.Since distinguishing clustering DE from the ΛCDM model can be considered a binary classification task, we employ the Confusion Matrix (CM) (Ting 2017)  However, achieving perfect accuracy in identifying every instance of clustering DE is impractical in real-world scenarios.To evaluate the performance of an ML algorithm, a commonly used and straightforward statistic is "accuracy" which is computed using the CM.This statistic is computed by summing up the correct predictions for both the clustering DE and ΛCDM classes and dividing it by the total size of the test dataset, A schematic representation of our work is illustrated in Figure 1.In this figure, we show the details of the data preparation for each ML algorithm.In our study, we utilize six density snapshots with distinct seed numbers, representing different realizations of the same cosmology.To ensure robustness and generalization, we consider the sub-boxes extracted from five density snapshots as the training data, while the sub-boxes from the remaining density snapshot serve as the test and validation data.By incorporating results from five different seed numbers, we mitigate the potential influence of specific realizations and ensure the reliability of our results.In our approach, we randomly select sub-boxes from each simulation and compute the matter power spectra for these sub-boxes.We then train a CNN algorithm using the 3D density maps from the sub-boxes and an RF algorithm using the corresponding matter power spectra.To assess the accuracy of each ML algorithm, we calculate the CM.It is important to highlight that in the context of detecting the speed of sound (cs), as discussed in subsection 3.2, the classification task involves distinguishing between clustering DE with c 2 s and clustering DE with c 2 s = 1, while keeping wDE fixed.

RESULTS
In this section, we explore the accuracy of ML algorithms in distinguishing clustering dark energy theories by considering variations in the equation of state (wDE) and the speed of sound (cs).We utilize the CNN algorithm for training on sub-boxes extracted from primary density snapshots, with varying simulation box sizes L ∈ {128, 256, 2048} Mpc/h.In all simulations, we utilize a fixed number of particles and grids, with N pcl = N grid = 256 3 .Moreover, the snapshots are produced at a cosmological redshift of z = 0, which matches the current epoch in the Universe's evolution.
In our study, we investigate sub-boxes that are either half or a quarter of the size of the main simulation box.These sub-boxes, along with the conditions N grid = N pcl = 256 3 , play a crucial role in determining the length scales covered for each case analyzed.For the case where the main box size is L = 2048 Mpc/h, and we cut sub-boxes that are half the size of the simulation box, the length scales span a range denoted as ℓ 1 2 ∈ [8, 1024] Mpc/h, which corresponds to a wavenumber range of k 1 2 = 2π/ℓ 1 2 ∈ [0.006, 0.680] h/Mpc.Similarly, when we consider sub-boxes that are a quarter of the size of the main box, the length scales cover a range ℓ 1 4 ∈ [8, 512] Mpc/h, corresponding to a wavenumber range of k 1 4 ∈ [0.012, 0.680] h/Mpc.In this context, ℓ represents the length scales incrementing by ∆ℓ, which is determined by the spatial resolution of the simulation ∆ℓ = L/N grid .The sub-index for ℓ indicates the portion of the main box that has been cut to form the sub-box.In Table 1, we present the length span and corresponding wavenumber ranges for each sub-box in the cases analyzed in our study.
Notably, the power spectra computed over sub-boxes of sizes 1/8, 1/16, and 1/32 of the main boxes exhibit significant variation.Given the substantial variations observed in the power spectra of these sub-boxes, they proved unsuitable for the RF algorithm, as it would face challenges in effectively learning from such data.In contrast, we do not encounter this challenge when utilizing the CNN algorithm, which effectively learns from 3D density snapshots.The sub-box sizes of 1/2 and 1/4 of the main boxes used in this article provide the most consistent results when comparing the CNN and RF algorithms.
The decision to use sub-boxes instead of main boxes is driven by the requirements of the RF and CNN algorithms.While this choice may lead to a reduced detectability of clustering DE due to the exclusion of certain large modes that are crucial for distinguishing the models, it aligns with the learning mechanisms of the algorithms.Both the RF and CNN algorithms rely on a large number of inputs to effectively learn the underlying patterns.Providing the full simulation box as input would necessitate training the algorithms with different simulations using different seed numbers to ensure convergence and learning from the patterns.However, such an approach would have significantly higher computational costs and make it prohibitively expensive to run these simulations.Therefore, utilizing sub-boxes for training the CNN and RF algorithms becomes a wise strategy.Cutting multiple sub-boxes from the main simulation box as a post-processing strategy offers a reasonable approach, striking a balance between excluding some modes and managing computational resources.It is important to note that by considering different sizes of main boxes, we effectively account for the modes that are lost by considering sub-boxes instead of full simulation boxes.
In order to obtain initial insights into the behavior of different models before the training phase, we investigate the ratio of power spectra.Figure 2 and Figure 3 present the ratio of matter power spectra for the selected cases that are utilized for training the ML algorithms in the subsequent subsections.It is important to note that the RF algorithm is trained on the power spectra, not the ratios.The ratios presented in Figure 2 and Figure 3 are less noisy than the power spectra because cosmic variance is reduced in the ratio.Additionally, the ratios are obtained by averaging results from different seed numbers, which helps to reduce the fluctuations further, as reflected in the error bars.Finally, the parts of the simulations that are prone to resolution inaccuracies have been removed from the figures in the ratio.Therefore, the RF algorithm learns a much noisier power spectrum than what is shown in the ratios.This means that features that appear obvious in the ratios may be difficult to distinguish in the noisy power spectra.In Figure 2, we present the smoothed matter power spectra ratio of clustering dark energy with varying equation of state, wDE, and a fixed sound speed squared c 2 s = 1, relative to the reference case of ΛCDM.On the other hand, Figure 3 showcases the matter power spectra ratio of clustering dark energy with a fixed wDE and different values of c 2 s , in comparison with clustering dark energy with the same wDE but c 2 s = 1.The figures include vertical lines indicating the wavenumbers covered by the sub-boxes, which are half the size of the main simulation box.These figures represent the average results of five simulations, each with different seed numbers.The error bars show how much the results vary around this average.Large error bars at small scales come from the use of a relatively small simulation box (L = 128 Mpc/h).This limited box size leads to large variations in power spectra among different seed numbers and affects the ratios as well.varies a lot for different seed numbers due to losing long wavelength modes in the entire simulation due to cosmic variance.We combined the outcomes from three different box sizes, namely L ∈ {128, 256, 2048} Mpc/h, while excluding the portion close to the Nyquist frequency..196, 10.882] Table 1.The length scale spans and corresponding wavenumber ranges for different simulation box sizes, as well as different cuts of the main simulation box (1/2 and 1/4 cuts).Throughout all cases, N grid = 256 3 remains constant, while we vary the box sizes and sub-box cuts to serve as input for training the ML algorithms.We determine the wavenumber ranges using the formulas: where k N is the Nyquist wavenumber and dx is the spatial resolution.
Furthermore, we applied the savgol filter in Python to achieve a smooth representation of the results.
These figures provide valuable insights into the scales (determined by box sizes and sub-box cuts) as well as the clustering dark energy parameters where the ML algorithms are expected to effectively distinguish different scenarios.Analysing Figure 2, we observe that at large scales, the ratio remains relatively constant, with a suppression that is mainly determined by a factor related to 1 + wDE.However, at intermediate scales (around k ∼ 0.9 h/Mpc), as non-linear effects become prominent, the ratio experiences a further decline.This decline arises from the enhanced growth of structures in the ΛCDM scenario compared to the wCDM scenario, leading to a more pronounced difference between the two cases.At smaller scales, the ratio approaches unity (1) due to the dominance of matter non-linearities in both scenarios.
From Figure 3, it is evident that the ratio between different c 2 s values and the case where c 2 s = 1 increases as 1 + wDE increases.Furthermore, a smaller speed of sound leads to a more pronounced growth of matter structures.This is due to the fact that the sound horizon is located at larger wavenumbers or smaller scales.This effect leads to the amplification of clustering dark energy perturbations, resulting in a stronger clustering of matter within these specific regimes.

Detecting Clustering Dark Energy: wDE
In this subsection, we explore the impact of various equations of state parameter (wDE) for clustering DE, on the detectability of the CNN and RF algorithms.The ML algorithms are trained using simulation sub-boxes extracted from the main simulation box for different values of wDE in the set {−0.7, −0.8, −0.85, −0.9, −0.95, −0.97, −0.98, −0.99}, while c 2 s = 1.As discussed previously, in the RF algorithm, the machine is trained using the power spectra of the extracted sub-boxes and in the CNN, we train it using 3D matter density snapshots.This training process is carried out for two different sub-box cut fractions, namely 1/2 and 1/4.In Figure 4 and Figure 5, the accuracy of each algorithm in distinguishing clustering DE with different wDE from the cosmological constant scenario (wDE = −1) is shown.The accuracies are plotted for different choices of simulation box size.In Figure 4, sub-boxes with a size of 1/4 of the simulation box are utilized, while in Figure 5, sub-boxes that are 1/2  of the simulation box are employed.In all the simulations, we maintain c 2 s = 1, and N grid = N pcl = 256 3 .To determine the length scale range and wavenumber ranges covered by each simulation box size and sub-box cut, refer to Table 1.In the figures, the blue lines represent the performance of the CNN algorithm, while the red lines show the accuracy of the RF algorithm for different values of wDE.The different point styles, such as stars, circles, and rectangles, correspond to different sizes of the simulation box, each corresponding to a distinct physical length span.In Figure 4  ∈ [0.5, 32] Mpc/h), it achieves this level of detectability at approximately wDE ≈ −0.73.However, it is important to highlight that the RF algorithm does not achieve the same level of accuracy for wDE ≤ −0.7, which is the range considered in our study.
By choosing larger sub-boxes as inputs for the ML algorithm analyses, specifically by cutting 1/2 of the simulation box instead of using sub-boxes with a size of 1/4, we can expect an improved accuracy in distinguishing clustering DE.This improvement is attributed to the inclusion of a greater range of length scales in the analyses.However, employing larger sub-boxes also leads to larger data sets, which in turn increases the computational cost required for the algorithms to effectively learn from such extensive data.In Figure 5, we evaluate the accuracy of each ML algorithm using subboxes with a size equal to 1/2 that of the main boxes.For the large simulation box L = 2048 Mpc/h which corresponds to ℓ 1 2 ∈ [8, 1024] Mpc/h and k 1 2 ∈ [0.006, 0.654] h/Mpc (see Table 1), the CNN algorithm achieves 95% accuracy at wDE ≈ −0.96, while the RF algorithm reaches this level of accuracy at wDE ≈ −0.92.Additionally, the CNN algorithm achieves 95% accuracy at wDE ≈ −0.94 and wDE ≈ −0.85 for 64] Mpc/h), respectively, while the RF algorithm is only able to achieve this level of accuracy at wDE ≈ −0.86 and wDE ≈ −0.81.
In summary, our results indicate that the CNN algorithm outperforms the RF algorithm in detecting the equation of state (wDE) of clustering DE across all scales.However, it is important to note that the accuracy of both methods decreases as the simulation box size decreases to the values considered in this study.The decrease in accuracy can be attributed to multiple factors, including the scale ranges present in the training set and how the effect of clustering DE manifests at different scales.Large variations among different seed numbers, as shown by the presence of large error bars at small scales in Figure 2, can complicate the learning process for algorithms trained on data from a small box size.Furthermore, the complexity of structures also plays a role, becoming more evident at smaller scales due to non-linear matter clustering.It is worth noting that the difference in matter power spectra of clustering DE and ΛCDM is nearly constant2 at larger scales and decays at small scales (k ≥ 0.9 h/Mpc) as shown in Figure 2.This observation provides an explanation for the results we have obtained.2019), the impact of the speed of sound on the matter power spectrum is negligible when wDE is sufficiently close to −1.The matter power spectrum's lack of sensitivity to the speed of sound poses an intriguing question about whether the CNN algorithm can enhance the detectability of clustering DE speed of sound by exploring different cs values while keeping wDE fixed.Furthermore, the utilization of the RF algorithm on matter power spectra provides a more systematic analysis of the impact of the speed of sound on the matter power spectrum.By adopting these approaches, there is potential to enhance the constraints on c 2 s in comparison to conventional methods.We present the results of our investigation on distinguishing clustering DE with different speeds of sound values compared to the case where c 2 s = 1 while keeping the equation of state wDE constant.The results are summarised in Table 2 (for wDE = −0.7),Table 3 (for wDE = −0.8),and Table 4 (for wDE = −0.9).Moreover, we consider c 2 s ∈ {10 −2 , 10 −4 , 10 −8 } and three different simulation box sizes: L = 2048 Mpc/h, L = 512 Mpc/h and L = 128 Mpc/h along with sub-box sizes that are 1/4 and 1/2 of the main boxes.The corresponding length scales and wavenumbers for each sub-box choice are summarised in Table 1.

Detecting
In the tables, we demonstrate the results for L = 2048 Mpc/h and L = 512 Mpc/h cases, as we did not observe any improvement in the accuracy of the CNN and RF algorithms for all the c 2 s values when the box size L = 128 Mpc/h for both sub-box cuts (1/2 and 1/4) considered.In other words, when considering scales of ℓ 1 2 ∈ [0.5, 64] Mpc/h or ℓ 1 4 ∈ [0.5, 32] Mpc/h, the ML algorithms were unable to distinguish between cases where c 2 s ̸ = 0 and the case where c 2 s = 1, even when c 2 s was sufficiently small.The challenge in distinguishing the case with c 2 s = 10 −8 , where the power ratio in Figure 3 exhibits a large difference at relevant scales (k 1 2 ∈ [0.098, 10.882] h/Mpc), can be attributed to the considerable variation in the data sets caused by the choice of a small box size.This variation is evident from the presence of large error bars at small scales in the figure.Moreover, the complexity of the underlying structures adds to the challenge of identifying patterns arising from the speed of sound.c 2 s = 10 −2 In the case where c 2 s = 10 −2 , the sound horizon defined as ℓs = H0/cs is ℓs ≈ 1878 Mpc/h, or equivalently ks ≈ 0.0033 h/Mpc.Dark energy perturbations decay within scales ℓ ≤ ℓs, and the ratio of dark energy perturbations to matter perturbations drops significantly on scales below the sound horizon (Hassani et al. 2019).Consequently, even for the largest simulation box and largest sub-box cut, which corresponds to a length scale span of ℓ 1 2 ∈ [8, 1024] < ℓs, we expect a similar effect on matter structures as in the case where c 2 s = 1.This makes it difficult for the RF and CNN algorithms to distinguish the effect of the speed of sound.Our results in Table 2, Table 3, and Table 4 for both the CNN and RF algorithms, across all simulation box sizes and subbox cuts, confirm that the ML algorithms cannot distinguish c 2 s = 10 −2 from c 2 s = 1.
c 2 s = 10 −4 In this case, the sound horizon is ℓs ≈ 188 Mpc/h and ks ≈ 0.033 h/Mpc.According to Table 1, in both cuts of box sizes with L = 512 Mpc/h, the dark energy perturbations have almost decayed.As a result, it becomes challenging to distinguish this case from c 2 s = 1 for this specific simulation box choice.According to the results presented in Table 2, Table 3, and Table 4, both the RF and CNN algorithms achieve an accuracy close to 50% for c 2 s = 10 −4 case and L = 512 Mpc/h, with a slight improvement when w = −0.7 in Table 2.However, when considering larger length scale spans, as shown in the tables for L = 2048 Mpc/h, we observe an improvement in accuracies, particularly when employing a sub-box cut of 1/2.This larger sub-box cut covers larger scales and captures more effects from dark energy perturbations.As indicated in Table 2, the accuracy of the CNN and RF algorithms can reach 95% and 71%, respectively, for the case of c 2 s = 10 −4 , L = 2048 Mpc/h, and a 1/2 sub-box cut.The accuracy decreases significantly when using a 1/4 sub-box cut.Moreover, the accuracy depends on the value of the equation of state wDE, and when wDE is closer to −1, the accuracy decreases as shown in Table 3, where the accuracy of the CNN and RF decreases to 82% and 60%, respectively.While when wDE = −0.9 in Table 4, the accuracy reaches ∼ 50%, and c 2 s = 10 −4 becomes undetectable by both ML algorithms.
c 2 s = 10 −8 When c 2 s = 10 −8 , the sound horizon is ℓs ≈ 1.88 Mpc/h and ks ≈ 3.34 h/Mpc.The RF and CNN algorithms exhibit improved accuracy compared to other sound speeds, even when L = 512 Mpc/h and a 1/4 cut is considered, as shown Table 2 and Table 3.However, when wDE = −0.9, the cases are indistinguishable, and the accuracy drops to approximately 50% (Table 4).Similar to other speeds of sound, as wDE approaches −1, the accuracy decreases, and using a sub-box cut of 1/2 leads to increased accuracy.Notably, when considering a 1/2 cut for w = −0.8 in Table 3, the CNN achieves an enhanced accuracy of 82%, while the RF fails to effectively distinguish the cases.This difference between the RF and CNN outcomes may be attributed to differences in their classification power and/or the information encoded in the data.It is generally expected that the density snapshots provide additional higher-order statistical information compared to the power spectra alone.However, in order to understand the exact causes of this significant difference, further investigations are necessary, particularly focusing on the impact of higher-order statistics in the data.
In short, the detection of the speed of sound can be challenging, particularly as the equation of state wDE approaches −1.Even with the CNN algorithm using 3D density snapshots, accurate detection remains difficult.However, our results indicate that employing larger sub-boxes and extending the length scale spans consistently enhances the accuracy of both ML algorithms.Specifically, when considering our largest simulation box size of L = 2048 Mpc/h, both ML algorithms demonstrate improved performance in distinguishing cases with different c 2 s values.Furthermore, we observe that the accuracy further improves as the speed of sound cs becomes smaller and deviates from cs = 1.

CONCLUSION AND DISCUSSION
In this study, we examined how well machine learning algorithms, namely the Convolutional Neural Network (CNN) and Random Forest (RF), can detect clustering DE.We investigated different equation of state (wDE) and speed of sound (cs) parameters using numerical N -body simulations, specifically the gevolution and k-evolution codes, to train and test the algorithms.For the detection of clustering DE, we first focused on the accuracy of the ML algorithms in distinguishing different values of wDE from the cosmological constant scenario (wDE = −1).We trained the CNN algorithm on 3D matter density snapshots extracted from sub-boxes of varying sizes, while the RF algorithm was trained on the power spectra computed from the sub-boxes.We evaluated the performance of the ML algorithms across a range of scales, from linear to non-linear.Our results showed that the CNN algorithm outperforms the RF algorithm in detecting clustering DE across almost all scales.For the largest simulation box size of L = 2048 Mpc/h, with a sub-box size of 1/4 the main box, the CNN algorithm achieved an accuracy of 95% in distinguishing clustering DE at wDE ≈ −0.96, while the RF algorithm reached this level of detectability at wDE ≈ −0.84.As the simulation box size decreased, the accuracy of both algorithms decreased.
We also investigated the impact of the speed of sound (cs) on the detectability of clustering DE.Our results showed that distinguishing different values of c 2 s from the case where c 2 s = 1 was challenging for both the CNN and RF algorithms.This difficulty was particularly pronounced when considering small simulation sizes.The accuracy of the ML algorithms was highly dependent on the length scales considered.Larger sub-boxes, which covered a broader range of scales, generally led to improved accuracy in detecting the speed of sound.However, even with the use of 3D density snapshots in the CNN algorithm, accurate detection of c 2 s remained difficult when wDE approached −1.Interestingly, for the cases where w = −0.7 and w = −0.8,we achieved successful detection of the speed of sound effect for speeds c 2 s ≤ 10 −4 when using a large simulation box size of L = 2048 Mpc/h, particularly with a sub-box cut of 1/2.Moreover, we observed an approximate 20% improvement in accuracy when employing the CNN compared to the RF algorithm.
In conclusion, our study demonstrated the potential of ML algorithms, particularly the CNN and RF algorithms, in detecting clustering DE.Furthermore, we studied the detectability of clustering DE through power spectra using the RF algorithm, which provides us a systematic study.The CNN algorithm consistently outperformed the RF algorithm across different scales and parameter ranges.The improved accuracy of the CNN algorithm could be due to the inclusion of higher-order statistics in the density maps, in contrast to the limited two-point statistics offered by the power spectrum.Further investigations would be valuable in determining whether higher-order statistics in addition to two-point statistics is the primary factor behind the CNN algorithm's performance or if other factors play a role.
In this study, we focused on investigating the detectability of clustering DE by varying only the parameters wDE and cs, while keeping all other cosmological parameters fixed.It is important to note that the degeneracy between the clustering DE parameters and the cosmological parameters could be im-portant, but it falls beyond the scope of our current paper.For a comprehensive analysis, it would be ideal to explore the entire parameter space, including parameters such as As, ns, Ωm, wDE, cs, and others, to evaluate how well the machine is capable of detecting clustering DE parameters in the presence of variations in all parameters.However, conducting such investigations would be computationally expensive.
To effectively use ML algorithms with data from cosmological surveys, such as galaxy catalogues, it is crucial to train them using realistic datasets like mock catalogues generated from snapshots of N -body simulations.This provides a better representation of actual observations compared to training only on matter density snapshots.By training the ML models on these simulated datasets, we can study how well they detect the parameters wDE and cs in real observational data.This methodology gives us valuable insights into the possibility of detecting clustering DE in future cosmological surveys and opens doors for future advancements in the field.a progressive approach in our analyses.We start with a simple model and gradually increase its complexity, allowing it to capture the data more accurately.In our CNN architecture, we use rectified linear units (ReLU) as the activation function (Agarap 2019).Each convolution layer has eight output filters to capture different patterns and properties.The final layer is fully connected and employs the Softmax function for the classification task.It consists of one node corresponding to the two cosmological models we classify in the output layer.Additionally, we incorporate L2 regularization (Cortes et al. 2012) with a regularisation value of 0.01 for both kernel and bias.We apply a 50% dropout (Srivastava et al. 2014) after the first dense layer to prevent overfitting during training.For a detailed description of the architecture, refer to Table B1.There are various performance measures that can be used to assess the training progress of our ML algorithms.One such measure is the loss function, which quantifies the difference between the algorithm's current output and the expected output.For our CNN algorithm, we utilise the binary cross-entropy loss function, which is commonly used in training binary classifiers (Ruby & Yendapalli 2020).
In the CNN architecture, our goal is to minimise the binary cross-entropy loss.To achieve this, we employ the Adam optimiser (Kingma & Ba 2017) with a learning rate of 0.0002 and a beta parameter (β1) of 0.9.Additionally, we implement two checkpoints in the model.
as an essential tool for analysing classification errors in our study.The CM provides insights into the performance of each ML algorithm utilised.In the context of our work in subsection 3.1, the CM allows us to determine the accuracy of classifying examples as clustering DE or ΛCDM models.Specifically, the CM consists of four categories: True Positive (TP), True Negative (TN), False Positive (FP), and False Negative (FN).A TP corresponds to an accurately classified clustering DE, while a TN signifies a correctly classified ΛCDM model.Conversely, an FP occurs when a ΛCDM model is mistakenly identified as clustering DE, and an FN arises when the ML algorithm fails to recognize clustering DE cases, incorrectly classifying them as ΛCDM models.The CM for our analysis is presented below, displaying the performance of the ML algorithms in distinguishing clustering DE from ΛCDM:

Figure 1 .
Figure 1.We provide a schematic representation of our ML scheme for classifying clustering DE and the cosmological constant scenario, as discussed in subsection 3.1.This scheme includes the CNN and RF algorithms trained on sub-boxes of both cosmological constant and clustering DE with w DE = −0.98 and c 2 s = 1.The schematic illustrates the steps of extracting sub-boxes, calculating their power spectra as input for the RF algorithm, and assessing the accuracy of the algorithms using a confusion matrix.

Figure 3 .
Figure 3.The matter power spectra ratio, showing the comparison between different values of c 2 s and w DE with the case where w DE remains constant and c 2 s = 1, is illustrated in the figure.The vertical lines indicate the range of wavenumbers covered (k min 1/2 (L), k max 1/2 (L)) by sub-boxes obtained through a half-cut of the main simulation box, denoted by the 1/2 sub-index.The sizes of the main simulation boxes (L) are indicated within parentheses in units of Mpc/h.The error bars are computed by considering variations over the ratios of simulations with different seed numbers.

Figure 4 .Figure 5 .
Figure 4.The detection accuracy of the RF (in red) and CNN (in blue) algorithms for clustering DE across a range of equation of state parameters, w DE .The horizontal purple line represents the 95% accuracy threshold.The data points on the plot correspond to different sizes of simulation boxes, allowing us to assess the performance of the RF and CNN algorithms across a range of scales.The analysis includes sub-boxes that are one-fourth (1/4) of the size of the main simulation box.The vertical green line on the plot represents the ΛCDM limit at w DE = −1.
(L)) by sub-boxes obtained through a halfcut of the main simulation box, denoted by the 1/2 sub-index.The sizes of the main simulation boxes (L) are indicated within parentheses, expressed in units of Mpc/h.The error bars are computed by considering variations of P w,c 2 s =1 (seed)/P ΛCDM (seed) computed for different seed numbers.
Clustering Dark Energy: c 2 sThe speed of sound, represented by cs is another key parameter for characterising clustering DE.It introduces a sound horizon for DE, where perturbations in DE decay on scales smaller than the sound horizon and grow on larger scales.So, small speeds of sound may result in non-linear clustering of DE.As discussed inHassani et al. (

Table 2 .
The accuracy of the CNN and RF algorithms is evaluated for different box sizes: L = 512 Mpc/h on the left and L = 2048 Mpc/h on the right, while keeping the equation of state fixed at w DE = −0.7,and varying the values of c 2 s .The accuracies are calculated by comparing the results with the reference case of c 2 s = 1.Additionally, different sub-box sizes, representing 1/4 and 1/2 of the main boxes, are considered.The table also displays the corresponding length spans (ℓ 1

Table A1 .
The accuracy of different ML algorithms for a fixed spatial resolution and sub-box size of 64 Mpc/h where the length scale span ℓ ∈ [1, 64] Mpc/h is fixed.We consider the clustering DE with w DE = −0.8,c 2 s = 1 and the ΛCDM scenarios.In the last row, a simulation was performed with an initial grid size of N grid = 512 3 and subsequently degraded to N grid = 256 3 .

Table B1 .
The architecture of the CNN algorithm The first is the ModelCheckpoint, which saves the best model during training based on a specified metric.The second is the ReduceLROnPlateau, which reduces the learning rate when there is no progress in training.Moreover, we incorporate the EarlyStopping callback, which stops the training process if the validation accuracy does not improve.To monitor the training progress, we record the loss function and accuracy computed on the training data after each epoch.We also calculate the validation loss and accuracy on a separate validation dataset.These metrics provide insights into the performance of the model during training and help us track its progress.