Home Forums Main Forums Python Forum customer function for ROC

  • customer function for ROC

     Tundra.L updated 3 years, 6 months ago 2 Members · 3 Posts
  • Tundra.L

    Member
    November 12, 2020 at 1:02 pm
    Up
    0
    Down

    here is the coding I did for ROC curve:

    threshold=[*range(100,900,100)]
    results=pd.DataFrame()
    for x in threshold:
    print(x)
    roc=Loan.query('CR_Score>x')
    roc=roc.assign(subject=i)
    roc=roc.groupby('Bad').agg({'Client_ID':'count'})
    results=results.append(roc)
    results

    the output is

    100#this is only number, no 200 etc
    .......
    UndefinedVariableError: name 'x' is not defined

    can you please tell me what’s wrong with my code? thanks

  • Datura

    Member
    November 12, 2020 at 6:43 pm
    Up
    0
    Down

    I think that, when you use query() function, probably you can only use columns in the Loan data frame. x is an external object, so Python cannot find it.

    Try to use other functions to subset data.

    • Tundra.L

      Member
      November 12, 2020 at 7:27 pm
      Up
      0
      Down

      thank you. I switched to loc() function, now it works. the output is like:

      0 8535
      1 1954
      0 8496
      1 1749
      .......

      • This reply was modified 3 years, 6 months ago by  Tundra.L.

Log in to reply.

Original Post
0 of 0 posts June 2018
Now