0
0
ML Pythonprogramming~10 mins

Decision tree 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 DecisionTreeClassifier from scikit-learn.

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

Complete 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'
Amin_samples_split
Brandom_state
Cmax_depth
Dcriterion
Attempts:
3 left
3fill in blank
hard

Fix 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'
AX
Bfit
Cy
Dmodel
Attempts:
3 left
4fill in blank
hard

Fill 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'
Apredict
BX_test
Cfit
Dy_test
Attempts:
3 left
5fill in blank
hard

Fill 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'
Aaccuracy_score
Cpredictions
Dy_train
Attempts:
3 left