Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
2fill in blank
mediumComplete 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'
Attempts:
3 left
3fill in blank
hardFix 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'
Attempts:
3 left
4fill in blank
hardFill 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'
Attempts:
3 left
5fill in blank
hardFill 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'
Attempts:
3 left