dipanjanS/practical-machine-learning-with-python

ValueError: Input contains NaN, infinity or a value too large for dtype('float64').

binary-signal opened this issue · 2 comments

Traceback (most recent call last):
File "/Users/evan/PycharmProjects/price-prediction/stock_price_forecast_regression_modeling.py", line 74, in
train_rmse = math.sqrt(mean_squared_error(y_train[train_offset:], np.array(train_pred_seqs).flatten()))
File "/Users/evan/PycharmProjects/price-prediction/venv/lib/python3.6/site-packages/sklearn/metrics/regression.py", line 238, in mean_squared_error
y_true, y_pred, multioutput)
File "/Users/evan/PycharmProjects/price-prediction/venv/lib/python3.6/site-packages/sklearn/metrics/regression.py", line 76, in _check_reg_targets
y_true = check_array(y_true, ensure_2d=False)
File "/Users/evan/PycharmProjects/price-prediction/venv/lib/python3.6/site-packages/sklearn/utils/validation.py", line 453, in check_array
_assert_all_finite(array)
File "/Users/evan/PycharmProjects/price-prediction/venv/lib/python3.6/site-packages/sklearn/utils/validation.py", line 44, in _assert_all_finite
" or a value too large for %r." % X.dtype)
ValueError: Input contains NaN, infinity or a value too large for dtype('float64').

Process finished with exit code 1

We need more information or context around your problem to understand what is happening. Please tell us the following,

  • What data is being used
  • Which function is throwing an error for you (besides the error message)

Also have you checked for missing values\NaNs in your dataset, if you have these values, it will throw an error (which is what it looks like based on the error messages above)

my csv file had nan values , with the correct file code runs ok !