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

0 votes

I got ValueError when predicting test data using a RandomForest model.

clf = RandomForestClassifier(n_estimators=10, max_depth=6, n_jobs=1, verbose=2)
clf.fit(X_fit, y_fit)

df_test.fillna(df_test.mean())
X_test = df_test.values  
y_pred = clf.predict(X_test)

error:

ValueError: Input contains NaN, infinity or a value too large for dtype('float32').
May 23 in Machine Learning by Amulya
61 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Assuming X_test is a pandas dataframe, you can use DataFrame.fillna to replace the NaN values with the mean:

X_test.fillna(X_test.mean())
answered May 23 by Maya

Related Questions In Machine Learning

0 votes
1 answer
0 votes
1 answer

Can an ML model be recreated or retrained?

Of course, your model is retrainable, in ...READ MORE

answered May 13 in Machine Learning by Hemant
14 views
0 votes
1 answer
0 votes
1 answer

What is supervised learning?

Supervised learning is an aspect of machine learning ...READ MORE

answered May 8 in Data Analytics by Alok
16 views
0 votes
0 answers

What is semi-supervised machine learning?

What is semi-supervised machine learning? READ MORE

May 8 in Machine Learning by Ganesh
8 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How do I create a decision tree?

Let us consider the following example. Suppose a ...READ MORE

answered May 13 in Machine Learning by Fatima
12 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.