Skip to content

Mission 4 - Linear Regressions

Estimated time for completing this mission: 20 mins

Learning Objective

Create regression models in LOGIBLOX using prepared Dataset.

Scenario

You were tasked with creating a simple regression, using the information from the correlation matrix.

BLOX used in this mission:

  • Basics/Start
  • MyData/FinalData
  • Database/ First Rows
  • Database/Group By
  • AI/Regression Model
  • Charts/Chart Dataset x2
  • Charts/Multi Chart
  • Basics/Display

startBlox

BLOX used for this mission

Data

In this mission we will use the prepared dataset from the previous section.

If you can not create it, here is a link for the dataset FinalData.xlsx

Steps

Please refer to the Navigation Guide to perform the steps below

Flow Builder:

Creating regressions

  1. In Module3 in logic section create new logic named Linear Regression
  2. Drag-and-drop logics that will be used for this mission including the dataset FinalData
  3. Connect "Start" BLOX to the "MyData" BLOX
  4. Connect the output from "MyData" BLOX to the input of "First Rows", and type in the amount of rows (e.g. 200) you want to work on (the more rows, the harder it will be for Regression Model to create accurate predictions)
  5. In this step a BLOX is missing, you will have to figure out which one :) The goal is to aggregate the dates (as we have some cases when multiple orders are made on one day) and take the mean of the other values for the aggregation
  6. Hint Connect the output from "First Rows" to a "Group By" BLOX, and specify the column for grouping ("ORDERDATE" in our case), and aggregation function ("Average" in our case). Then, connect this BLOX to a "Regression Model" as described in step 6.
  7. Connect the output from your BLOX to "Regression Model" BLOX, specify the "Features" as "ORDERDATE" and the "Target" as "SALES", set the "Regression Type" to "Linear", set "Feature is time series" "yes" (as "ORDERDATE" is a time series variable) and specify the name of the regression model ("Linear Model" preferably)
  8. Connect the output from "Regression Model" to "Chart Dataset" BLOX, specify the x and y axis as "ORDERDATE" and "y_pred", chart type as "Line Chart" and optionally the color
  9. Connect the "Regression Model" BLOX to another "Chart Dataset" BLOX, specify the x and y ("ORDERDATE" and "y" in our case), chart type to "scatter" and optionally color
  10. Next, connect the output from "Chart Dataset" to "Multi Chart". In the "Multi Chart" input tab, set "Continuous X" to "yes". Finally, connect the output from "Multi Chart" to "Display" BLOX and click on the play button to execute the logic

Tip

You can look up the accuracy of the regression model if you double click on "Regression Model" BLOX and go to "Prediction Score" tab. The closer the value is to 1, the more accurate the predictions are.

Results and Summary

startBlox

Final logic composition

startBlox

Linear regression with 200 rows (accuracy: 8%)

Now you should see the regression in the "Display" BLOX, representing the regression calculated based on the provided data.

Well done! Now let's move on to the next mission!