Let's practice in critical conditions: we have a small dataset. As already mentioned in the topic, some objects can never occur in any OOB sample and the model does not give OOB predictions for them.
Let's look at how it happens. Follow these steps:
- Load the iris flower dataset.
- Split data into train and test sets using
train_test_splitfunction with the following parameters:test_size=0.5,random_state=17. - Create an instance of
RandomForestClassifiermodel with the following parameters:n_estimators=5,max_features=2,random_state=17,oob_score=True. Then, fit it with the train set. - Examine the content of the
oob_decision_function_attribute of the model for the presence ofnanvalues.
Your task is to write the number of objects that have no OOB prediction.