k-Means++ Seeding from Given Draws

~18 mincode completion

Implement kmeanspp_seed(X, first, draws) returning the array of chosen centroids, in the order chosen.

Where this shows up

~18 min

1 employer weight this skill

1 health and bio company. Top match scores 85.

Python
import numpy as np


def kmeanspp_seed(X, first, draws):
    """
    k-means++ initialization with the random draws supplied.

    Args:
        X:     array of shape (n, d)
        first: index of the first centroid
        draws: array of uniform numbers in [0, 1), one per extra centroid

    Returns:
        array of shape (len(draws) + 1, d): the centroids in the order chosen
    """
    # YOUR CODE HERE
    pass

Run your code to see results

⌘↵ runs against the visible tests

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.