Skip to content

Commit 06e486e

Browse files
committed
Fix improper abs use and add try/except around scipy import
1 parent 729e72c commit 06e486e

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/sasctl/pzmm/write_json_files.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -542,12 +542,14 @@ def calculateFitStat(
542542
GINI = (2 * auc) - 1
543543
fitStats["_GINI_"] = GINI
544544

545-
from scipy.stats import (
546-
gamma,
547-
) # Holdover until fitstat generation via SWAT is sussed out
548-
549-
_, _, scale = gamma.fit(dataSets[j][1])
550-
fitStats["_GAMMA_"] = 1 / scale
545+
try:
546+
from scipy.stats import gamma
547+
_, _, scale = gamma.fit(dataSets[j][1])
548+
fitStats["_GAMMA_"] = 1 / scale
549+
except ImportError:
550+
warnings.warn("scipy was not installed, so the gamma calculation could"
551+
"not be computed.")
552+
fitStats["_GAMMA_"] = None
551553

552554
intPredict = [round(x) for x in dataSets[j][1]]
553555
MCE = 1 - metrics.accuracy_score(dataSets[j][0], intPredict)
@@ -559,7 +561,7 @@ def calculateFitStat(
559561
MCLL = metrics.log_loss(dataSets[j][0], dataSets[j][1])
560562
fitStats["_MCLL_"] = MCLL
561563

562-
KS = max(math.fabs(fpr - tpr))
564+
KS = max(abs(fpr - tpr))
563565
fitStats["_KS_"] = KS
564566

565567
KSPostCutoff = None

0 commit comments

Comments
 (0)