Jump to content

Capsule Based Regression/Prediction


Recommended Posts

  • Administrators

The following steps will create a prediction model for every capsule in a condition.

Step 1.  pick a condition with capsules that isolate the desired area of regression.  Any condition with non-overlapping capsules will work as long as there are enough sample points within its duration. For this example, an increasing temperature condition will be used.  However, periodic conditions and value search conditions will work as well.

Step 2. Create a time counter for each capsule in the condition.  This can be done with the new timesince() function in the formula tool. The timesince() function will have samples spaced depending on the selected period so it is important to select a period that has enough points to build a model with.  See below for details on the timesince() formula setup.


Step 3. In this step a condition with capsule properties that hold the regression constants will be made.  This will be done in the formula tool with one formula.  The concept behind the formula below is to split the condition from step one into individual capsules and use each of the capsules as the training window for a regression model. Once the regression model is done for one capsule the coefficients of the model are assigned as properties to the capsule used for the training window.  

The formula syntax for a linear model-based condition can be seen below.  An example of a polynomial regression model can be found in the post below.

              $model=$SignalToModel.validValues().regressionModelOLS( group($cap),false,$Time)

Below is a screenshot of how the formula looks in Seeq.


Note: The regression constants can be added to the capsule pane by clicking on the black stats button and selecting add column. Below is a screen shot of the results.


Step 4. Once a condition with the regression coefficients has been created the information will need to be extracted to a signal form. The following formula syntax will extract the information. This will need to be repeated for every constant from your regression model. e.g.(So for a linear model this must be done for both the slope and for the intercept.)

The formula syntax for extracting the regression coefficients can be seen below.

  $cap -> sample($cap.getmiddle(), 
              $cap.getProperty('Intercept').toNumber()), 1min)


Below is a screenshot of the formula in Seeq.


Below is a screenshot of the display window of how the signals should look.


Step 5. Use the formula tool to plot the equation. See screenshot below for details.


Final Result

Edited by Teddy
  • Like 3
Link to comment
Share on other sites

  • Administrators

Here is the syntax for a polynomial regression based condition. 


        $model=$signaltomodel.regressionModelOLS(group($cap), false, $Time, $Time^2)

Below is a screenshot of it setup in the formula tool. 


The result

  • Like 2
Link to comment
Share on other sites

  • 2 years later...
  • Seeq Team

In Step 4 of the Original Post, the formula used for creating a signal with values from the Condition properties, 'Intercept' and 'Slope', was...

  $cap -> sample($cap.getmiddle(), 
              $cap.getProperty('Intercept').toNumber()), 1min)



This complex formula has been simplified and can now be written as...



If the condition is unbounded you may have to modify slightly...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...