Author

Tashvi Bansal

1 published record · Monta Vista High School

Social science · Paper · October 2025

Counterfactual Loss Improves Feature-Token Transformer Performance in Community Homelessness Prediction

Tashvi Bansal

Two issues persist within the homelessness domain: lack of accuracy in current homelessness prediction models and the need to reduce spending because of inefficiency in homelessness funding. This study has two hypotheses. First, we hypothesized that the addition of a counterfactual loss configuration will improve FT-Transformer’s accuracy on homelessness data because sparsity regularization penalizes complex feature combinations and reduces overfitting to noise in highdimensional data. Second, we hypothesized that generating post-hoc counterfactuals will identify “what-if” changes to the input features that will prescribe budgeting more efficiently. This study’s dataset is from the U.S. Department of Housing and Urban Development (HUD), with community-level factors associated with homelessness as input features and homelessness rates per Continuum of Care as the target. The study evaluated the performance of FTTransformer versus FT-Transformer with a modified loss function. The modified loss function integrated sparsity, a metric measuring how many feature values differ between an instance and its counterfactuals. Supporting the first hypothesis, FT-Transformer with counterfactual loss achieved an R2 of 0.850—higher than vanilla FT-Transformer’s R2 of 0.831—and attention analysis revealed significant variance reduction in attention scores for FT-Transformer with the loss configuration. This variance reduction indicated attention is more concentrated on a smaller set of features, demonstrating that the sparsity-based optimization successfully penalized complex feature combinations and reduced overfitting to noise. The second hypothesis received only partial support, as post-hoc counterfactuals successfully reduced budgets but exhibited low feasibility and yield. This work lays foundations for transparent and data-driven homelessness policy interventions.