benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf aca8ff4e-44db-5ba5-829a-f82a801dee13

Problem

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

complete prompt

from scipy.stats import linregress
import matplotlib.pyplot as plt

def task_func(data, column1, column2):
    """
    Perform a linear regression on two columns of a dataset and record the result.
    Additionally, generates a plot representing the original data and the fitted line.

    Parameters:
    data (DataFrame): The dataset.
    column1 (str): The name of the first column.
    column2 (str): The name of the second column.

    Returns:
    tuple: The slope, intercept, r-value, p-value, and standard error of the regression.
    Axes: The matplotlib Axes object containing the plot.

    Raises:
    ValueError: If the specified columns do not exist in the DataFrame.

    Requirements:
    - scipy.stats
    - matplotlib.pyplot

    Example:
    >>> data = pd.DataFrame([[14, 25], [1, 22], [7, 8]], columns=['Column1', 'Column2'])
    >>> result, ax = task_func(data, 'Column1', 'Column2')
    """

instruct prompt

Perform a linear regression on two columns of a dataset and record the result. Additionally, generates a plot representing the original data and the fitted line.
The function should raise the exception for: ValueError: If the specified columns do not exist in the DataFrame.
The function should output with:
    tuple: The slope, intercept, r-value, p-value, and standard error of the regression.
    Axes: The matplotlib Axes object containing the plot.
You should write self-contained code starting with:

Code

from scipy.stats import linregress
import matplotlib.pyplot as plt
def task_func(data, column1, column2):

code prompt

Code

from scipy.stats import linregress
import matplotlib.pyplot as plt
def task_func(data, column1, column2):

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