0

I attempted to run a code on both linux and Google Colab. It works fine on the later but throws syntax error on Linux.

auc = roc_auc_score(observed[:,0], predicted[:,0])
tn, fp, fn, tp = confusion_matrix(observed[:,0]>0.5, predicted[:,0]>0.5).ravel()
sen = tn/(tn+fp)
spe = tp/(tp+fn)
acc = (tp+tn)/(tp+tn+fp+fn)
print(f"AUC  Sen. Spe. Acc.\n{auc:0.2f} {sen:0.2f} {spe:0.2f} {acc:0.2f}")

Traceback:

~/PathCNN$ python3 PathCNN_GradCAM_modeling.py
  File "PathCNN_GradCAM_modeling.py", line 205

    print(f"AUC  Sen. Spe. Acc.\n{auc:0.2f} {sen:0.2f} {spe:0.2f} {acc:0.2f}")
                                                                            ^
SyntaxError: invalid syntax

The code works fine when I ran it on google colab (https://colab.research.google.com/drive/1WCfguKFN0Zs0ZDkKga2DpDgjBP3PnwB_?usp=sharing).

melolili
  • 383
  • 1
  • 7
  • Maybe is a Python version issue? f-strings were introduced in Python 3.6. Check your local Python version using `python3 --version` – aaossa Feb 11 '22 at 16:47

0 Answers0