A bank scores loan applicants with a simple model. Each row of X is one applicant, and columns names each column of X in order.
The model's weights arrive as a dict, weights, mapping a feature's name to its weight. It was saved by a different program, so:
columns,columns that is missing from weights has a weight of 0,weights that aren't in columns are ignored.An applicant's score is each feature times its own weight, all added up, plus bias. An applicant is approved when their score is greater than or equal to threshold. Compare the unrounded score.
Task: write approve(X, columns, weights, bias, threshold) returning a dict:
"scores" — every applicant's score, in row order, rounded to 2 decimal places,"approved" — the row numbers of the approved applicants, smallest first.