<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: hkad98</title>
    <description>The latest articles on Forem by hkad98 (@hkad98).</description>
    <link>https://forem.com/hkad98</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F764446%2F1c4e6b51-408b-4f6d-9728-b6335f09db29.JPG</url>
      <title>Forem: hkad98</title>
      <link>https://forem.com/hkad98</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/hkad98"/>
    <language>en</language>
    <item>
      <title>How To Automate Your Statistical Data Analysis</title>
      <dc:creator>hkad98</dc:creator>
      <pubDate>Mon, 21 Mar 2022 12:26:41 +0000</pubDate>
      <link>https://forem.com/hkad98/how-to-automate-your-statistical-data-analysis-2556</link>
      <guid>https://forem.com/hkad98/how-to-automate-your-statistical-data-analysis-2556</guid>
      <description>&lt;p&gt;During my university studies, I attended a course named Statistical Data Analysis. I was excited about this course because it taught me all the basic statistical analysis methods such as (non-)linear regression, ANOVA, MANOVA, LDA, PCA, etc. However, I never learned about the business application of these methods. During the course, we worked with several examples. Still, all the samples were CSV datasets, mainly from &lt;a href="https://www.kaggle.com/"&gt;Kaggle&lt;/a&gt;. I wondered how I could perform some statistical analysis over a database such as Postgres and automate it by creating a pipeline, trying all possible combinations of columns, yielding a result saying which models are better than others. Years passed by, and now I am here to present you with my proof of concept of statistical data analysis automation.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Statistical Method Will Be Automated?
&lt;/h2&gt;

&lt;p&gt;For my proof of concept, I chose to automate linear regression. I decided on linear regression because I consider this method an entry point to statistical data analysis. Since linear regression has assumptions, I can easily demonstrate how I imagine sorted models from the best to the worst.&lt;/p&gt;

&lt;h3&gt;
  
  
  What Is Linear Regression, and What Are Its Assumptions?
&lt;/h3&gt;

&lt;p&gt;Simple linear regression is a statistical method that models a relationship between two continuous variables, and if there are multiple variables, we call it multiple linear regression. The most straightforward approach for linear regression is ordinary least squares estimation. &lt;/p&gt;

&lt;p&gt;We can extend ordinary least squares estimation with regularization. One of the most known regularizations are shrinkage methods (ridge, lasso). They are called shrinkage methods because they force estimated parameters to be shrunken towards zero, producing reduced variance. &lt;/p&gt;

&lt;p&gt;Let's remind ourselves what the goal of the ordinary least squares estimation method is.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DAecvc3m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l9ivg3tr01x8779nxm7x.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DAecvc3m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l9ivg3tr01x8779nxm7x.jpg" alt="The visualized goal of the ordinary least squares estimation method." width="880" height="567"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the figure above, we can see points (red) in space and a line (black). We define residual (s values) as a distance between the predicted value and a point. The ordinary least squares estimation method aims to find the line (line coefficients – intercept and slope), which minimizes the sum of squared s.&lt;/p&gt;

&lt;p&gt;In this article, I will consider four assumptions of linear regression. I cannot forget to mention that some method modifications are not that strict about assumptions and can demand them in a weaker form than standard linear regression.&lt;/p&gt;

&lt;h4&gt;
  
  
  The four assumptions for linear regression are:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Linearity

&lt;ul&gt;
&lt;li&gt;the existence of a linear relationship between variables&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Homoscedasticity

&lt;ul&gt;
&lt;li&gt;constant variance – residuals are independent of the    predictor variables&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Independence

&lt;ul&gt;
&lt;li&gt;residuals are independent of each other&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Normality

&lt;ul&gt;
&lt;li&gt;residuals are normally distributed&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What Technologies Am I Going To Use?
&lt;/h2&gt;

&lt;p&gt;I'm enthusiastic about Python, so my programming language of choice is evident. I chose to use &lt;a href="https://www.gooddata.com/developers/cloud-native/?utm_medium=blogpost&amp;amp;utm_source=dev.to&amp;amp;utm_campaign=gooddata_statistical_data_analysis_21032022&amp;amp;utm_content=autor_jan"&gt;GoodData.CN&lt;/a&gt; – cloud-native analytics platform. &lt;/p&gt;

