The Perceptron Learning Rule

~15 mincode completion

Implement perceptron_train(X, y, lr, max_epochs) returning the array [w_1, ..., w_d, b, updates].

Where this shows up

~15 min

8 employers weight this skill

4 frontier labs, 2 big tech firms, 1 autonomy company, 1 enterprise vendor. Top match scores 92.

Python
import numpy as np


def perceptron_train(X, y, lr, max_epochs):
    """
    Train a perceptron with Rosenblatt's rule.

    Args:
        X:          inputs, shape (n, d)
        y:          labels in {0, 1}, shape (n,)
        lr:         learning rate eta
        max_epochs: the most passes over the data to make

    Returns:
        array [w_1, ..., w_d, b, updates]
    """
    # YOUR CODE HERE
    pass
Loading docs…

The AI Mentor needs an account

It reads your code and the failing tests and nudges you toward the fix without handing you the answer. Free accounts get it on every problem you're working on today.