extfieldsofstudy:
Physics
Environmental Science

s2fieldsofstudy:
Computer Science
Environmental Science

text:
Determination of size of urban particulates from occluded scattering patterns using deep learning and data augmentation

Deep learning has shown recent key breakthroughs in enabling particulate identification directly from scattering patterns. However, moving such a detector from a laboratory to a real-world environment means developing techniques for improving the neural network robustness. Here, a methodology for training data augmentation is proposed that is shown to ensure neural network accuracy, despite occlusion of the scattering pattern by simulated particulates deposited on the detector’s imaging sensor surface. The augmentation approach was shown to increase the accuracy of the network when identifying the geometric Y-dimension of the particulates by ∼62% when 1000 occlusions of size ∼5 pixels were present on the scattering pattern. This capability demonstrates the potential of data augmentation for increasing accuracy and longevity of a particulate detector operating in a real-world environment.

Introduction
One of the current global health challenges is particulate matter (PM) pollution, since it is associated with sicknesses that include respiratory disorders, cardiovascular diseases and cancer [1][2][3][4][5][6]. The current World Health Organisation (WHO) guidelines for PM concentrations over a 24-hour period are 25 μg m −3 for PM2.5 (<2.5 μm), and 50 μg m −3 for PM10 (<10 μm particulates), with annual guidelines of 10 μg m −3 and 20 μg m −3 , respectively [7]. A dataset complied in 2016 by the WHO for annual mean concentrations of PM2.5 and PM10 across the globe, shows that particulate levels can vary from city to city, with 100 μg m −3 of PM2.5 and 187 μg m −3 of PM10 recorded in Jaipur, India (2012 data), 29 μg m −3 of PM2.5 and 64 μg m −3 of PM10 recorded in Santiago, Chile (2014 data), and 15 μg m −3 of PM2.5 and 21 μg m −3 of PM10 recorded in Southampton, UK (2013) [8]. Critically, however, there is no evidence that there is a 'safe' lower concentration of PM below which effects do not occur and, indeed, good evidence to the contrary [9]. Mean concentrations mask significant spatiotemporal variation due to proximity to local sources, variation in local and background sources, the effects of meteorological factors such as wind direction, rain and sunlight, and seasonality. There is, therefore, a clear need for PM concentrations in areas of the UK and elsewhere to be monitored. The effect of such pollution on individuals can vary, with some people being more vulnerable to certain types of pollution than others [10]. The size, type and number of particulates can also lead to different adverse health effects. For example, individual and aggregated particulates larger than PM10, such as pollen grains (some species can have grains as large as ∼150 μm in geometrical size [11]), can lead to allergic rhinitis [12], and PM10 can cause respiratory problems [13,14]. PM2.5 particulates can travel deep into the lungs, being associated with incidence and exacerbations of respiratory diseases such as chronic obstructive pulmonary disease (COPD) and asthma [15][16][17], as well as lung cancer [18], while also being shown to exert effects on the cardiovascular system including myocardial infarction and stroke [19]. Ultrafine particulates (<0.1 μm), a subset of PM2.5, which generally comprise a relatively small proportion of the airborne mass of fine PM, but the majority by number concentration, is thought to be able to translocate from the lung into the circulation, and indeed, ultrafine particles from ambient sources have been observed in both brain tissue and cardiac tissue [20,21], and also appear able to cross the placenta [22]. Importantly, as cohort studies expand in size, and as methods to determine individual exposures improve, associations with further diseases affecting additional body systems are being uncovered [3]. Although these associations are not currently established as being causal relationships, and mechanisms are not fully understood, it is becoming ever more likely that the cardiovascular and respiratory systems are not the sole sites of the deleterious effects of airborne PM [23]. Since particle size and morphology may play an important role in governing interactions with the human body, being able to characterise such airborne particulates is important in determining its prevalence and potential health effects, while also giving possible clues as to its source [24]. Conventional methods for monitoring the size and chemical composition of particulates involve using large filter traps that collect the particulates onto a filter substrate, often with an upstream size selective inlet of impaction surface to allow size fractionation. These filters then need to be postprocessed, usually with lab-based scientific apparatus. Collection of particulates in this way clearly reduces the temporal resolution of readouts, and may be labour intensive. A simple optical detector that can determine the size of particulates, whilst also being robust in the environment in which it is sensing, is therefore highly desirable.
The light scattered from a single particulate encodes information regarding its size and shape, as well as chemical constituents and refractive index [25][26][27][28]. As shown in the images in the experimental setup figure (see figure 1), individual urban particulates are highly variable in shape and size, and consequently the scattering patterns generally also vary significantly. Extraction of particulate parameters via theoretical methods, such as Mie theory [29] can be difficult, due to the complexity of such particulates, and hence alternative methods need to be investigated. In recent years, convolutional neural networks [30][31][32] have shown notable ability for the classification of objects in images [33][34][35][36][37] and, importantly for this work, they have shown the capability to identify spherical and non-spherical objects directly from their scattering patterns [38][39][40]. Since a neural network's accuracy is dependent on the data used in training the neural network, methods for improving accuracy include data augmentation, which has been shown to improve neural network accuracy in classifying image and acoustic data [41][42][43].
Here, we demonstrate the ability to determine the geometric size of the urban particulates from their scattering patterns (see figure 2) captured using a complementary metal-oxide-semiconductor (CMOS) camera sensor, via the use of convolutional neural networks. In addition, in optical particle sensing, there is an inherent risk that particulates may deposit on the sensor or on optical surfaces, thereby reducing their ability to collect the scattered light. This is particularly problematic in optical dust detectors, which often rely on just a single photodiode. We demonstrate here that the combination of a camera sensor and a convolutional neural network offers robustness against partial sensor occlusion -potentially improving longevity and accuracy in the event of sensor surface contamination. Current methods for robustness include 'pixel attacking' and 'adversarial attacking' techniques [44,45] that been used in various forms to test and fool neural networks in order to find their weakness, and thus enable improvements in network training. For practical purposes, we use zero intensity Figure 1. (a) Illustration of experimental setup for using a camera to collect scattering patterns from urban particulates deposited onto a microscope slide, when the particulates were illuminated with red, green and blue laser light. The particulates were also imaged for reference and sample alignment. (b) Scattering patterns and, corresponding SEM images and optical images for three different particulates (upper, middle and lower rows, respectively). The SEM images include labels of the maximum X-dimension and maximum Y-dimension of the particulates. pixels of various sizes on the scattering pattern images to simulate particulates deposited on the camera sensor that occlude light from being incident on the sensor's pixels. We improve the accuracy for determining particulate sizes from occluded scattering patterns by augmenting the neural network training data via inclusion of occluded scattering pattern images, hence demonstrating the potential for improving the detector's robustness when applied in a real-world environment.

