# How to Determine the Minimum Value of a Continuous Variable for Predicting Categorical variable using Logistic Regression?

I am using logistic regression to predict df['MortSubiteCardiaque'], which contains 0 and 1, based on my continuous variable df['NTProBNP']. I would like to determine the threshold for df['NTProBNP'], specifically the minimum value of df['NTProBNP'] that predicts 1. How can I do that?

  df['constante'] = 1

X = df[['constante', 'NTProBNP']]
y = df['MortSubiteCardiaque']

model = sm.Logit(y, X)
result = model.fit()

y_probs = result.predict(X)

fpr, tpr, thresholds = roc_curve(y, y_probs)

roc_auc = auc(fpr, tpr)
# optimal cut-off point
optimal_idx = np.argmax(tpr - fpr)
optimal_threshold = thresholds[optimal_idx]

# i had 2361 with this line
df['NTProBNP'][y_probs >= optimal_threshold].min()

• Is the scale of NTProBNP such that higher values correspond more to MortSubiteCardiaque = 1? Feb 12 at 16:09
• #@m13op22 yes, mean 5116.904762 std 6759.119454 min 15.000000 25% 737.250000 50% 2463.500000 75% 5514.250000 max 25000.000000 I think I can find the solution by inverting the logistic function, setting it equal to the optimal threshold. This solution seems logical to me, but I can't find a reference. Feb 13 at 8:24