Adjusted R^2 metric in a Feature Selection Loop

I created a simple Feature Selection Loop (no test data) for a MLR model (image below). I’d like to use Adjusted R^2 for scoring models. Calculating this metric requires the number of predictors p, however the Numeric Scorer node does not seem pick up p from the workflow. Instead, p is a parameter (“number of predictors”) in the node. This doesn’t work in a Feature Selection Loop, because p changes in each iteration of the loop.

Is there a way to set p using flow variables, or are there other nodes that make it possible to use Adjusted R^2 for feature selection?

Hello @rastraughan,

Welcome to the Forum.

To calculate the number of predictors used in a Multiple Linear Regression model, follow these steps:

  1. Use the Extract Table Dimension node to determine the number of columns in your table.
  2. Connect the output of the Extract Table Dimension node to the Table Row to Variable node to convert the number of columns into a flow variable.
  3. Use the Math Formula (Variable) node to subtract 1 from this value (to exclude the dependent variable).
  4. Use this resulting flow variable in the Numeric Scorer node to control the number of predictors value.

Hope this helps.



1 Like

Hi @k10shetty1,

Yes, that certainly helps! Thank you for the clear instructions and the example workflow!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.