&lt;p&gt;The reasons why I chose GoodData.CN are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.gooddata.com/blog/how-build-logical-data-models-scale-analytical-applications/?utm_medium=blogpost&amp;amp;utm_source=dev.to&amp;amp;utm_campaign=gooddata_statistical_data_analysis_21032022&amp;amp;utm_content=autor_jan"&gt;The logical data model (LDM)&lt;/a&gt; holds information about attributes, facts, datasets (tables), and their relationships.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://help.gooddata.com/doc/enterprise/en/dashboards-and-insights/maql-analytical-query-language/get-started-with-using-maql-to-write-metrics/?utm_medium=blogpost&amp;amp;utm_source=dev.to&amp;amp;utm_campaign=gooddata_statistical_data_analysis_21032022&amp;amp;utm_content=autor_jan"&gt;Metrics&lt;/a&gt; – GoodData.CN allows users to create, store and reuse metrics. Metrics are aggregation functions that do not require any joins and adapt to the context, thanks to LDM.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.gooddata.com/blog/python-sdk-for-composable-and-reusable-analytics/?utm_medium=blogpost&amp;amp;utm_source=dev.to&amp;amp;utm_campaign=gooddata_statistical_data_analysis_21032022&amp;amp;utm_content=autor_jan"&gt;GoodData's Python SDK&lt;/a&gt; allows me to work with LDM, metrics, and access data from GoodData.CN in Python pandas data frame.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--J_-jmVoF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i29gnc9qiaj6pgpkewif.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--J_-jmVoF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i29gnc9qiaj6pgpkewif.png" alt="An example of Logical Data Model" width="880" height="594"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;An example of Logical Data Model&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--i4lrIt8j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s9ru9eym0as18s72wtgh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--i4lrIt8j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s9ru9eym0as18s72wtgh.png" alt="An example of a revenue metric containing another metric order amount showing that we can reuse metrics in other metrics." width="629" height="50"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;An example of a revenue metric containing another metric order amount showing that we can reuse metrics in other metrics.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--j7_uV_N0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vyp3ybrozsthyl7zb1z3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--j7_uV_N0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vyp3ybrozsthyl7zb1z3.png" alt="The figure above shows an example of a pandas data frame containing attribute campaign name, fact price, and metric revenue." width="380" height="157"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The figure above shows an example of a pandas data frame containing attribute campaign name, fact price, and metric revenue.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3faN92Iy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/37khrp092sldx80cxpme.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3faN92Iy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/37khrp092sldx80cxpme.png" alt="Note that metric revenue without any joins is used, and even though facts budget and price are both in different datasets, we get valid results." width="374" height="156"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note that metric revenue without any joins is used, and even though facts budget and price are both in different datasets, we get valid results.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let's Automate Our Statistical Data Analysis
&lt;/h2&gt;

&lt;p&gt;I will now describe my proposed pipeline, and then I shall present my results. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Generate all possible combinations without repetition – triplets consisting of precisely one attribute, metric/fact, and metric/fact. Thanks to the logical data model and Python SDK, this task becomes trivial.  The logical data model gives me information about what attributes, facts, and metrics I can combine.&lt;/li&gt;
&lt;li&gt;For every combination, get a data frame using GoodData Python SDK.&lt;/li&gt;
&lt;li&gt;For every data frame combination, evaluate linear regression assumptions.&lt;/li&gt;
&lt;li&gt;Sort triplets in descending order of the number of valid assumptions.&lt;/li&gt;
&lt;li&gt;Enjoy your analyzed data.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;My proposed pipeline seems quite simple, but the tricky parts are hidden in the details – like what statistical tests are used for assumption validation, thresholds for statistical tests hypothesis, etc. Such details are subject to personal choice.&lt;/p&gt;

&lt;p&gt;In the following section, I will demonstrate how simple it is to implement parts of the pipeline mentioned above.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;content_service&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sdk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;catalog_workspace_content&lt;/span&gt;
&lt;span class="n"&gt;catalog&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;content_service&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get_full_catalog&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;workspace_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Get attributes
&lt;/span&gt;&lt;span class="n"&gt;attributes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;dataset&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;catalog&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;datasets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;attributes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;extend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dataset&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;attributes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Get metrics
&lt;/span&gt;&lt;span class="n"&gt;metrics&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;catalog&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;metrics&lt;/span&gt;

