R^2 for Logistic Regression models

User 2872 | 12/20/2015, 1:40:14 PM

Is there a direct way to get R^2 for learned Logistic Regression models? I can manually calculate it, but hoping there's some field I'm missing.

Comments

User 1592 | 12/26/2015, 5:28:18 AM

Hi Danny Here is a sample code for computing r^2 as defined here.

`python target = "ActualElapsedTime" def r2(model, test): y = test[target].mean() f = model.predict(test) ssres = ((test[target] - f)2).sum() sstot = ((f - y) 2).sum() r2 = 1 - (float(ssres) / sstot) return r2

print "R2 for model:", r2(model, test) `

Let us know if you have any further questions!