Yes, I know. This was supposed to be a four-part series. I lied. Well, not really. Although not part of the original plan, at some point along the way, I came up with the idea to extend the series by adding a comparison of results of all the feature extraction methods I covered. In this series, I’ve covered four methods to create new features using SAS Model Studio. In Part 1, I covered Principal Components Analysis (PCA), Part 2 introduced Robust PCA, Part 3 was on Autoencoders, and Part 4 covered Singular Value Decomposition (SVD). If you’re just joining this party now, you’ll probably want to check out those posts before reading this one. What fun would it be start at the end of the story?
The main purpose of the series was to introduce feature extraction, also called feature engineering, methods that are available in SAS Model Studio. Each post introduced a different method, provided some background and, when appropriate, mathematical details of the method, and a data example of how to implement the method and consume the results provided in Model Studio. The purpose of this post is to pull those examples together and compare the results. I’ll actually be covering two examples here.
The first thing I need to say is to keep in mind that results in data science are always data dependent. Just as there is not one single modeling algorithm which is always best, there is certainly not one single feature extraction method that is always best. If there were, Model Studio would include only that method! By data dependent, I mean problem specific. Data scientists think of such methods as tools in their toolbox. And it often takes trial and error for a specific problem to see which tool is best. Even with extensive domain knowledge, it’s very difficult before digging into the data to know which supervised model will be best or which data preprocessing method is most beneficial to the final model.
Example 1: Telecommunications Churn
The first example will be based on the data application I used throughout the series. A fictitious telecommunications company that is trying to predict customer churn. To compare results, I’ve created a pipeline reproducing exactly what was done in each prior post. The final result for each method is fed into a gradient boosting model which will be the basis for the comparison. I’ll also include a default gradient boosting model with no data preprocessing as a baseline and another gradient boosting model which uses only missing value imputation as its data preprocessing.
Here’s the pipeline. Again, each method in the pipeline is based on where each example ended in prior posts, so take a look at those posts if you need a refresher on what properties were changed in each case.
Select any image to see a larger version.
Mobile users: To view the images, select the "Full" version at the bottom of the page.
In the pipeline, you can see four gradient boosting models labeled according to each extraction method that was used (PCA, RPCA, AE, and SVD) as well as the gradient boosting model which used imputation (labeled Imp) and then the baseline, default gradient boosting model with no data prep.
Here’s the results from the Model Comparison node.
Although it may be disappointing given the purpose of the current series, the baseline, default gradient boosting model (no data preprocessing) is the pipeline champion based on the default assessment measure KS (Youden) on validation data. In fact, the baseline gradient boosting model is universally best across all assessment measures shown, including Average Squared Error, Area Under ROC, and Accuracy. This may seem anticlimactic, however, there is no guarantee that feature extraction will always lead to improved model performance. As stated above, results are data dependent and sometimes using the raw, untransformed inputs may lead to the best model. Keep in mind as mentioned in prior posts, feature extraction may be performed for reasons aside from just model performance. We may desire to reduce dimensionality of the input space due to a vast number of inputs in the data, the data itself may be corrupted with outliers that we wish to account for, or there may be a concern with nonlinear relationships in the data that we want to handle by compressing the raw inputs into a lower dimensional space.
That's an important point to remember. Feature extraction gives us another way of representing our data, but the ultimate test is still how useful that representation is for the analytical problem we're trying to solve.
One more point before moving on to the second example; for simplicity, the gradient boosting models had all hyperparameters left at their default values. Changing or tuning the models’ hyperparameters may have impacted relative performance and thus changed the results.
Example 2: Non-profit Charity Donations
For the second example, we’ll switch to a non-profit veterans' organization that is seeking donations for their charitable causes. In this example the organization would like to interpret what might lead to a high chance of donating, so we’ll be building decision trees. Even though the inputs created by feature extraction methods are not interpretable, there is a trick that can be done to interpret models based on uninterpretable features. Take a look at an earlier post I wrote on this topic.
Here’s the pipeline
Notice that the pipeline is based on the same approach as the one used in the first example. Four decision trees are built and named according to the feature extraction method each uses (PCA, RPCA, AE, SVD), there is a decision tree which uses imputation for data preprocessing (Imp), and a baseline, default decision tree with no data preprocessing.
The results of model comparison are much different from Example 1.
In this case, the decision tree using the results from Principal Components is the champion model across all metrics on validation data. And the model that comes in second place across all measures is the tree based on Singular Value Decomposition. Aside from the decision tree using Autoencoders (which could not provide a stable solution), the default baseline tree and the tree using only imputation were the worst performing models on the holdout sample.
For each feature extraction method, I followed similar approaches and guidelines as I discussed in prior posts to pick appropriate solutions. For example, for the PCA method, I selected 7 PCs as that is the value where the cumulative amount of variation explained in the data exceeded 80%, which is a common threshold when selecting the number of PCs to use.
For the RPCA method, the default settings led to a result where the sparsity of the sparse matrix was 0.1431 which would indicate that about 85% of the data are outliers.
Given this is not a realistic percentage, I increased the penalty weight which resulted in a more realistic value. The sparsity of the sparse matrix increased to 0.9781 which indicates about 2% of the data are outliers; a more realistic result.
With the increased penalty term, the scree plot revealed a significant bend or elbow at the 3 PC solution, so that value was selected as the solution for the RPCA method.
As in the first example, all models were built using the default values of their hyperparameters.
Closing Remarks:
Feature Extraction is an important and powerful method in data preprocessing for data scientists. It may increase model performance, it handles issues such as high dimensional data, it can mitigate the effect of outliers, and it can account for nonlinear relationships. Of course, like all data preprocessing actions, there’s no guarantee that applying feature extraction methods leads to improved model performance. Results are always problem specific. Nonetheless, feature extraction is a useful tool to keep in the analytics toolbox and SAS Model Studio makes implementing those tools quite easy.
Find more articles from SAS Global Enablement and Learning here.
Visit the Tips & Tricks page for setup guidance, demos, and practical examples that show how Copilot supports your workflows.
The rapid growth of AI technologies is driving an AI skills gap and demand for AI talent. Ready to grow your AI literacy? SAS offers free ways to get started for beginners, business leaders, and analytics professionals of all skill levels. Your future self will thank you.