Open demainchen opened 3 years ago
Hi, While, I never encountered this error before, I think it may have to do with division by zero in the definition of MCC: just add an eps = 1e-6 in the denominator, e.g.: MCC = float(tptn-fpfn)/(1e-6+np.sqrt((tp+fp)(tp+fn)(tn+fp)*(tn+fn)))
I believe this should fix the error. Let me know if it helps.
On Sun, Aug 29, 2021 at 7:33 AM demainchen @.***> wrote:
Training... /Users/demainchen/Downloads/Struct2Graph-master/k-fold-CV.py:282: RuntimeWarning: invalid value encountered in double_scalars MCC = float(tptn-fpfn)/(np.sqrt((tp+fp)(tp+fn)(tn+fp)(tn+fn))) Traceback (most recent call last): File "", line 1, in File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_umd.py", line 198, in runfile pydev_imports.execfile(filename, global_vars, local_vars) # execute the script File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "/Users/demainchen/Downloads/Struct2Graph-master/k-fold-CV.py", line 388, in accuracy, precision, recall, sensitivity, specificity, MCC, F1_score, roc_auc_val, auc_val, Q9, ppv, npv, tp, fp, tn, fn = tester.test(dataset_test) File "/Users/demainchen/Downloads/Struct2Graph-master/k-fold-CV.py", line 202, in test roc_auc_val = roc_auc_score(t_list, score_list) File "/Users/demainchen/.conda/envs/DESC_MOL-DDIE-master/lib/python3.9/site-packages/sklearn/utils/validation.py", line 63, in inner_f return f(args, **kwargs) File "/Users/demainchen/.conda/envs/DESC_MOL-DDIE-master/lib/python3.9/site-packages/sklearn/metrics/_ranking.py", line 542, in roc_auc_score return _average_binary_score(partial(_binary_roc_auc_score, File "/Users/demainchen/.conda/envs/DESC_MOL-DDIE-master/lib/python3.9/site-packages/sklearn/metrics/_base.py", line 77, in _average_binary_score return binary_metric(y_true, y_score, sample_weight=sample_weight) File "/Users/demainchen/.conda/envs/DESC_MOL-DDIE-master/lib/python3.9/site-packages/sklearn/metrics/_ranking.py", line 327, in _binary_roc_auc_score raise ValueError("Only one class present in y_true. ROC AUC score " ValueError: Only one class present in y_true. ROC AUC score is not defined in that case.
When I try to run the K-fold-CV.py , the console told me the above information.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/baranwa2/Struct2Graph/issues/6, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJDGYOEV4WR5IYX4MVZSVFLT7GINNANCNFSM5C7WZQ3Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
-- Regards, Mayank
It is very sad to tell you this method does not work, I guess this problem was probably incurred by my Computer System. I run this model under Mac 2020, with the M1 chip. Recently I find a few models are not compatible with my computer.
Training... /Users/demainchen/Downloads/Struct2Graph-master/k-fold-CV.py:282: RuntimeWarning: invalid value encountered in double_scalars MCC = float(tptn-fpfn)/(np.sqrt((tp+fp)(tp+fn)(tn+fp)(tn+fn))) Traceback (most recent call last): File "", line 1, in
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_umd.py", line 198, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/Users/demainchen/Downloads/Struct2Graph-master/k-fold-CV.py", line 388, in
accuracy, precision, recall, sensitivity, specificity, MCC, F1_score, roc_auc_val, auc_val, Q9, ppv, npv, tp, fp, tn, fn = tester.test(dataset_test)
File "/Users/demainchen/Downloads/Struct2Graph-master/k-fold-CV.py", line 202, in test
roc_auc_val = roc_auc_score(t_list, score_list)
File "/Users/demainchen/.conda/envs/DESC_MOL-DDIE-master/lib/python3.9/site-packages/sklearn/utils/validation.py", line 63, in inner_f
return f( args, **kwargs)
File "/Users/demainchen/.conda/envs/DESC_MOL-DDIE-master/lib/python3.9/site-packages/sklearn/metrics/_ranking.py", line 542, in roc_auc_score
return _average_binary_score(partial(_binary_roc_auc_score,
File "/Users/demainchen/.conda/envs/DESC_MOL-DDIE-master/lib/python3.9/site-packages/sklearn/metrics/_base.py", line 77, in _average_binary_score
return binary_metric(y_true, y_score, sample_weight=sample_weight)
File "/Users/demainchen/.conda/envs/DESC_MOL-DDIE-master/lib/python3.9/site-packages/sklearn/metrics/_ranking.py", line 327, in _binary_roc_auc_score
raise ValueError("Only one class present in y_true. ROC AUC score "
ValueError: Only one class present in y_true. ROC AUC score is not defined in that case.
When I try to run the K-fold-CV.py , the console told me the above information.