How do I assign x, y in a dataframe?
in
Machine Learning with Decision Trees and Random Forests
/
Practical Example: Creating a Decision Tree
This example does not have the column names for the dataset. For a dataframe where I have column names, how do I assign x and y? Thanks.
2 answers ( 0 marked as helpful)
Hi,
Sklearn is build to handle dataframes, including the column names. Thus, you can set your X and y variables to be the portions of the dataframe that you are interested in (one way to do is with .iloc) with the column names themselves.
Hope this helps! Let me know if you have further questions.
Best,
Nikola, 365 Team
Can you send me an example of the codes? Thanks!