Build a baseline classifier that predicts the most frequent training label for every test sample. If multiple labels have the same maximum frequency, choose the one that appears first in y_train. Features in X_test determine only how many predictions to return. Return a one-dimensional NumPy integer array.
Input: y_train = [0, 1, 1, 1, 0], X_test = [10, 20, 30]
Output: [1, 1, 1]
Explanation: Label 1 occurs three times, so it is predicted for all three samples.
Input: y_train = [2, 2, 2, 1, 0], X_test = [5, 6]
Output: [2, 2]
Use np.unique(y_train, return_index=True, return_counts=True) to obtain counts and first positions.
Among labels with the maximum count, select the smallest recorded first position.
Sign in to take notes on this problem
Accepts: array
Accepts: array
Build a baseline classifier that predicts the most frequent training label for every test sample. If multiple labels have the same maximum frequency, choose the one that appears first in y_train. Features in X_test determine only how many predictions to return. Return a one-dimensional NumPy integer array.
Input: y_train = [0, 1, 1, 1, 0], X_test = [10, 20, 30]
Output: [1, 1, 1]
Explanation: Label 1 occurs three times, so it is predicted for all three samples.
Input: y_train = [2, 2, 2, 1, 0], X_test = [5, 6]
Output: [2, 2]
Use np.unique(y_train, return_index=True, return_counts=True) to obtain counts and first positions.
Among labels with the maximum count, select the smallest recorded first position.
Sign in to take notes on this problem
Accepts: array
Accepts: array