0
0
ML Pythonprogramming~10 mins

Random forest classifier in ML Python - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the RandomForestClassifier from scikit-learn.

ML Python
from sklearn.ensemble import [1]
Drag options to blanks, or click blank then click option'
ADecisionTreeClassifier
BKNeighborsClassifier
CRandomForestClassifier
DSVC
Attempts:
3 left
2fill in blank
medium

Complete the code to create a random forest classifier with 100 trees.

ML Python
model = RandomForestClassifier(n_estimators=[1])
Drag options to blanks, or click blank then click option'
A10
B200
C50
D100
Attempts:
3 left
3fill in blank
hard

Fix the error in the code to fit the model on training data X_train and y_train.

ML Python
model.[1](X_train, y_train)
Drag options to blanks, or click blank then click option'
Afit
Btransform
Cpredict
Dscore
Attempts:
3 left
4fill in blank
hard

Fill both blanks to predict labels for X_test and calculate accuracy score.

ML Python
predictions = model.[1](X_test)
accuracy = accuracy_score(y_test, [2])
Drag options to blanks, or click blank then click option'
Apredict
Bpredictions
Cfit
Dtransform
Attempts:
3 left
5fill in blank
hard

Fill all three blanks to create a random forest with max depth 5, fit it, and predict.

ML Python
model = RandomForestClassifier(n_estimators=[1], max_depth=[2])
model.[3](X_train, y_train)
preds = model.predict(X_test)
Drag options to blanks, or click blank then click option'
A100
B5
Cfit
D10
Attempts:
3 left