# Interactive Graph Stream Analytics in Arkouda
## 5 Single Pass Regression Analysis Stream Model
### Real-World Graph Distribution Based Regression Model  
Instead of developing different specific methods for different graph analysis problems, we propose a general regression method to generate the approximate solution based on the results of different sub-sketches. One essential objective of a stream model is generating an accurate estimation based on the query results from its sketch. The basic idea of our method is to exploit the real-world graph distribution information to build an accurate regression model. Then we can use the regression model to generate approximate solutions for different queries. Specifically, for the triangle counting problem, when we know the exact number of triangles in each sub-sketch (see Table 1), the key problem is how we can estimate the total number of triangles. To achieve user-required accuracy for different real-world applications, our method exploits the features of real-world graph distributions. Many sparse networks--social networks in particular--have an important property; their degree distribution follows the power law distribution. Normal distributions are often used in the natural and social sciences to represent real-valued random variables whose distributions are not known. So, we develop two regression models for the two different graph degree distributions. We let \(E_{H},E_{M},E_{T}\) be the exact number of triangles in the Head, Mid and Tail sub-sketches. The exact triangle counting algorithm is given in Section 5.2. For normal degree distribution graphs, we assume that the total number of triangles has a linear relationship with the number of triangles in each sub-sketch. We take \(E_{H},E_{M},E_{T}\) as three randomly sampled results of the original stream graph to build our multivariate linear regression model. \(TC_{Normal}\) is the estimated number of triangles and the regression model is given in Equation (1). \[TC_{Normal}=a\times E_{H}+b\times E_{M}+c\times E_{T}. \tag{1}\] \begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Graph Name** & **Shrinking Factor** & **Head** & **Mid** & **Tail** & **Exact** \\ \hline delaunay\_n10 & 4 & 98 & 138 & 150 & 2047 \\ \hline delaunay\_n10 & 8 & 63 & 72 & 80 & 2046 \\ \hline delaunay\_n10 & 16 & 35 & 41 & 41 & 2044 \\ \hline delaunay\_n10 & 32 & 20 & 12 & 16 & 2043 \\ \hline delaunay\_n10 & 64 & 3 & 3 & 10 & 2042 \\ \[PERSON]\_n11 & 4 & 195 & 302 & 294 & 4104 \\ \[PERSON]\_n11 & 8 & 95 & 151 & 144 & 4103 \\ \[PERSON]\_n11 & 16 & 62 & 71 & 63 & 4101 \\ \[PERSON]\_n11 & 32 & 26 & 32 & 29 & 4100 \\ \[PERSON]\_n11 & 64 & 12 & 24 & 14 & 4009 \\ \[PERSON]\_n12 & 4 & 258 & 607 & 575 & 8215 \\ \[PERSON]\_n12 & 8 & 163 & 306 & 293 & 8214 \\ \[PERSON]\_n12 & 16 & 90 & 139 & 147 & 8212 \\ \[PERSON]\_n12 & 32 & 52 & 78 & 76 & 8211 \\ \[PERSON]\_n12 & 64 & 51 & 42 & 32 & 8210 \\ \[PERSON]\_n13 & 4 & 646 & 1160 & 1197 & 16,442 \\ \[PERSON]\_n13 & 8 & 335 & 598 & 588 & 16,441 \\ \[PERSON]\_n13 & 16 & 187 & 297 & 304 & 16,439 \\ \[PERSON]\_n13 & 32 & 108 & 144 & 153 & 16,438 \\ \[PERSON]\_n13 & 64 & 68 & 62 & 81 & 16,437 \\ \[PERSON]\_n14 & 4 & 1099 & 2356 & 2299 & 32,921 \\ \[PERSON]\_n14 & 8 & 507 & 1205 & 1184 & 32,920 \\ \[PERSON]\_n14 & 16 & 269 & 568 & 579 & 32,918 \\ \[PERSON]\_n14 & 32 & 135 & 294 & 303 & 32,917 \\ \[PERSON]\_n14 & 64 & 93 & 144 & 137 & 32,916 \\ \[PERSON]\_n15 & 4 & 2085 & 4571 & 4585 & 65,872 \\ \[PERSON]\_n15 & 8 & 943 & 2335 & 2320 & 65,871 \\ \[PERSON]\_n15 & 16 & 486 & 1140 & 1159 & 65,869 \\ \[PERSON]\_n15 & 32 & 265 & 568 & 580 & 65,868 \\ \[PERSON]\_n15 & 64 & 137 & 282 & 299 & 65,867 \\ \[PERSON]\_n16 & 4 & 4168 & 9648 & 9510 & 131,842 \\ \[PERSON]\_n16 & 8 & 2170 & 4666 & 4601 & 131,841 \\ \[PERSON]\_n16 & 16 & 1063 & 2387 & 2348 & 131,839 \\ \[PERSON]\_n16 & 32 & 569 & 1174 & 1169 & 131,838 \\ \[PERSON]\_n16 & 64 & 326 & 576 & 580 & 131,837 \\ \[PERSON]\_n17 & 4 & 8154 & 18,873 & 18,938 & 263,620 \\ \[PERSON]\_n17 & 8 & 4012 & 9543 & 9501 & 263,619 \\ \[PERSON]\_n17 & 16 & 2132 & 4595 & 4773 & 263,617 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Sketch Triangle Number.