You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@dataprofessor
If the code is run as is, it will display an error when building the Random Forest Model:
"Error in y - ymean : non-numeric argument to binary operator
In addition: Warning messages:..."
That is because the "Species" column in the TrainSet is passed as char
Therefore, the model cannot be created and the app can't be run.
To solve it, we just need to pass the "Species" column to the TrainSet as factor after line 24:
TrainSet <- read.csv("training.csv", header = TRUE)
str(TrainSet)
#Since here "Species" is a char column,
#we convert it to a factor
TrainSet[,"Species"] <- as.factor(TrainSet[,"Species"])
TrainSet <- TrainSet[,-1]
str(TrainSet)
#Now "Species" is a factor with three levels ;)
This will keep the Sepal and Petal Length and Width as num, but turn the Species into a 3 - level factor.
Thanks for all of your lessons!
jzambrano-xyz
The text was updated successfully, but these errors were encountered:
@dataprofessor
If the code is run as is, it will display an error when building the Random Forest Model:
"Error in y - ymean : non-numeric argument to binary operator
In addition: Warning messages:..."
That is because the "Species" column in the
TrainSet
is passed as charTherefore, the model cannot be created and the app can't be run.
To solve it, we just need to pass the "Species" column to the TrainSet as factor after line 24:
This will keep the Sepal and Petal Length and Width as num, but turn the Species into a 3 - level factor.
Thanks for all of your lessons!
jzambrano-xyz
The text was updated successfully, but these errors were encountered: