benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 2edc0281-2152-5fc3-97ff-9480d9456a63

Problem

Answer published by the source. Consult the official source to check your work against its answer.

complete prompt

from itertools import chain
import numpy as np
from sklearn.cluster import KMeans


def task_func(L):
    """
    Convert a list of lists into a list of integers, apply the KMeans clustering, 
    and return a scatter plot 'matplotlib.axes.Axes' with data points color-coded by their cluster.

    Requirements:
    - itertools.chain
    - numpy
    - sklearn.cluster

    Parameters:
    L (list of lists): A list of lists where each sublist contains integers.

    Returns:
    matplotlib.axes.Axes: An Axes object representing the scatter plot.

    Example:
    >>> ax = task_func([[1, 2, 3], [50, 60, 70], [100, 110, 120]])
    """

instruct prompt

Convert a list of lists into a list of integers, apply the KMeans clustering, and return a scatter plot 'matplotlib.axes.Axes' with data points color-coded by their cluster.
The function should output with:
    matplotlib.axes.Axes: An Axes object representing the scatter plot.
You should write self-contained code starting with:

Code

from itertools import chain
import numpy as np
from sklearn.cluster import KMeans
def task_func(L):

code prompt

Code

from itertools import chain
import numpy as np
from sklearn.cluster import KMeans
def task_func(L):

entry point

task_func

libs

  • numpy
  • itertools
  • sklearn

Discussion

Discussion

No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

Source and history

Official source

initial import