## Demo: Performing Feature Selection (Self-Paced)

Removing redundant and irrelevant inputs from a training data set often improves the performance of a model. In this demonstration, you use a pre-created flow to select potentially useful features (variables).

Reminder: If you restarted your SAS session, or it has timed out due to inactivity, you must re-create the course libraries, LOCALLIB and VST. To do this, run the AssignLibrary flow.

1. In SAS Viya, launch SAS Studio by clicking the Applications menu button (the three-by-three grid in the upper left corner), expand ANALYTICS LIFE CYCLE, and click Develop Code and Flows.
2. In the navigation panel on the far left, click the Explorer button (second from top). Expand Files >Home > workshop > VST. Double-click AssignLibrary.flw to open it.
3. Click the Run button on the flow toolbar.

## Demo Steps

1. Open the previously created flow Data Preprocessing.flw from the VST folder.
2. Click on the Steps icon on the left side of the Navigation Pane. Under SAS Steps, expand Prepare Data, then double click on the Variable Selection step.
3. Next, move your mouse towards the edge of the PVA_DONORS_FINAL node until the pointer becomes a hand icon. Click and drag an arrow from PVA_DONORS_FINAL node to the box on the left side of the Variable Selection node (the input port). Now Variable Selection is connected to the PVA_DONORS_FINAL data. Click the Arrange nodes button to visually organize the flow.
4. Click on the Variable Selection node. Under the Data tab, ensure that the Unsupervised variable selection radio button has been selected.
5. Expand Explanatory Variables using the dropdown arrow. Under Explanatory Variables, find the field for Continuous variables and click the plus sign (+) to add numeric columns to the variable list. Select all the numeric inputs except GiftCnt36, StatusCatStarAll, DemMedIncome, Donation_Amt, and Rep_DemMedIncome. You can do so by clicking the Select all check box next to the Name field to include all the numeric inputs and then clear the boxes corresponding to GiftCnt36, StatusCatStarAll, DemMedIncome, Donation_Amt, and Rep_DemMedIncome. Click OK to close the Column Selection window.
6. Scroll down to the Classification variables field. Click the plus sign (+) to add variables. In the Column Selection window, select StatusCat96NK, StatusCatStarAll, DemGender, and DemHomeOwner. Click OK to close the Column Selection window.
7. Click on the Model tab to view these settings. Leave the default option Main effects model selected.
8. Next, click on the Options tab. Leave the default settings for Select variables based on: Correlations, Proportion of total variance to be explained: Use 0.9, and Maximum number of selected effects: Use 200.
9. Scroll down and select the box next to the Specify minimum increment of explained variance property. Verify that the Increment of explained variance value is set at 0.001.
10. Finally, under the Plots option, select the Iteration plot box to include an iteration plot in the results.
11. Typically, an output port connected to a table node would be added to Variable Selection to save the variable list to a data set. In the interest of time, here we will just right-click on the Variable Selection node and choose Run node to view the variable list in the Results. Save Data Preprocessing.flw and view the results.

When the run is complete, the results are displayed in the work area. Note that the variable reduction algorithm has used 5908 observations out of a total of 9686 observations. This is because of the presence of several missing values. Remember that, for brevity, you imputed the missing values in just one of the several variables. In practice, you should impute the missing values in all the variables before performing variable selection.

The Selection Summary table lists the variables in the order of selection. The variable that explains most of the variability in the input space is selected first. In the current example, Promotion Count All (PromCntAll) explains around 20% of variability, which is the highest among all inputs. The selection process stops after 17 iterations. Can you guess why? Well, the final parameter added to the selection summary resulted in just over 90% of the original variability being explained, triggering the algorithm to stop.

Next you see the Selected Effects table, which provides a summary of selected variables. These are the 12 variables that you might want to use as features in any supervised machine learning algorithm that follows.

When you scroll down farther in the results window, you see the iteration plot that summarizes the incremental variance explained by adding a variable in each iteration. This is essentially a grouped bar chart of increasing size in which blue bars represent the base value of variance explained and yellow bars represent the incremental value.