&lt;span class="c1"&gt;# Get facts
&lt;/span&gt;&lt;span class="n"&gt;facts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;dataset&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;catalog&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;datasets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;facts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;extend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dataset&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;facts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see above, using a few lines of code, you can access workspace content – LDM.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Numeric&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
&lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;extend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;metrics&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;extend&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;facts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;combinations&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;set&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;pairs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;itertools&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;combinations&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;pair&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;pairs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;valid_objects&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;content_service&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;compute_valid_objects&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;workspace_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pair&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;valid_objects&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"attribute"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[]):&lt;/span&gt;
        &lt;span class="n"&gt;attribute&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;catalog&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;find_label_attribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="s"&gt;"label/&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;attribute&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;combinations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Triplet&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;attribute&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pair&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using the compute valid objects method, I can find out what other LDM entities I can add to the combination of metric/fact and metric/fact, making a valid combination accessible.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;pandas&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;GoodPandas&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getenv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'HOST'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getenv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'TOKEN'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="n"&gt;df_factory&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pandas&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;data_frames&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;workspace_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;combinations&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;load_combinations&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="n"&gt;columns&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;combinations&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;as_computable_dictionary&lt;/span&gt;
&lt;span class="n"&gt;data_frame&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;df_factory&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;not_indexed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;columns&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code snippet above is an example of getting non-indexed pandas data frames using generated combinations of triplets.&lt;/p&gt;

&lt;p&gt;You can find the code implementing the pipeline above with a script for setting up the GoodData.CN CE environment in the &lt;a href="https://github.com/hkad98/statistical-data-analysis-automation"&gt;GitHub repository&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--C-3zh4MI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ddirceri0lxfzwg0hoj1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--C-3zh4MI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ddirceri0lxfzwg0hoj1.png" alt="The figure above shows the linear regression returned as the best one with all four passed assumptions." width="640" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The figure above shows the linear regression returned as the best one with all four passed assumptions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UcZ9qPQ1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dcsoian4v14tkd17n46b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UcZ9qPQ1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dcsoian4v14tkd17n46b.png" alt="The above example shows the worst linear regression with only one valid assumption - independence." width="640" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above example shows the worst linear regression with only one valid assumption - independence.&lt;/p&gt;

&lt;h3&gt;
  
  
  Potential Simplifications
&lt;/h3&gt;

&lt;p&gt;I would like to address the possible simplifications I noted during the creation of the code. The first simplification arises from generating combinations. In my example, I can omit combinations containing the primary keys of datasets because their role is purely technical.&lt;br&gt;
Furthermore,  I found that generating combinations is time-consuming for massive databases, so I propose to create combinations only once, store them using Pickle, for example, and then just load them. I added an option to cache combinations in the code in GitHub, so I encourage you to cache combinations when trying it out. When you add a new column to your database, you can regenerate your combinations or just generate combinations related to the new column and add them to existing ones.&lt;br&gt;
My last noted simplification is related to assumptions validation. Three out of four assumptions need residuals, which means we require the existence of a linear regression model. Linearity assumption does not require residuals, so we do not have to create a linear regression model. We can validate this assumption using, e.g. Pearson’s correlation coefficient, and if linearity is not satisfied, we can omit other assumptions and speed up the pipeline.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;If you've come this far, I thank you for reading my article about my proof of concept. I consider statistical data analysis essential for data analysis, and I find it convenient to simplify work using the right technologies and automate the research process. I welcome any feedback concerning this topic, and I will be pleased to hear from you if you come across any solutions to similar problems. I encourage you to check out my proof of concept and to try it for yourself.&lt;/p&gt;

&lt;p&gt;I look forward to seeing your modifications of statistical tests. &lt;/p&gt;

</description>
      <category>python</category>
      <category>computerscience</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>MAQL: Powerful Analytical Querying Made Simple</title>
      <dc:creator>hkad98</dc:creator>
      <pubDate>Mon, 29 Nov 2021 16:05:28 +0000</pubDate>
      <link>https://forem.com/hkad98/maql-powerful-analytical-querying-made-simple-1eik</link>
      <guid>https://forem.com/hkad98/maql-powerful-analytical-querying-made-simple-1eik</guid>
      <description>&lt;p&gt;If you are reading this you may know what MAQL is and want to know more or, alternatively, you may have never heard of MAQL but are keen to find out what it is. Either way, welcome and let me introduce you to MAQL.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is MAQL?
&lt;/h2&gt;

