Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import the DecisionTreeClassifier from scikit-learn.
ML Python
from sklearn.tree import [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
2fill in blank
mediumComplete the code to create a decision tree classifier object with a maximum depth of 3.
ML Python
model = DecisionTreeClassifier([1]=3)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
3fill in blank
hardFix the error in the code to train the decision tree model on features X and labels y.
ML Python
model.fit([1], y) Drag options to blanks, or click blank then click option'
Attempts:
3 left
4fill in blank
hardFill both blanks to predict labels for test data and store the predictions in variable 'predictions'.
ML Python
predictions = model.[1]([2])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
5fill in blank
hardFill all three blanks to calculate and print the accuracy score of the model predictions.
ML Python
from sklearn.metrics import {{BLANK_1 }} accuracy = [2](y_test, {{BLANK_3}}) print(f"Accuracy: {accuracy:.2f}")
Drag options to blanks, or click blank then click option'
Attempts:
3 left