Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dividing by zero #3

Open
londumas opened this issue Apr 6, 2020 · 2 comments
Open

dividing by zero #3

londumas opened this issue Apr 6, 2020 · 2 comments

Comments

@londumas
Copy link

londumas commented Apr 6, 2020

The following code results in the following error because of division by zero.

precision_all[j,1] = max(2*precision_lof*recall_lof/(precision_lof+recall_lof))

run_classification_pyod.py:61: RuntimeWarning: invalid value encountered in true_divide
  precision_all[j,0] = max(2*precision_iso*recall_iso/(precision_iso+recall_iso))
run_classification_pyod.py:62: RuntimeWarning: invalid value encountered in true_divide
  precision_all[j,1] = max(2*precision_lof*recall_lof/(precision_lof+recall_lof))
@londumas
Copy link
Author

londumas commented Apr 6, 2020

Same here:

run_classification_rrcf.py:69: RuntimeWarning: invalid value encountered in true_divide
  precision_all[j,0] = max(2*precision_iso*recall_iso/(precision_iso+recall_iso))
run_classification_sklearn_pidforest_alg.py:84: RuntimeWarning: invalid value encountered in true_divide
  precision_all[j,1] = max(2*precision_lof*recall_lof/(precision_lof+recall_lof))
run_classification_sklearn_pidforest_alg.py:85: RuntimeWarning: invalid value encountered in true_divide
  precision_all[j,2] = max(2*precision_osvm*recall_osvm/(precision_osvm+recall_osvm))
run_classification_sklearn_pidforest_alg.py:86: RuntimeWarning: invalid value encountered in true_divide
  precision_all[j,3] = max(2*precision_our*recall_our/(precision_our+recall_our))
run_timeseries_pyod.py:64: RuntimeWarning: invalid value encountered in true_divide
  precision_all[j,0] = max(2*precision_iso*recall_iso/(precision_iso+recall_iso))
run_timeseries_pyod.py:65: RuntimeWarning: invalid value encountered in true_divide
  precision_all[j,1] = max(2*precision_lof*recall_lof/(precision_lof+recall_lof))

@londumas
Copy link
Author

londumas commented Apr 6, 2020

The incorrect division must be preventing from the script to finish properly:

python run_classification_rrcf.py
Traceback (most recent call last):
  File "run_classification_rrcf.py", line 67, in <module>
    precision_iso, recall_iso, thresholds_iso = metrics.precision_recall_curve(y, iso_scores, pos_label=1)
  File "<HOME>.local/lib/python3.6/site-packages/sklearn/metrics/_ranking.py", line 673, in precision_recall_curve
    sample_weight=sample_weight)
  File "<HOME>.local/lib/python3.6/site-packages/sklearn/metrics/_ranking.py", line 542, in _binary_clf_curve
    assert_all_finite(y_score)
  File "<HOME>.local/lib/python3.6/site-packages/sklearn/utils/validation.py", line 77, in assert_all_finite
    _assert_all_finite(X.data if sp.issparse(X) else X, allow_nan)
  File "<HOME>.local/lib/python3.6/site-packages/sklearn/utils/validation.py", line 60, in _assert_all_finite
    msg_dtype if msg_dtype is not None else X.dtype)
ValueError: Input contains NaN, infinity or a value too large for dtype('float64').

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant