Problem:
"NAs introduced by coercion" Error in Titanic Random Forest Model.
Solution:
While creating my first Random Forest model on Titanic Dataset, I got the below Error:
This error occurs if there is some feature in the DataSet with class 'char'. Let's take a look at the current Dataset with glimpse() or str(). To use the glimpse(), library "dplyr" is required first.
"NAs introduced by coercion" Error in Titanic Random Forest Model.
Solution:
While creating my first Random Forest model on Titanic Dataset, I got the below Error:
This error occurs if there is some feature in the DataSet with class 'char'. Let's take a look at the current Dataset with glimpse() or str(). To use the glimpse(), library "dplyr" is required first.
As we can see, the variables "Sex" and "Embarked" are "char". We need to convert the "char" columns into "Factors". Factors are treated as integers internally whereas character fields are not. So, for this example, we will convert the below variables into Factors:
1. Survived
2. Pclass
3. Sex
4. Embarked
After Transforming the variables to Factors, the issue was resolved and I was able to develop my Random Forest Model for Titanic Dataset. The post is here.
No comments:
Post a Comment