Question 12
1. Train a Random Forests model where the number of estimators is 100 using the training dataset.
2. Make predictions using the test dataset
3. Compute accuracy and save as accuracy
Hints:
• You need to use the RandomForestClassifier function. Instantiate a RandomForestClassifier object and pass the number of estimators to the function. Train the model using the X_train and y_train. Then make predictions using X_test. Then compute the accuracy using the predicted values and y_test.
• Check Module 6d: Model Performance and _Module 5c: Classification
In [162]: # Your code to train random forest, make predictions, and compute accuracy goes in here
accuracy = # compute accuracy here
Do not alter the below cell. It is a test case for Question 6
In [163]: try:
if (accuracy > 0.80):
score['question 12'] = 'pass'
else:
score['question 12'] = 'fail'
except:
score['question 12'] = 'fail'
score
Out[163]: {'question 1': 'pass',
'question 2': 'pass',
'question 3': 'pass',
'question 4': 'pass',
'question 5': 'pass',
'question 6': 'pass',
'question 7': 'pass',
'question 8': 'pass',
'question 9': 'pass',
'question 10': 'pass',
'question 11': 'pass',
'question 12': 'pass'}