I am building a Random Forest model, and my categorical labels are strings (e.g., "Active" and "Inactive"). How can I convert "Active" to '1' and "Inactive" to '0' for use in a classification model?

15 views
Skip to first unread message

Andrew Orry

unread,
Feb 7, 2025, 8:29:02 PM2/7/25
to MolSoft ICM Knowledge Base
Q  I am building a Random Forest model, and my categorical labels are strings (e.g., "Active" and "Inactive"). How can I convert "Active" to '1' and "Inactive" to '0' for use in a classification model?

A. 
 You can use the add column command to achieve this. Below is an example for a table called test_results with a column named Activity that contains the strings "Active" and "Inactive":

add column test_results function = "Activity=='Active'?1:0" name="aaa"

Reply all
Reply to author
Forward
0 new messages