dipanjanS / practical-machine-learning-with-python

Master the essential skills needed to recognize and solve complex real-world problems with Machine Learning and Deep Learning by leveraging the highly popular Python Machine Learning Eco-system.
Apache License 2.0
2.25k stars 1.64k forks source link

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

Closed binary-signal closed 6 years ago

binary-signal commented 6 years ago

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

dipanjanS commented 6 years ago

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

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)

binary-signal commented 6 years ago

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