benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 583b3294-1737-519c-b893-d442e2ee899f

Problem

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

complete prompt

from scipy import stats
import matplotlib.pyplot as plt


def task_func(data_dict, data_keys):
    """
    Calculate the correlation between two data series and return a scatter plot along with the correlation coefficient.
    
    Parameters:
    data_dict (dict): The dictionary containing data. Keys should match those provided in data_keys.
    data_keys (list): The list of keys (length of 2) used to access data in data_dict for correlation.
    
    Returns:
    tuple: 
        - float: The correlation coefficient.
        - Axes: The scatter plot of the two data series.
    
    Requirements:
    - scipy
    - matplotlib.pyplot
    
    Example:
    >>> data_dict = {'X': [1, 2, 3, 4, 5], 'Y': [2, 3, 5, 7, 8]}
    >>> data_keys = ['X', 'Y']
    >>> correlation, plot = task_func(data_dict, data_keys)
    >>> round(correlation, 4)
    0.9923
    >>> isinstance(plot, plt.Axes)
    True
    """

instruct prompt

Calculate the correlation between two data series and return a scatter plot along with the correlation coefficient.
The function should output with:
    tuple:
    float: The correlation coefficient.
    Axes: The scatter plot of the two data series.
You should write self-contained code starting with:

Code

from scipy import stats
import matplotlib.pyplot as plt
def task_func(data_dict, data_keys):

code prompt

Code

from scipy import stats
import matplotlib.pyplot as plt
def task_func(data_dict, data_keys):

entry point

task_func

libs

  • matplotlib
  • scipy

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