Complete the code to import the machine learning library.
import [1]
We use sklearn (scikit-learn) for many machine learning tasks because it provides easy-to-use tools for advanced techniques.
Complete the code to create a decision tree classifier.
from sklearn.tree import DecisionTreeClassifier model = DecisionTreeClassifier([1]=42)
The random_state parameter ensures reproducible results by fixing the random seed.
Fix the error in the code to train the model on data X and labels y.
model.fit([1], y)The fit method requires the input features X first, then the labels y.
Fill both blanks to create a dictionary of word lengths for words longer than 3 letters.
lengths = {word: [1] for word in words if len(word) [2] 3}We want the length of each word, so len(word) is the value. We filter words longer than 3 letters using >.
Fill all three blanks to create a filtered dictionary with uppercase keys and values greater than 2.
filtered = [1]: [2] for [3], [2] in data.items() if [2] > 2
The keys are converted to uppercase with k.upper(), values are v, and we loop using k, v from data.items().