benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 8777bf02-d9c6-5742-a2ef-adafb2cc0e60

Problem

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

complete prompt

import numpy as np
from sklearn.decomposition import PCA

def task_func(tuples_list, n_components):
    """
    Perform Principal Component Analysis (PCA) on a list of tuples.
    
    Parameters:
    - tuples_list (list): The list of tuples.
    
    Returns:
    - transformed_data (ndarray): The transformed data.

    Requirements:
    - numpy
    - sklearn
    
    Example:
    >>> data = task_func([(1, 2, 3, 4), (5, 6, 7, 8), (9, 10, 11, 12)], 2)
    >>> print(data)
    [[ 8.00000000e+00  3.84592537e-16]
     [ 0.00000000e+00  0.00000000e+00]
     [-8.00000000e+00  3.84592537e-16]]
    """

instruct prompt

Perform Principal Component Analysis (PCA) on a list of tuples.
The function should output with:
    transformed_data (ndarray): The transformed data.
You should write self-contained code starting with:

Code

import numpy as np
from sklearn.decomposition import PCA
def task_func(tuples_list, n_components):

code prompt

Code

import numpy as np
from sklearn.decomposition import PCA
def task_func(tuples_list, n_components):

entry point

task_func

libs

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