I used scorecardpy function to get a model:
import scorecardpy as ac
card=sc.scorecard(bins_adj, lr, X_train.columns)
Then I tried to save this model using following code:
import numpy as np
np.save('card.npy',card)
After that I tried to reload this model:
card=np.load('card.npy',allow_pickle=True)
Then I want to use the model to get the scores:
score=sc.scorecard_ply(data_train, card, print_step=0)
But it gives error:
UnboundLocalError Traceback (most recent call last)
Cell In [91], line 1
score=sc.scorecard_ply(data_train, card, print_step=0)
File ~/.local/lib/python3.9/site-packages/scorecardpy/scorecard.py:330, in scorecard_ply(dt, card, only_total_score, print_step, replace_blank_na, var_kp)
card_df=card.copy(deep=True)
# x variables
xs=card_df.loc[card_df.variable != 'basepoints', 'variable'].unique()
# length of x variables
xs_len=len(xs)
UnboundLocalError: local variable 'card_df' referenced before assignment
How to resolve this problem?
scorecardmodule. What version are you using, and is there a newer one available that might fix the bug?