Complete the code to import the popular machine learning framework.
import [1] as ml
TensorFlow is a popular framework for machine learning and AI tasks.
Complete the code to create a simple neural network layer using the framework.
model = ml.keras.Sequential([ml.keras.layers.Dense([1], activation='relu')])
The number 64 specifies the number of neurons in the Dense layer.
Fix the error in the code to compile the model with an optimizer.
model.compile(optimizer=[1], loss='sparse_categorical_crossentropy')
The optimizer name must be a string, so it needs quotes.
Fill both blanks to create a dictionary comprehension that filters features with importance above 0.1.
important_features = {k: v for k, v in feature_importances.items() if v [1] [2]The code keeps features with importance greater than 0.1.
Fill all three blanks to create a training loop that runs for 5 epochs and prints loss each epoch.
for epoch in range([1]): history = model.fit(X_train, y_train, epochs=1, verbose=0) print(f"Epoch { [2] }: Loss = {{history.history['[3]'][0]}}")
The loop runs 5 times, printing the loss after each epoch with epoch number starting at 1.
