Linear Model Inference

Xem dạng PDF

Gửi bài giải

Điểm: 100,00
Giới hạn thời gian: 2.0s
Giới hạn bộ nhớ: 256M

Tác giả:
Dạng bài
Ngôn ngữ cho phép
Python

Task

Given a pre-trained linear model defined by a weight vector and a bias scalar, apply it to a set of test inputs and return the predictions. Each prediction is computed as y = X_row · w + bias. This simulates loading a serialized model and running inference without retraining.

Input

  • Line 1: d — number of features (dimension of weight vector)
  • Line 2: w_1 ... w_d bias — weight values followed by the bias term (d+1 numbers)
  • Line 3: m — number of test samples
  • Lines 4 to m+3: x_1 ... x_d — feature values for each test sample

Output

Print the prediction for each test sample space-separated on one line, with up to 10 significant digits each.

Example

Input:

2
1.5 -0.5 0
3
1 2
3 4
0 0

Output:

0.5 2.5 0

Scaffolding

Submit a Python file defining:

def model_serialization(weights: list[float], bias: float,
                        X_test: list[list[float]]) -> list[float]:
    ...

Receives a weight vector, a bias scalar, and a list of test feature rows; returns a list of linear predictions.


Bình luận

Hãy đọc nội quy trước khi bình luận.


Không có bình luận tại thời điểm này.