Practice
import numpy as np
from sklearn.preprocessing import StandardScaler
X = np.array([[1, 2], [3, 4], [5, 6]])
scaler = StandardScaler()
X_scaled = scaler.fit_transform(X)
print(X_scaled.mean(axis=0))What does this code output?Solution
Step 1: Understand standardization.
StandardScaler standardizes features by removing the mean and scaling to unit variance.Step 2: Calculate the mean of standardized data.
After standardization, the mean of each feature should be 0.Final Answer:
Option C -> Option CQuick Check:
StandardScaler centers data to mean 0. [OK]
import numpy as np
business_goals = np.array(['increase sales', 'reduce churn', 'improve satisfaction'])
ml_problems = np.array(['classification', 'regression', 'clustering'])
result = np.char.add(business_goals, ml_problems)
print(result)Solution
Step 1: Understand the operation
The np.char.add function concatenates corresponding elements of two arrays element-wise.Step 2: Eliminate wrong options
['increase sales', 'reduce churn', 'improve satisfaction'] and C are incorrect because they ignore the concatenation operation. Throws an error due to incompatible types is incorrect because np.char.add handles string arrays correctly.Final Answer:
Option A -> Option AQuick Check:
np.char.add concatenates strings element-wise. [OK]
import numpy as np
x = np.array([1, 2, 3])
y = np.array([4, 5, 6])
result = np.dot(x, y)
print(result)What does this code output?Solution
Step 1: Understand the dot product operation.
The dot product of two vectors is the sum of the products of their corresponding elements.Step 2: Calculate the dot product.
(1*4) + (2*5) + (3*6) = 32.Final Answer:
Option C -> Option CQuick Check:
Dot product sums element-wise products. [OK]
Solution
Step 1: Identify potential issues with SentencePiece training.
Improper normalization can lead to unexpected token sequences.Step 2: Eliminate wrong options.
Large vocabulary (A) and diverse data (C) are less likely to cause unexpected sequences; fixed vocabulary (D) is unrelated to sequence issues.Final Answer:
Option A -> Option AQuick Check:
Normalization issues cause token surprises. [OK]
Solution
Step 1: Identify task requirements
The task requires capturing both spatial and temporal hierarchies, which suggests a hybrid approach.Step 2: Eliminate wrong options
Use a shallow CNN for spatial features and a separate RNN for temporal features. is incorrect because separate models may not capture interactions. Use a shallow RNN for temporal features and ignore spatial features. is incorrect because it ignores spatial features. Use a deep CNN for spatial features and ignore temporal features. is incorrect because it ignores temporal features.Final Answer:
Option A -> Option AQuick Check:
Hybrid models for spatial-temporal tasks. [OK]
