benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 66583ca7-0b6f-5ccc-91ea-c9c5e1debde5

Problem

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

complete prompt

import pandas as pd
from sklearn.cluster import DBSCAN

def task_func(data, cols):
    """
    Perform DBSCAN clustering on the data by transforming it into a DataFrame and recording the clusters in a new column named 'Cluster'.
    Please choose the parameters eps=3 and min_samples=2.
    
    Parameters:
    - data (list): List of lists with the data, where the length of the inner list equals the number of columns
    - cols (list): List of column names
    
    Returns:
    - df (DataFrame): The DataFrame with a new 'Cluster' column.

    Requirements:
    - pandas
    - sklearn

    Example:
    >>> data = [[5.1, 3.5], [4.9, 3.0], [4.7, 3.2]]
    >>> cols = ['x', 'y']
    >>> df = task_func(data, cols)
    >>> print(df)
         x    y  Cluster
    0  5.1  3.5        0
    1  4.9  3.0        0
    2  4.7  3.2        0
    """

instruct prompt

Perform DBSCAN clustering on the data by transforming it into a DataFrame and recording the clusters in a new column named 'Cluster'. Please choose the parameters eps=3 and min_samples=2.
The function should output with:
    df (DataFrame): The DataFrame with a new 'Cluster' column.
You should write self-contained code starting with:

Code

import pandas as pd
from sklearn.cluster import DBSCAN
def task_func(data, cols):

code prompt

Code

import pandas as pd
from sklearn.cluster import DBSCAN
def task_func(data, cols):

entry point

task_func

libs

  • pandas
  • 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