&lt;p&gt;MAQL is GoodData's analytical querying language, which simplifies querying over multidimensional data and provides predefined functions that allow simple queries, such as simple aggregations, or more complex functions like skewness or kurtosis.&lt;/p&gt;

&lt;p&gt;You’re probably thinking that the same thing can be done using SQL, and you would be right, but MAQL makes it significantly easier. When you are carrying out multidimensional analysis using SQL, you have to be careful about querying and joining your data. MAQL, on the other hand, uses a semantic model that allows you to omit many of these things, making querying much easier. With this in mind, let me first tell you what the semantic model is and why it is essential.&lt;/p&gt;

&lt;h2&gt;
  
  
  Semantic Model
&lt;/h2&gt;

&lt;p&gt;When a database is being modeled, the first thing which is done is a conceptual model. The conceptual model is there for database architects to understand the structure of the database. MAQL uses this knowledge as well and calls it a semantic model. &lt;a href="https://www.gooddata.com/blog/deliver-efficient-data-consumption-semantic-model/?utm_medium=blogpost&amp;amp;utm_source=dev.to&amp;amp;utm_campaign=gooddatacn_maql_29112021&amp;amp;utm_content=autor_jan"&gt;The semantic model&lt;/a&gt; is the same as the conceptual model for database architects: It gives MAQL the power and knowledge of the database, its attributes, and relationships between tables. The inside is very crucial for efficient and user-friendly querying of data. &lt;/p&gt;

&lt;h2&gt;
  
  
  MAQL Syntax and Usage
&lt;/h2&gt;

&lt;p&gt;MAQL syntax is similar to SQL syntax but with one main difference; MAQL does away with keywords like FROM and JOIN. Why? Due to the presence of the semantic model, they are simply not required: The semantic model has the knowledge of relations and the occurrence of attributes. Let's take a look at an example.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Qd740e0J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ci9rtcp69vifq2usig10.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Qd740e0J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ci9rtcp69vifq2usig10.gif" alt="Image description" width="716" height="570"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gAamZ0CH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8ihisukozjq6ddcyz3fg.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gAamZ0CH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8ihisukozjq6ddcyz3fg.gif" alt="Image description" width="712" height="570"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As can be seen in the above, MAQL significantly simplifies the querying process. All we need to know with MAQL is what we want to do: The rest is up to the MAQL engine, which uses the semantic model to query our data. A MAQL query is called a metric; an aggregation producing a single number.&lt;/p&gt;

&lt;p&gt;Another crucial advantage of MAQL is that you can specify the "ground truth analysis" (i.e., single source of truth) of your data by creating and storing metrics. Stored metrics can be reused in other metrics, as can be seen below. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wQ7z9wFG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/97waul5tpd2l456alp21.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wQ7z9wFG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/97waul5tpd2l456alp21.png" alt="Image description" width="880" height="513"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another use for stored metrics is to provide results to other data consumers such as data analysts, data scientists, data engineers, and the relevant data consumption tools. The main idea can be seen in the picture below, where these tools access stored metrics using API, and all data consumers are using the same "ground truth analysis". This approach prevents the creation of duplicate analysis and simplifies work for data consumers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ej0tkWNl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oqkf369e5z9hd9u53109.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ej0tkWNl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oqkf369e5z9hd9u53109.png" alt="Image description" width="880" height="463"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Ready to Learn More?
&lt;/h2&gt;

&lt;p&gt;MAQL forms part of the &lt;a href="https://www.gooddata.com/headless-bi/?utm_medium=blogpost&amp;amp;utm_source=dev.to&amp;amp;utm_campaign=gooddatacn_maql_29112021&amp;amp;utm_content=autor_jan"&gt;headless BI&lt;/a&gt; family, with headless BI providing consistent, real-time insights to an array of different data consumers. To try out MAQL and see it in action, simply pull the GoodData.CN docker image. For help and further info, see the &lt;a href="https://www.gooddata.com/developers/cloud-native/doc/?utm_medium=blogpost&amp;amp;utm_source=dev.to&amp;amp;utm_campaign=gooddatacn_maql_29112021&amp;amp;utm_content=autor_jan"&gt;MAQL documentation&lt;/a&gt;, step-by-step tutorials, community forum, and community slack channel. I think it is worth trying it on demo data which are included in the docker image or your own data or any data you can find. Get as creative as you like.&lt;/p&gt;

</description>
      <category>sql</category>
      <category>analytics</category>
      <category>docker</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
