1

Prediction with Weights

Unsolved
Supervised

Difficulty: 3 | Problem written by Mr. Umair
Prediction in supervised learning often looks like this:

$$intermediate = sum(weight_i * x_i) + bias$$

These intermediate values are used for prediction using a step transfer function:

$$prediction = 1.0 \: if \: intermediate >= 0 \: else \: 0$$

Input:

You will be given two variables, i.e. a 2D array containing the dataset and 1D array of weights. The dataset format will be:
X1                             X2

2.7810836            2.550537003
1.465489372        2.362125076
7.627531214        2.759262235
5.332441248        2.088626775
6.922596716        1.77106367

Weights = [-0.1, 0.20653640140000007, -0.23418117710000003]

Output:

Your function will return a list of predicted values, i.e. a list of predictions using the two formulae above.

Sample Input:
<class 'list'>
dataset: [[2.7810836, 2.550537003], [1.465489372, 2.362125076], [3.396561688, 4.400293529], [1.38807019, 1.850220317], [3.06407232, 3.005305973], [7.627531214, 2.759262235], [5.332441248, 2.088626775], [6.922596716, 1.77106367], [8.675418651, -0.242068655], [7.673756466, 3.508563011]]
<class 'list'>
weights: [-0.1, 0.20653640140000007, -0.23418117710000003]

Expected Output:
<class 'list'>
[0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0]

MLPro Premium also allows you to access all our high quality MCQs which are not available on the free tier.

Not able to solve a problem? MLPro premium brings you access to solutions for all problems available on MLPro

Have an issue, the MLPro support team is available 24X7 to Premium users.