Sample fabrication
Urban particulate matter (NIST 1648a urban particulate matter, collected from St. Louis, MO in 1977MO in -1978 was deposited onto a soda-lime glass slide (25 mm by 75 mm, 1 mm thick). A total of 112 particles were imaged using a Zeiss Evo scanning electron microscope (SEM) and their geometrical sizes, ranging from 3 μm to 45 μm, were determined (maximum X-dimension and maximum Y-dimension in microns, as shown in figure 1(b)). The sizes were chosen for ease of imaging and alignment, with the smallest size limited by the need for sufficient signal to be obtained from the scattering in our experimental setup. Figure 1 shows an illustration of the experimental setup, showing light from lasers operating at 450 nm, 520 nm and 635 nm wavelengths, with <1 mW average powers, being focussed using an Olympus SLMPLN 50× objective (NA=0.35, WD=18 mm) onto the surface of the urban particulate-covered glass slide, with a focus diameter of ∼30 μm. Three lasers were used rather than one since the light scattered from an object is wavelength-dependent, and so the more wavelengths of light used, the more information that is available to the neural networks to allow for more accurate training and prediction, as demonstrated in our previous work [46]. When the lasers illuminated the particulates, the resulting scattered light was collected by a CMOS colour camera sensor (Thorlabs DCC1645C, 1280×1024 pixels, 3.60 μm square pixels, 5 ms integration time), that was placed 3 mm further along the laser axis from the illuminated particulates. The sample was mounted onto a 3-axis stage (25 mm maximum travel and 10 μm resolution) to allow alignment of the particulates within the laser beam. To produce in-situ images of the particulates, allowing identification and cross-referencing with the SEM data, they were illuminated with the aid of a white light source (50 W white halogen lamp), and a beam splitter was used to direct the back-reflected light onto a CMOS camera sensor (Thorlabs, DCC3260C, 1936×1216 pixel, 5.86 μm square pixels, 5 ms integration time). In total, 113 scattering patterns were recorded, as this included images of scattering patterns from the 112 particulates and 1 image when no particulates were present.

Neural networks
In total, 3 neural networks were trained using, (1) X-dimension data, (2) Y-dimension data, (3) augmented Y-dimension data. For each network, an 18-layer regression convolutional neural network that included 4 convolutional layers (3×8, 3×16, 3×32, 3×32), each with a stride of [1 1], each followed by a batch normalisation layer and a ReLu (rectified linear activation function) layer, was used. The dataset of training and validation scattering pattern images (total of 92 images) was split in a ratio of 90:10, and the remaining 21 particulate scattering patterns that were not present in the training data and included sizes that were not present in the training dataset (5-25 μm), were used for testing. The input images were cropped to 1024×1024 pixels and resized to 256×256 pixels, prior to being fed into the neural network. The output consisted of a single number likely between 0 and 45 microns (since this was the range of the values in the training and test data). A learning rate of 0.0002 and a dropout of 0.2 was used, along with a minibatch size of 30, and validation frequency of 5. All networks were trained for 30 epochs using an NVIDIA RTX 2080 graphics processing unit (GPU), taking <5 min each. Initially, the training data and the test data used were unedited, then to test the ability of the neural network to determine particulate sizes for scattering patterns with occlusions on, single zero intensity (black) pixels numbering from 1 to 1000 were randomly added to the test images (5 times each particulate size, for averaging purposes) and the outputs determined. Also, 5 and 10-pixel diameter sized black circles in numbers totalling 1, 10, 100 and 1000 were randomly added to each scattering pattern in the test data and the outputs were again determined. Finally, to improve the ability to determine the particulate sizes from occluded scattering patterns, a neural network was trained using a dataset that was augmented with randomly positioned occlusions. This was achieved by randomly adding 1, 5 and 10-pixel diameter black circles to the training data, in numbers totalling 1, 10, 100 and 1000. Again, the neural network was tested using the same scattering patterns as those tested with the neural network trained without augmented data, for ease of comparison.

Results and discussion
The capability of neural networks to determine the size of urban particulates from images of their scattering patterns is shown in figure 3. Evident from the plot is that both the (a) X-dimension and (b) Y-dimension were able to be determined, with an RMSE of 4.00 μm and 3.27 μm, respectively.
To test the robustness of the network against variations in the scattering pattern via occlusion of pixels, figure 4(a) demonstrates the capability of the neural network to predict Y-dimension of particulates, when the scattering pattern images have 1, 10, 100 and 1000 random single pixels set to zero intensity. The figure shows the difference in the predicted size compared to the original prediction for each sized particulate (5-25 μm). Even for 100 occlusions, the neural network output remains within ∼0.2-microns of the original prediction. The network only produces an error of greater than 1 micron when 1000 pixels were occluded. Interestingly, the larger the size of the particulate from which the light is scattered, the less the effect of the occluded pixels. This can perhaps be understood by looking at the scattering patterns and the maximum neural network activation of the final ReLu layer (normalised to 1) from the highest error size (8 μm) and the lowest error size (25 μm), see figure 4(b). For 8 μm, the maximum activation (red region), which shows what region is strongly triggering the neural network to categorise a certain number, is much smaller than that for the 25 μm scattering pattern. This indicates that 1000 pixels could have a greater effect on the features that allow for determination of the 8 μm scattering pattern, and thus lead to greater error in determining its size. The results above demonstrate that the network was robust up to the case of 10 single pixel occlusions, and even for 100 single pixel occlusions, the error was ∼0.2 μm. With the optical arrangement used here, occlusion of a single pixel would require a particle of ∼15 μm in geometric diameter, however, many particulates, as shown in the SEM images, can be larger. Indeed, smoke and cement dust can be as large as 100 s of microns and smaller particulates can also agglomerate in the environment to form larger sensor occlusions. Therefore, if sensing larger particulates (>15 μm) was desired or agglomeration could not be mitigated inside the detector, understanding how size determination is affected by larger particulates or agglomerates occluding the sensor and whether errors can be mitigated using methods such as data augmentation, would be invaluable.
The size of the occlusions was increased to 5 and 10-pixel diameters on the test images, which were the fed into the neural network. Following this, the training data were augmented to include 1, 5 and 10-pixel diameter occlusions to train a neural network that could perform with greater accuracy on occluded data. Initially, the neural network trained on augmented data was tested on 1-pixel diameter occlusions, in order to determine if the network was suitable for improving on the accuracy of the predictions presented in figure 4. The results are shown in figure 5, and it is evident that the difference between the predicted sizes for particulate scattering patterns without occlusions and with, has decreased across all sizes. For example, the prediction for 5 μm sized particulate has decreased in error from ∼1.6 μm (figure 4(a)) down to ∼0.3 μm. Figure 6(a) shows the absolute difference in the root-mean-square error (RSME) of the prediction of all the test particulates (5-25 μm) for the original neural network and augmented neural network for 1, 5 and 10-pixel diameter occlusion, numbering 1, 10, 100 and 1000, compared with the RMSE of the prediction of all the test scattering patterns with 0 occlusions. It is evident from the plot in figure 6(a) that the network trained with augmented data produced a reduction in the RMSE of the prediction of size by approximately 0.5 microns for 100 5-pixel diameter occlusions, and at least 1 micron for 10-pixel diameter occlusions totalling 100 and 1000. Figure 6(b) shows examples of scattering patterns occluded with 100 of 1, 5 and 10-pixel diameter circles. For 5-pixel diameter occlusions at numbers totalling 1000 on each pattern, a reduction of an RMSE of over 3 microns was achieved, meaning a potential 62% increase in accuracy could be achieved even when 20% of the sensor's surface is occluded.
The results demonstrate that such a detector could remain accurate for longer via the use of adequate training of a neural network, if the number of particulates deposited and occluding the sensor's surface increases over time. For example, it was found in one study that dry deposition of an upper limit of 64 μm diameter particulates (∼5-pixels diameter occlusions in our work) onto measurement surfaces in the northern Lake Tahoe Basin (USA) could occur at a flux of ∼10 6 m −2 day −1 [47], which in this work, corresponds to ∼10 sensor −1 day −1 , where our sensor area is approximately 4 mm 2 . Thus, as an example, if such deposition conditions occurred on the detector's sensor surface described in this work, and if a detector's acceptable error from the original Y-dimension was <3 μm, for 5-pixel diameter occlusions in figure 6(a), this would mean that only 100 occluding particulates could be deposited before the error increases beyond the acceptable limit, which corresponds to ∼30 days. However, if the training data were augmented, then the detector could last for an extra 900 occluding particulates (∼240 days), without the need for cleaning the detector's sensor surface.
To further improve the accuracy of the neural network, training with augmented data that included occlusions with non-spherical shapes could further aid in increasing the precision of a detector, since, as shown in the SEM images of urban particulates, such objects can be non-symmetric in shape. In addition, incorporating information about the 3-dimensional structure of the particulates into neural network training could perhaps aid in accuracy of a single dimension, owing to the extra information provided, while using a smaller laser beam could lead to less of the unscattered beam saturating pixels on the camera sensor and allow light scattered from smaller particulates to be adequately recorded. Figure 5. Difference between the prediction, using the neural network trained on augmented data, of the Y-dimension for particulate scattering patterns without occlusions and scattering patterns containing occlusions with single pixel width, for a total of 1 (red), 10 (green), 100 (blue) and 1000 (yellow) randomly located occlusion pixels.

Conclusion
In conclusion, we have shown that neural networks can determine the size of urban particulate matter from their scattering pattern obtained when the particulates were illuminated using 3 different laser beams. In addition, we have shown a neural network's robustness to single pixel occlusion of the sensor and have shown that when the regions of the scattering pattern become significantly occluded, either via numbers or sizes, augmenting the training data to include such occlusions can improve the accuracy of a neural network in determining the size of particulates. In practice, another algorithm (e.g. summing up all zero intensity pixels) could be used to determine the amount of contamination on the sensor to inform the user to clean such a sensor, in order to aid in avoiding incorrect predictions of particulate matter sizes. The results here demonstrate a key technique for enabling deep learning to be applied to sensing technologies for deployment in the real-world environment.


Adversarial Robustness of Streaming Algorithms through Importance Sampling

In this paper, we introduce adversarially robust streaming algorithms for central machine learning and algorithmic tasks, such as regression and clustering, as well as their more general counterparts, subspace embedding, low-rank approximation, and coreset construction. For regression and other numerical linear algebra related tasks, we consider the row arrival streaming model. Our results are based on a simple, but powerful, observation that many importance sampling-based algorithms give rise to adversarial robustness which is in contrast to sketching based algorithms, which are very prevalent in the streaming literature but suffer from adversarial attacks. In addition, we show that the well-known merge and reduce paradigm in streaming is adversarially robust. Since the merge and reduce paradigm allows coreset constructions in the streaming setting, we thus obtain robust algorithms for $k$-means, $k$-median, $k$-center, Bregman clustering, projective clustering, principal component analysis (PCA) and non-negative matrix factorization. To the best of our knowledge, these are the first adversarially robust results for these problems yet require no new algorithmic implementations. Finally, we empirically confirm the robustness of our algorithms on various adversarial attacks and demonstrate that by contrast, some common existing algorithms are not robust. (Abstract shortened to meet arXiv limits)

Introduction
Robustness against adversarial attacks have recently been at the forefront of algorithmic design for machine learning tasks [GSS15, CW17, AEIK18, MMS + 18, TSE + 19]. We extend this line of work by studying adversarially robust streaming algorithms.
In the streaming model, data points are generated one at a time in a stream and the goal is to compute some meaningful function of the input points while using a limited amount of memory, typically sublinear in the total size of the input. The streaming model is applicable in many algorithmic and ML related tasks where the size of the data far exceeds the available storage. Applications of the streaming model include monitoring IP traffic flow, analyzing web search queries [LMV + 16], processing large scientific data, feature selection in machine learning [HZZ21, GRB + 19, WYWD10], and estimating word statistics in natural language processing [GDC12] to name a few. Streaming algorithms have also been implemented in popular data processing libraries such as Apache Spark which have implementations for streaming tasks such as clustering and linear regression [ZXW + 16a].
In the adversarial streaming model [MBN + 17, BMSC17, AMYZ19, BY20, BJWY20, HKM + 20, WZ20, ABD + 21, KMNS21], an adversary gives an algorithm a sequence of adaptively chosen updates u 1 , . . . , u n as a data stream. The goal of the algorithm is to compute or approximate some predetermined function for every prefix of the adversarial stream, but the adversary may generate future updates based on previous outputs of the algorithm. In particular, the adversary may gradually learn the random bits internally used by an algorithm to manipulate dependencies in the input. This is especially problematic as many important problems in the streaming model require randomized algorithms, as they are known to not admit any deterministic algorithms that use sublinear space. Studying when adversarially robust streaming algorithms are possible is an important problem in lieu of recent interest in adversarial attacks in ML with applications to adaptive data analysis.
Formally, we define the model as a two-player game between a streaming algorithm StreamAlg and a source Adversary of adaptive and adversarial input to StreamAlg. At the beginning of the game, a fixed query Q is determined and asks for a fixed function for the underlying dataset implicitly defined by the stream. The game then proceeds in rounds, and in the t-th round, (1) Adversary computes an update u t ∈ [n] for the stream, which depends on all previous stream updates and all previous outputs from StreamAlg.
(2) StreamAlg uses u t to update its data structures D t , acquires a fresh batch R t of random bits, and outputs a response A t to the query Q.
(3) Adversary observes and records the response A t .
The goal of Adversary is to induce StreamAlg to make an incorrect response A t to the query Q at some time t ∈ [m] throughout the stream.
Related Works. Adversarial robustness of streaming algorithms has been an important topic of recent research. On the positive note, [BJWY20] gave a robust framework for estimating the L p norm of points in a stream in the insertion-only model, where previous stream updates cannot later be deleted. Their work thus shows that deletions are integral to the attack of [HW13]. Subsequently, [HKM + 20] introduced a new algorithmic design for robust L p norm estimation algorithms, by using differential privacy to protect the internal randomness of algorithms against the adversary. Although [WZ20] tightened these bounds, showing that essentially no losses related to the size of the input n or the accuracy parameter ε were needed, [KMNS21] showed that this may not be true in general. Specifically, they showed a separation between oblivious and adversarial streaming in the adaptive data analysis problem.
[BY20] showed that sampling is not necessarily adversarially robust; they introduce an exponentially sized set system where a constant number of samples, corresponding to the VC-dimension of the set system, may result in a very unrepresentative set of samples. However, they show that with an additional logarithmic overhead in the number of samples, then Bernoulli and or reservoir sampling are adversarially robust. This notion is further formalized by [ABD + 21], who showed that the classes that are online learnable requires essentially sample-complexity proportional to the Littlestone's dimension of the underlying set system, rather than VC dimension. However, these sampling procedures are uniform in the sense that each item in the stream is sampled with the same probability. Thus the sampling probability of each item is oblivious to the identity of the item. By contrast, we show the robustness for a variety of algorithms based on non-oblivious sampling, where each stream item is sampled with probability roughly proportional to the "importance" of the item.

Our Contributions
Our main contribution is a powerful yet simple statement that algorithms based on non-oblivious sampling are adversarially robust if informally speaking, the process of sampling each item in the stream can be viewed as using fresh randomness independent of previous steps, even if the sampling probabilities depend on previous steps.
Let us describe, very informally, our meta-approach. Suppose we have an adversarial stream of elements given by u 1 , . . . , u n . Our algorithm A will maintain a data structure A t at time t which updates as the stream progresses. A will use a function g(A t , u t ) to determine the probability of sampling item u t to update A t to A t+1 . The function g measures the 'importance' of the element u t to the overall problem that we wish to solve. For example, if our application is k-means clustering and u t is a point far away from all previously seen points so far, we want to sample it with a higher probability. We highlight that even though the sampling probability for u t given by g(A t , u t ) is adversarial, since the adversary designs u t and previous streaming elements, the coin toss performed by our algorithm A to keep item u t is independent of any events that have occurred so far, including the adversary's actions. This new randomness introduced by the independent coin toss is a key conceptual step in the analysis for all of the applications listed in Figure 1.
Contrast this to the situation where a "fixed" data structure or sketch is specified upfront. In this case, we would not be adaptive to which inputs u t the adversary designs to be "important" for our problem which would lead us to potentially disregard such important items rendering the algorithm ineffective.
As applications of our meta-approach, we introduce adversarially robust streaming algorithms for two central machine learning tasks, regression and clustering, as well as their more general counterparts, subspace embedding, low-rank approximation, and coreset construction.
We show that several methods from the streaming algorithms "toolbox", namely merge and reduce, online leverage score sampling, and edge sampling are adversarially robust "for free." As a result, existing (and future) streaming algorithms that use these tools are robust as well. We discuss our results in more detail below and provide a summary of our results and applications in Figure 1.
Theorem 1.1 (Merge and reduce is adversarially robust) Given an offline ε-coreset construction, the merge and reduce framework gives an adversarially robust streaming construction for an ε-coreset with high probability.
For regression and other numerical linear algebra related tasks, we consider the row arrival streaming model, in which the adversary generates a sequence of row vectors a 1 , . . . , a n in d-dimensional vector space. For t ∈ [n], the t-th prefix of the stream induces a matrix A t ∈ R t×d with rows a 1 , . . . , a t . We denote this matrix as A t = a 1 • . . . • a t and define κ to be an upper bound on the largest condition number 1 of the matrices A 1 , . . . , A n . Theorem 1.2 (Row sampling is adversarially robust) There exists a row sampling based framework for adversarially robust streaming algorithms that at each time t ∈ [n]: ε 2 log n log κ rows (spectral approximation/subspace embedding/linear regression/generalized regression).
(2) Outputs a matrix M t such that for all rank k orthogonal projection matrices P ∈ R d×d , while sampling O dkκ ε 2 log n log 2 κ rows (projection-cost preservation/low-rank approximation). ( Finally, we show that our analysis also applies to algorithms for graph sparsification for in which edges are sampled according to their "importance". Define κ as the ratio of the largest and the smallest cut sizes in G (see Section 4 and Supplementary Section C for exact details). Theorem 1.3 Given a weighted graph G = (V, E) with |V | = n whose edges e 1 , . . . , e m arrive sequentially in a stream, there exists an adversarially robust streaming algorithm that outputs a 1 ± ε cut sparsifier with O κ 2 n log n ε 2 edges with probability 1 − 1/ poly(n).
Sketching vs Sampling Algorithms. A central tool for randomized streaming algorithms is the use of linear sketches. These methods maintain a data structure f such that after the (i + 1)-th input x i , we can update f by computing a linear function of x i . Typically, these methods employ a random matrix. For example, if the input consists of vectors, sketching methods will use a random matrix to project the vector into a much smaller dimension space. In [HW13], it was proved no linear sketch can approximate the L 2 -norm within a polynomial multiplicative factor against such an adaptive adversary. In general, streaming algorithms that use sketching are highly susceptible to the type of attack described in [HW13] where the adversary can effectively 'learn' the kernel of the linear function used and send inputs along the kernel. For example, if an adversary knows the kernel of the random matrix used to project the input points, then by sending points that lie on the kernel of the matrix as inputs, the adversary can render the whole streaming algorithm useless.
One the other hand, we employ a different family of streaming algorithms that are based on sampling the input rather than sketching it. Surprisingly, this simple change allows one to automatically get many adversarially robust algorithms either "for free" or without new algorithmic overheads. For more information, see Section 1.1. We emphasize that while our techniques are not theoretically sophisticated, we believe its power lies in its simple message that sampling is often superior to sketching for adversarial robustness. In addition to downstream algorithmic and ML applications, this provides an interesting separation and trade-offs between the two paradigms; for non adversarial inputs sketching often gives similar or better performance guarantees for many tasks [BYKS01]. {C 1,j }: C 1,1 C 1,2 C 1,3 C 1,4 {C 2,j }: {C 3,j }: C 3,1 Fig. 2: Merge and reduce framework. Each C 1,j is an O(ε/ log n)-coreset of the corresponding partition of the substream and each C i,j is an ε-coreset of C i−1,2j−1 and C i−1,2j for i > 1.

Merge and Reduce
We show that the general merge and reduce paradigm is adversarially robust. Merge and reduce is widely used for the construction of a coreset, which provides dimensionality reduction on the size of an underlying dataset, so that algorithms for downstream applications can run more efficiently: Definition 2.1 (ε coreset) Let P ⊂ X be a set of elements from a universe X, z ≥ 0, ε ∈ (0, 1), and (P, dist, Q) be a query space. Then a subset C equipped with a weight function w : P → R is called an ε-coreset with respect to the query space (P, dist, Q) if The study of efficient offline coreset constructions for a variety of geometric and algebraic problems forms a long line of active research. For example, offline coreset constructions are known for linear regression, low-rank approximation, L 1 -subspace embedding, k-means clustering, k-median clustering, k-center, support vector machine, Gaussian mixture models, M -estimators, Bregman clustering, projective clustering, principal component analysis, k-line center, j-subspace approximation, and so on. Thus, our result essentially shows that using the merge and reduce paradigm, these offline coreset constructions can be extended to obtain robust and accurate streaming algorithms. The merge and reduce paradigm works as follows. Suppose we have a stream p 1 , . . . , p n of length n = 2 k for some integer k, without loss of generality (otherwise we can use a standard padding argument to increase the length of the stream). Define C 0,j = p j for all j ∈ [n]. Consider k levels, where each level i ∈ [k] consists of n 2 i coresets C i,1 , . . . , C i,n/2 i and each coreset C i,j is an ε 2k -coreset of C i−1,2j−1 and C i−1,2j . Note that this approach can be implemented efficiently in the streaming model, since each C i,j can be built immediately once C i−1,2j−1 and C i−1,2j are constructed, and after C i,j is constructed, then both C i−1,2j−1 and C i−1,2j can be discarded. For an illustration of the merge and reduce framework, see Figure 2, though we defer all formal proofs to the supplementary material. Using the coresets of [BDM + 20], Theorem 1.1 gives the following applications: Theorem 2.2 There exists a merge-and-reduce row sampling based framework for adversarially robust streaming algorithms that at each time t ∈ [n]: ε 2 log 4 n log κ rows (spectral approximation/subspace embedding/linear regression/generalized regression).
(2) Outputs a matrix M t such that for all rank k orthogonal projection matrices P ∈ R d×d , while sampling O k ε 2 log 4 n log 2 κ rows (projection-cost preservation/low-rank approximation). ( Using coresets of [HV20], then Theorem 1.1 also gives applications for (k, z)-clustering such as k-median for z = 1 and k-means for z = 2. Moreover, [LK17] noted that constructions of [FL11] give coresets for Bregman clustering, which handles µ-similar Bregman divergences such as the Itakura-Saito distance, KL-divergence, Mahalanobis distance, etc.
Theorem 2.3 There exists a merge-and-reduce importance sampling based framework for adversarially robust streaming algorithms that at each time t: (1) Outputs a set of centers that gives a (1 + ε)-approximation to the optimal (k, z)-clustering, k-means clustering (z = 2), and k-median clustering (z = 1), while storing O 1 ε 2z+2 k log 2z+2 n log k log k log n ε points.
(2) Outputs a set of centers that gives a (1 + ε)-approximation to the optimal k-Bregman clustering, while storing O 1 ε 2 dk 3 log 3 n points. Using the sensitivity bounds of [VX12a, VX12b] and the coreset constructions of [BFL16], then Theorem 1.1 also gives applications for the following shape fitting problems: Theorem 2.4 There exists a merge-and-reduce importance sampling based framework for adversarially robust streaming algorithms that at each time t: (1) Outputs a set of lines that gives a (1 + ε)-approximation to the optimal k-lines clustering, while storing (2) Outputs a subspace that gives a (1 + ε)-approximation to the optimal dimension j subspace approximation, while storing O d ε 2 g(d, j)k g(d,j) log 4 n points of R d , for a fixed function g(d, j).
(3) Outputs a set of subspaces that gives a (1 + ε)-approximation to the optimal (j, k)-projective clustering, , for a set of input points with integer coordinates.
Adversarially robust approximation algorithms for Bayesian logistic regression, Gaussian mixture models, generative adversarial networks (GANs), and support vector machine can be obtained from Theorem 1.1 and coreset constructions of [HCB16, FKW19, SZG + 20, TBFR20]; a significant number of additional applications of Theorem 1.1 using coreset constructions can be seen from recent surveys on coresets, e.g., see [LK17,Fel20]. The merge-and-reduce framework also has applications to a large number of other problems such as finding heavy-hitters [MG82] or frequent directions [GLPW16] and in various settings, such as the sliding window model [DGIM02], time decay models [BLUZ19] or for at-the-time or back-in-time queries [SZP + 21].

Adversarial Robustness of Subspace Embedding and Applications
We use [n] to represent the set {1, . . . , n} for an integer n > 0. We typically use bold font to denote vectors and matrices. For a matrix A, we use A −1 to denote the Moore-Penrose inverse of A. We first formally define the goals of our algorithms: Problem 3.1 (Spectral Approximation) Given a matrix A ∈ R n×d and an approximation parameter We note that linear regression is a well-known specific application of spectral approximation.
Problem 3.2 (Projection-Cost Preservation) Given a matrix A ∈ R n×d , a rank parameter k > 0, and an approximation parameter ε > 0, the goal is to find a matrix M ∈ R m×d with m n such that for all rank k orthogonal projection matrices P ∈ R d×d , Note if M is a projection-cost preservation of A, then its best low-rank approximation can be used to find a projection matrix that gives an approximation of the best low-rank approximation to A. Problem 3.3 (Low-Rank Approximation) Given a matrix A ∈ R n×d , a rank parameter k > 0, and an approximation parameter ε > 0, find a rank k matrix M ∈ R n×d such that for a matrix A denotes the best rank k approximation to A.
Problem 3.4 (L 1 -Subspace Embedding) Given a matrix A ∈ R n×d and an approximation parameter We consider the general class of row sampling algorithms, e.g., [CMP16, BDM + 20]. Here we maintain a L p subspace embedding of the underlying matrix by approximating the online L p sensitivities of each row as a measure of importance to perform sampling. For more details, see Algorithm 1.
Algorithm 1 Row sampling based algorithms, e.g., [CMP16, BDM + 20] Input: A stream of rows a 1 , . . . , a n ∈ R d , parameter p > 0, and an accuracy parameter ε > 0 Output: Remark 3.6 We note that for p = 1, a constant fraction approximation to any online L p sensitivity τ i such that τ i > 1 poly(n) can be computed in polynomial time using (offline) linear programming while for p = 2, τ i is equivalent to the online leverage score of a i , which has the closed form expression a i (A i A i ) −1 a i , which can be approximated by a i (M M) −1 a i , conditioned on M being a good approximation to A i−1 when a i is in the span of M. Otherwise, τ i takes value 1 when a i is not in the span of M.
Lemma 3.7 (Adversarially Robust L p Subspace Embedding and Linear Regression) Given ε > 0, p ∈ {1, 2}, and a matrix A ∈ R n×d whose rows a 1 , . . . , a n arrive sequentially in a stream with condition number at most κ, there exists an adversarially robust streaming algorithm that outputs a (1 + ε) spectral approximation with high probability. The algorithm samples O d 2 κ 2 ε 2 log n log κ rows for p = 2 and O d 2 λ 2 ε 2 log 2 n log κ rows for p = 1, with high probability, where λ is a ratio between upper and lower bounds on A 1 .
We also show robustness of row sampling for low-rank approximation by using online ridge-leverage scores. Together, Lemma 3.7 and Lemma 3.8 give Theorem 1.2.
Lemma 3.8 (Adversarially Robust Low-Rank Approximation) Given accuracy parameter ε > 0, rank parameter k > 0, and a matrix A ∈ R n×d whose rows a 1 , . . . , a n arrive sequentially in a stream with condition number at most κ, there exists an adversarially robust streaming algorithm that outputs a (1 + ε) low-rank approximation with high probability. The algorithm samples O kdκ 2 ε 2 log n log κ rows with high probability.

Graph Sparsification
In this section, we highlight how the sampling paradigm gives rise to an adversarially robust streaming algorithm for graph sparsification. First, we motivate the problem of graph sparsification. Massive graphs arise in many theoretical and applied settings, such as in the analysis of large social or biological networks.
A key bottleneck in such analysis is the large computational resources, in both memory and time, needed. Therefore, it is desirable to get a representation of graphs that take up far less space while still preserving the underlying "structure" of the graph. Usually the number of vertices is much fewer than the number of edges; for example in typical real world graphs, the number of vertices can be several orders of magnitude smaller than the number of edges (for example, see the graph datasets in [RA15]). Hence, a natural benchmark is to reduce the number of edges to be comparable to the number of vertices.
The most common notion of graph sparsification is that of preserving the value of all cuts in the graph by keeping a small weighted set of edges of the original graph. More specifically, suppose our graph is G = (V, E) and for simplicity assume all the edges have weight 1. A cut of the graph is a partition of V = (C, V \ C) and the value of a cut, Val G (C), is defined as the number of edges that cross between the vertices in C and V \ C. A graph H on the same set of vertices as V is a sparsifier if it preserves the value of every cut in G and has a few number of weighted edges. For a precise formulation, see Problem 4.1.
In addition to being algorithmically tractable, this formulation is natural since it preserves the underlying cluster structure of the graph. For example, if there are two well connected components separated by a sparse cut, i.e. two distinct communities, then the sparsifier according to the definition above will ensure that the two communities are still well separated. Conversely, by considering any cut within a well connected component, it will also ensure that any community remains well connected (for more details, see [SPR11] and references therein). Lastly, graph sparsification has been considered in other frameworks such as differential privacy [EKKL20], distributed optimization [WWLZ18], and even learning graph sparsification using deep learning methods [ZZC + 20]. The formal problem definition of graph sparsification is as follows.
Problem 4.1 (Graph Sparsification) Given a graph weighted G = (V, E) with |V | = n, |E| = m, and an approximation parameter ε > 0, compute a weighted subgraph H of G on the same set of vertices such that (1) every cut in H has value between 1 − ε and 1 + ε times its value in G: (1 + ε)Val G (C) for all cuts C where Val G (C), Val H (C) denotes the cost of the cut in the graphs G and H respectively and for the latter quantity, the edges are weighted, (2) the number of edges in H is O n log n ε 2 .
Ignoring dependence on ε, there are previous results that already get sparsifiers H with O(n log n) edges [BK96, SS08]. Their setting is when the entire graph is present up-front in memory. In contrast, we are interested in the streaming setting where future edges can depend on past edges as well as revealed randomness of an algorithm while processing the edges.
Our main goal is to show that the streaming algorithm from [AG09] (presented in Algorithm 2 in the supplementary section), which uses a sampling procedure to sample edges in a stream, is adversarially robust, albeit with a slightly worse guarantee for the number of edges. Following the proof techniques of the non streaming algorithm given in [BK96], it is shown in [AG09] that Algorithm 2 outputs a subgraph H such that H satisfies the conditions of Problem 4.1 with probability 1 − 1/ poly(n) where the probability can be boosted by taking a larger constant C. We must show that this still holds true if the edges of the stream are adversarially chosen, i.e., when new edges in the stream depend on the previous edges and the randomness used by the algorithm so far. We thus again use a martingale argument; the full details are given in Supplementary Section C. As in Section 3, we let κ 1 and κ 2 to be deterministic lower/upper bounds on the size of any cut in G and define κ = κ 2 /κ 1 . Theorem 1.3 Given a weighted graph G = (V, E) with |V | = n whose edges e 1 , . . . , e m arrive sequentially in a stream, there exists an adversarially robust streaming algorithm that outputs a 1 ± ε cut sparsifier with O κ 2 n log n ε 2 edges with probability 1 − 1/ poly(n).

Experiments
To illustrate the robustness of importance-sampling-based streaming algorithms we devise adversarial settings for clustering and linear regression. With respect to our adversarial setting, we show that the performance of a merge-and-reduce based streaming k-means algorithm is robust while a popular streaming k-means implementation (not based on importance sampling) is not. Similarly, we show the robustness superiority of a streaming linear regression algorithm based on row sampling over a popular streaming linear regression implementation and over sketching.
Streaming k-means In this adversarial clustering setting we consider a series of point batches where all points except those in the last batch are randomly sampled from a two dimensional standard normal distribution and points in the last batch similarly sampled but around a distant center (see the data points realization in both panels of Figure 3). We then feed the point sequence to StreamingKMeans, the streaming k-means implementation of Spark [ZXW + 16b] the popular big-data processing framework. As illustrated in the left panel of Figure 3, the resulting two centers are both within the origin. Now, this result occurs regardless of the last batch's distance from the origin, implying that the per-sample loss performance of the algorithm can be made arbitrarily large. Alternatively, we used a merge-and-reduce based streaming k-means algorithm and show that one of the resulting cluster centers is at the distant cluster (as illustrated in the right panel of Figure 3) thereby keeping the resulting per sample loss at the desired minimum. Specifically we use Streamkm, an implementation of StreamKM++ [AMR + 12] from the ClusOpt Core library [Mac20]. Streaming linear regression. Similar to the clustering setting, in the adversarial setting for streaming linear regression all batches except the last one are sampled around a constellation of four points in the plane such that the optimal regression line is of −1 slope through the origin (see the leftmost panel of Figure 4). The last batch of points however, is again far from the origin (L, L) such that the resulting optimal regression line is of slope 1 through the origin 2 . We compare the performance of LinearRegression from the popular streaming machine learning library River [MHM + 20] to our own row sampling based implementation of streaming linear regression along the lines of Algorithm 1 and observe the following: Without the last batch of points, both implementations result in the optimal regression line, however, the River implementation reaches that line only after several iterations, while our implementation is accurate throughout (This is illustrated in the second-left panel of Figure 4). When the last batch is used, nevertheless, Algorithm 1 picks up the drastic change and adapts immediately to a line of the optimal slope (the blue line of the second right panel of Figure 4) while the River implementation update merely moves the line in the desired direction (the orange line in that same panel) but is far from catching up. Finally, the rightmost panel of Figure 4) details the loss trajectory for both implementations. While the River loss skyrockets upon the last batch, the loss of Algorithm 1 remains relatively unaffected, illustrating its adversarial robustness.  Note that in both the clustering and linear regression settings above the adversary was not required to consider the algorithms internal randomization to achieve the desired effect (this is due to the local nature of the algorithms computations). This is no longer the case in the following last setting.
Sampling vs. sketching. Finally, we compare the performance of the leverage sampling Algorithm 1 to sketching. In this setting, for a random unit sketching matrix S (that is, each of its elements is sampled from {−1, 1} with equal probability), we create an adversarial data stream A such that its columns are in the null space of S. As a result, the linear regression as applied to the sketched data S · A as a whole is unstable and might significantly differ from the resulting linear regression applied to streamed prefixes of the sketched data. As illustrated in Figure 5, this is not the case when applying the linear regression to the original streamed data A using Algorithm 1. Upon the last batch, the performance of the sketching-based regression deteriorates by orders of magnitude, while the performance of Algorithm 1 is not affected. Moreover, the data reduction factor achieved by leveraged sampling 3 is almost double compared to the data reduction factor achieved by sketching. [BJWY20] Omri Ben-Eliezer, Rajesh Jayaram, David P. Woodruff, and Eylon Yogev. A framework for adversarially robust streaming algorithms.  [LK17]) Given ε > 0 and δ ∈ (0, 1), let P be a set of weighted points, with non-negative weight function µ : P → R ≥0 and let s : P → R ≥0 denote an upper bound on the sensitivity of each point. For S = p∈P µ(p)s(p), let m = Ω S 2 ε 2 d + log 1 δ , where d is the pseudo-dimension of the query space. Let C be a sample of m points from P with replacement, where each point p ∈ P is sampled with probability q(p) = µ(p)s(p) S and assigned the weight µ(p) m·q(p) if sampled. Then C is an ε-coreset of P with probability at least 1 − δ.
We first observe that any streaming algorithm that uses linear memory is adversarially robust because intuitively, it can recompute an exact or approximate solution at each step.
Lemma A.2 Given a set of points P , there exists an offline adversarially robust construction that outputs an ε-coreset of P with probability at least 1 − δ.

Proof :
Given an adversary A, let P = p 1 , . . . , p n be a set of points such that each p i with i ∈ [n] is generated by A, possibly as a function of p 1 , . . . , p i−1 . For example, it may be possible that the points p 1 , . . . , p n/2 are a coreset of some set of points P 1 and the points p n/2+1 , . . . , p n (1) were either generated with full knowledge of p 1 , . . . , p n/2 or (2) are a coreset of a set of points P 2 generated with full knowledge of P 1 . Let s(p) be an upper bound on the sensitivity of each point in P and consider the sensitivity sampling procedure described in Lemma A.1. We would like to sample each point with probability q(p). Each point in C is chosen to be p with probability q(p). However, if our algorithm generates internal randomness to perform this sampling procedure, it may be possible for an adversary to either learn correlations with the internal randomness or even learn the internal randomness entirely (such as the seed of a pseudorandom generator). Thus the choice for each point of C may no longer be independent, so we are no longer guaranteed that the resulting construction is a coreset.
Instead, suppose the randomness used by the algorithm at time i in the sampling procedure is independent of the choices of p 1 , . . . , p i−1 , e.g., the algorithm has access to a source of fresh public randomness at each time in the data stream. Then the algorithm can generate C independent of the choices of p 1 , . . . , p i−1 . Thus by Lemma A.1, C is an ε-coreset of P with probability at least 1 − δ. 2 We emphasize that Lemma A.2 shows that any offline coreset construction is adversarially robust; the example of sensitivity sampling is specifically catered to our applications of the merge and reduce framework to clustering.
We now prove our main statement.
Proof of Theorem 1.1: Let δ = 1 poly(n) and consider an ε-coreset construction with failure probability δ. We prove that the merge and reduce framework gives an adversarially robust construction for an ε-coreset with probability at least 1 − 2nδ. We consider a proof by induction on an input set P of n points, supposing that n = 2 k for some integer k > 0. Observe that C 0,j is a coreset of p j for j ∈ [n] since C 0,j = p j . Let E i be the event that for a fixed i ∈ [k] that C i−1,j is an ε 2k -coreset of C i−1,2j−1 and C i−1,2j for each j ∈ n 2 i−1 . By Lemma A.2, it holds that for a fixed j, C i,j is an ε 2k -coreset of C i−1,2j−1 and C i−1,2j with probability at least 1 − δ. By a union bound over n 2 i−1 possible indices j, we have that for a fixed i, all C i,j are ε 2k -coresets of C i−1,2j−1 and C i−1,2j with probability at least 1 − n 2 i−1 · δ. Thus, Pr [E i+1 ] ≥ 1 − nδ 2 i−1 , which completes the induction. Hence with Pr ∪ k i=0 E i , we have that the cost induced by C k,1 is a 1 + ε 2k k -approximation to the cost induced by P . Since 1 + ε 2k k ≤ e ε/2 ≤ 1 + ε, then C k,1 is an ε-coreset of P with probability with high probability. We define the predictable quadratic variation process of the martingale by . Then for all ε ≥ 0 and σ 2 > 0, and every k ∈ [n], |Y t | > ε and w k ≤ σ 2 ≤ 2 exp − ε 2 /2 σ 2 + Rε/3 .
We first show robustness of our algorithm by justifying correctness of approximation for L p norms.
Lemma B.2 (L p subspace embedding) Suppose ε > 1 n , p ∈ {1, 2}, and C > κ p , where κ is an upper bound on the condition number of the stream. Then Algorithm 1 returns a matrix M such that for all x ∈ R d , for sufficiently large C > (κ 1 /κ 2 ) p . Note for p = 2, we have the upper bound on the condition number κ ≥ κ 1 /κ 2 so it suffices to set C = κ 2 . Since κ p 1 x p p ≤ Ax p p , then we have Thus | Mx p p − Ax p p | ≤ ε Ax p p with probability at least 1 − 1 2 d poly(n) . By a rescaling of ε since p ≤ 2, we thus have that | Mx p − Ax p | ≤ ε Ax p with probability at least 1 − 1 2 d poly(n) . We now show that we can union bound over an ε-net. We first define the unit ball B = {Ay ∈ R n | Ay p = 1}. We also define N to be a greedily constructed ε-net of B. Since balls of radius ε 2 around each point cannot overlap, but must all fit into a ball of radius 1 + ε 2 , then it follows that N has at most 3 ε d points. Therefore, by a union bound for 1 ε < n, we have | My p − Ay p | ≤ ε Ay p for all Ay ∈ N , with probability at least 1 − 1 poly(n) . We now argue that accuracy on this ε-net implies accuracy everywhere. Indeed, consider any vector z ∈ R d normalized to Az p = 1. We shall inductively define a sequence Ay 1 , Ay 2 , . . . such that Az − i j=1 Ay j p ≤ ε i and there exists some constant γ i ≤ ε i−1 with 1 γi Ay i ∈ N for all i. Define our base point Ay 1 to be the closest point to Az in the ε-net N . Then since N is a greedily constructed ε-net, we have that Az − Ay 1 p ≤ ε. Given a sequence Ay 1 , . . . , Ay i−1 such that Ay j p = 1. Thus we inductively define the point Ay i ∈ N so that Ay i is within which completes the induction for time n. 2

B.1 Adversarially Robust Spectral Approximation
We observe that Lemma B.2 provides adversarial robustness for free.
Proof : Let us inspect the proof of Lemma B.2. Observe that since the adversary can observe the past data and the past randomness of Algorithm 1, then the rows a i are random variables that depend on the history and the randomness of the algorithm. In other words, a i is measurable with respect to the sigma algebra generated by a 1 , . . . , a i−1 , B 1 , . . . , B i−1 , C i where B i is the indicator of the event that we sample row a i in Algorithm 1 and C i is the random vector generated by the adversary at step i to create row a i . Denote F i the sigma algebra generated by a 1 , . . . , a i−1 , B 1 , . . . B i−1 , C i . Then a i is measurable with respect to F i . Let us remind that Y j = Y j−1 + X j and let us observe that the definition of X j in Equation (1) can be rewritten as It can be easily checked that This is because Y j−1 , p j , a j are measurable with respect to F j . This implies that in the adversarial setting sequence Y j is a martingale with respect to the filtration F 0 ⊂ F 1 ⊂ · · · ⊂ F n .
The remainder of the proof of Lemma B.2 goes through as is for arbitrary rows a i 's. Thus, the algorithm is indeed adversarially robust.  ) for p = 2. We note that κ is an adversarially chosen parameter, since the rows of the input matrix A are generated by an adversary. One can mitigate possible adversarial space attacks by tracking κ and aborting if log κ exceeds a desired threshold.

Proof of Lemma 3.7:
Algorithm 1 is adversarially robust by Lemma B.3. It remains to analyze the space complexity of Algorithm 1. By Lemma B.3 and a union bound over the n rows in the stream, each row a i is sampled with probability at most 4ατ i , where τ i is the online leverage score of row a i . By Lemma B.4, we have n i=1 τ i = O (d log κ) and we also set α = O dκ ε 2 log n . Let γ > 0 be a sufficiently large constant such that We use a martingale argument to bound the number of rows that are sampled. Consider a martingale U 0 , U 1 , . . . , U n with difference sequence W 1 , . . . , W n , where for j ≥ 1, we set W j = 0 if U j−1 > d 2 γκ log κ ε 2 log n and otherwise if U j−1 ≤ d 2 γκ log κ ε 2 log n, we set We have E [U j |U 1 , . . . , U j−1 ] = U j−1 , then the sequence U 0 , . . . , U n induced by the differences is indeed a valid martingale. Note that intuitively, U n is the difference between the number of sampled rows and n j=1 p j . Since a j is sampled with probability p j ∈ [0, 1], Moreover, we have E [|W j | | U 1 , . . . , U j−1 ] ≤ 1. Thus by Freedman's inequality (Theorem B.1) with σ 2 = n j=1 ατ j ≤ d 2 γκ log κ ε 2 log n and R ≤ 1, Pr |U n | > d 2 γκ log κ ε 2 log n ≤ 2 exp − d 4 γ 2 κ 2 log 2 κ log 2 n/(2ε 4 ) σ 2 + Rd 2 γκ log κ log n/(3ε 2 ) ≤ 1 poly(n) .
Hence we have that with high probability, the number of rows sampled is O 1 ε 2 d 2 κ log κ log n . 2 We remark that the space bounds for Lemma 3.7 could similarly be shown (with constant probability of success) using Markov's inequality though analysis Freedman's inequality provides much higher guarantees in terms of probability of success.
On the other hand, it is not clear how to execute a similar strategy using the Matrix Freedman's Inequality rather than using Freedman's inequality. This is because to obtain the desired spectral bound, we must define a martingale at time j in terms of both the matrix A j and whether the rows a 1 , . . . , a j−1 were previously sampled. However, since A j is itself a function of whether a 1 , . . . a j−1 were previously sampled, the resulting sequence is not a valid martingale.
We first require the following bound on the sum of the online ridge leverage scores, e.g., Theorem 2.12 from [BDM + 20], which results from considering Lemma 2.11 in [BDM + 20] at O (log n) different scales. . . . • a n ∈ R n×d arrive in a stream with condition number at most κ, let λ i = is the best rank k approximation to A i . Let i be the online ridge leverage score of a i with regularization λ i . Then n i=1 i = O (k log n log κ). From Lemma B.5 and a similar argument to Lemma B.2, we also obtain adversarially robust projectioncost preservation and therefore low-rank approximation. Namely, [CMM17, BDM + 20] showed that projectioncost preservation essentially reduces to sampling a weighted submatrix M of A such that Mx 2 2 + λ x 2 2 ∈ (1 ± ε)( Ax 2 2 + λ x 2 2 ) for a ridge parameter λ. Since the online ridge leverage score of each row a i can be rewritten as max x∈R d ai,x 2 +λ x 2 2 Aix 2 2 +λ x 2 2 , then the same concentration argument of Lemma B.2 gives Lemma 3.8.

B.2 Adversarially Robust Linear Regression
We first give the formal definition of linear regression: Problem B.6 (Linear Regression) Given a matrix A ∈ R n×d , a vector b ∈ R n and an approximation parameter ε > 0, the goal is to output a vector y such that Lemma B.7 (Adversarially Robust Linear Regression) Given ε > 0 and a matrix A ∈ R n×d whose rows a 1 , . . . , a n arrive sequentially in a stream with condition number at most κ, there exists an adversarially robust streaming algorithm that outputs a (1 + ε) approximation to linear regression and uses O d 3 ε 2 log 2 n log κ bits of space, with high probability.
Proof : Suppose each row of A arrives sequentially, along with the corresponding entry in b. Let B = A•b so that the effectively, the rows of B arrive sequentially. Note that if M is a spectral approximation to B, for all vectors v ∈ R d+1 . In particular, let w ∈ R d+1 be the vector that minimizes Mv 2 subject to the constraint that the last coordinate of w is 1, and let w = y 1 . Then we have Let z be the vector that minimizes Ax − b 2 and let u = z 1 . Then we have where the last inequality follows from the minimality of w. Thus we have that Ay − b 2 ≤ (1 + O (ε)) Az − b 2 . 2

C Missing Proofs from Section 4
Other Related Works. Note that there is an alternate streaming algorithm for graph sparsification given in [GKK10] which has the same guarantees but is computationally faster. However, we choose to analyze the algorithm of [AG09] since its core argument is sampling based. Nevertheless, it is possible that the algorithm from [GKK10] is also adversarially robust. Lastly, we recall that our model is the streaming model where edges arrive one at a time. There is also related work in the dynamic streaming model (see [KNST19] and references therein) where previously shown edges can be deleted but this is not the scope of our work. The notion of the connectivity of an edge is needed to in the algorithm of [AG09].

Definition C.1 (Connectivity [BK96])
A graph is k-strong connected iff every cut in the graph has value at least k. A k-strong connected component is a maximal node-induced subgraph which is k-strong connected. The connectivity of an edge e is the maximum k such that there exists a k-strong connected component that contains e.
Algorithm 2 Graph sparsification algorithm from [AG09]. Input: A stream of edges e 1 , · · · , e m and an accuracy parameter ε > 0 Output: Sparified graph H 1: H ← ∅ 2: ρ ← C(log n + log m)/ε 2 for sufficiently large constant C > 0 3: for each new edge e do Add e to H with probability p e and weight 1/p e times its original weight 7: return H We begin by providing a brief overview of our proof. The first step is to show that for a cut in G of value c, the same cut in the sparsified graph H has value that concentrates around c. Note that in [AG09], the concentration inequality they obtain depends roughly on exp(−c). In other words, they get a stronger concentration for larger cuts in the original graph. However, their concentration inequality is not valid in our setting since the value c is random. Therefore, we employ a different concentration inequality, namely Freedman's inequality (Theorem Theorem B.1) in conjunction with an assumption about the sizes of cuts in the graph to obtain concentration for a fixed cut. The second step is to use a standard worst-case union bound strategy to bound the total number of cuts with a particular size in the original graph. This uses the standard fact that the number of cuts in a graph that is at most α times the minimum cut is at most n 2α . Then the final result for the property (1) in Problem 4.1 follows by combining the union bound with the previously mentioned concentration inequality. The bound for the total number of edges (condition (2) in Problem 4.1) is a "worst case" calculation in [AG09] so it automatically ports over to our setting. Note that we assume κ 1 and κ 2 to be deterministic lower and upper bounds on the size of any cut in G and define κ to be their ratio. Theorem 1.3 Given a weighted graph G = (V, E) with |V | = n whose edges e 1 , . . . , e m arrive sequentially in a stream, there exists an adversarially robust streaming algorithm that outputs a 1 ± ε cut sparsifier with O κ 2 n log n ε 2 edges with probability 1 − 1/ poly(n).
Proof : We claim through induction the stronger statement that the value C H of any cut in H is a (1 + ε)approximation of the value C G of the corresponding cut in G for all times j ∈ [m] with high probability. Consider a fixed set S ⊆ V and the corresponding cut C = (S, V \ S). Let e 1 , . . . , e m be the edges of the stream in the order that they arrive. We emphasize that e 1 , . . . , e m are possibly random variables given by the adversary rather than fixed edges. For each j ∈ [m], let G j be the graph consisting of the edges e 1 , . . . , e j and let H j be the corresponding sampled weighted subgraph. We abuse notation and define p j := p ej to denote the probability of sampling the edge e j that arrives at time j. We use C (j) G and C (j) H to denote the value of the cut at time j in graphs G and H, respectively. Note that p 1 = 1, so we have H 1 = G 1 for our base case.
We assume the statement holds for all j ∈ [m − 1] and prove it must hold for j = m. We define a martingale Y 0 , Y 1 , . . . , Y m through its difference sequence X 1 , . . . , X m , where for j ≥ 1, we set X j = 0 if C (j−1) H ∈ (1 ± ε)C (4)