I am working on a project where I need to compute scores for each record in a table based on the weights of different features. I have generated the weights using logistic regression. I have also generated a query that does the score weighted computation for all features using weights generated by LR. There are around 500 features in total.
However, when I run the query, I get an error saying Out of stack space due to deeply nested query expression. I understand that this is because the query is complex as it compute weighted score for lot of feats in select statement. But I don't know how to simplify the query or avoid this error.
Is there any way to rewrite the query or use a different approach to achieve the same result without getting this error? Any help or suggestions would be appreciated.
Example query: CREATE TEMP FUNCTION LR(x float64) RETURNS FLOAT64 AS ( 1/(1+ EXP(case when x > 100 then 100 else x end)) ); SELECT Id, LR( -( 0.01 * feat_1 + 0.04 * feat_2 ......{for all features}) )