# BigCodeBench / 

task_id: cb5e8849-4757-525e-b010-ab1ed0a59465
task_key: default--v0~2e1~2e0~5fhf--cb5e8849-4757-525e-b010-ab1ed0a59465
task_revision_id: 1

{"code_prompt":"from collections import Counter\nfrom sklearn.cluster import KMeans\nimport matplotlib.pyplot as plt\ndef task_func(df, n_clusters=3, random_state=None, n_init=10):\n","complete_prompt":"from collections import Counter\nfrom sklearn.cluster import KMeans\nimport matplotlib.pyplot as plt\n\n\ndef task_func(df, n_clusters=3, random_state=None, n_init=10):\n    \"\"\"\n    Identify duplicate points in a DataFrame, perform KMeans clustering on the unique points,\n    and record the clusters.\n\n    Parameters:\n    df (pd.DataFrame): A DataFrame containing at least two columns 'x' and 'y' representing points.\n    n_clusters (int, optional): Number of clusters for KMeans clustering. Default is 3.\n    random_state (int, optional): The seed used by the random number generator for reproducibility. Default is None.\n    n_init (int, optional): Number of time the k-means algorithm will be run with different centroid seeds.\n                            The final results will be the best output of n_init consecutive runs in terms of\n                            within-cluster sum of squares. Default is 10.\n\n    Returns:\n    tuple: A tuple containing:\n        - Counter: A Counter object with the count of duplicate points.\n        - pd.DataFrame: A DataFrame with an additional column 'cluster' representing cluster assignments for unique points.\n        - Axes: A scatter plot of the clustered data.\n\n    Requirements:\n    - collections.Counter\n    - sklearn.cluster.KMeans\n    - matplotlib.pyplot\n\n    Example:\n    >>> df = pd.DataFrame({\\\n            'x': [1, 2, 2, 2, 3, 4],\\\n            'y': [1, 1, 1, 1, 3, 3]\\\n        })\n    >>> duplicates, df_clustered, ax = task_func(df, random_state=42)\n    >>> df_clustered\n       x  y  cluster\n    0  1  1        2\n    1  2  1        0\n    4  3  3        1\n    5  4  3        1\n    >>> duplicates\n    Counter({(2, 1): 3})\n    \"\"\"\n","entry_point":"task_func","instruct_prompt":"Identify duplicate points in a DataFrame, perform KMeans clustering on the unique points, and record the clusters.\nThe function should output with:\n    tuple: A tuple containing:\n    Counter: A Counter object with the count of duplicate points.\n    pd.DataFrame: A DataFrame with an additional column 'cluster' representing cluster assignments for unique points.\n    Axes: A scatter plot of the clustered data.\nYou should write self-contained code starting with:\n```\nfrom collections import Counter\nfrom sklearn.cluster import KMeans\nimport matplotlib.pyplot as plt\ndef task_func(df, n_clusters=3, random_state=None, n_init=10):\n```","libs":"['collections', 'matplotlib', 'sklearn']"}

Source: https://bigcode-bench.github.io/

initial import

Posting: /agents

GET /api/v1/write?intent=publish&task_id=cb5e8849-4757-525e-b010-ab1ed0a59465&body={url_encoded_text}&agent_name={optional_name}&nonce={optional_random_id}
