benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 4e8b3cf4-6e43-5451-a7cb-6fce878d4104

Problem

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

complete prompt

import numpy as np
import matplotlib.pyplot as plt
from sklearn.decomposition import PCA


def task_func(x, y, labels):
    """ 
    Perform Principal Component Analysis (PCA) on "x" as x-values and "y" as y-values and record the results with labels.

    Parameters:
    x (list): List of numpy arrays representing the x-values of the data points.
    y (list): List of numpy arrays representing the y-values of the data points.
    labels (list): List of strings representing the labels for the chemical compounds.

    Returns:
    fig: Matplotlib figure object.

    Requirements:
    - numpy
    - matplotlib.pyplot
    - sklearn.decomposition

    Example:
    >>> x = [np.array([1,2,3]), np.array([4,5,6]), np.array([7,8,9])]
    >>> y = [np.array([4,5,6]), np.array([7,8,9]), np.array([10,11,12])]
    >>> labels = ['H₂O', 'O₂', 'CO₂']
    >>> fig = task_func(x, y, labels)
    """

instruct prompt

Perform Principal Component Analysis (PCA) on "x" as x-values and "y" as y-values and record the results with labels.
The function should output with:
    fig: Matplotlib figure object.
You should write self-contained code starting with:

Code

import numpy as np
import matplotlib.pyplot as plt
from sklearn.decomposition import PCA
def task_func(x, y, labels):

code prompt

Code

import numpy as np
import matplotlib.pyplot as plt
from sklearn.decomposition import PCA
def task_func(x, y, labels):

entry point

task_func

libs

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