benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf f23fe38e-665d-52a9-ace5-66a649a3215b

Problem

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

complete prompt

import pandas as pd
from sklearn.linear_model import LinearRegression

def task_func(d, target='z'):
    """
    Perform linear regression to "x," "y," against "z" from a list of dictionaries "d."

    Parameters:
    d (list): A list of dictionaries.
    target (str): The target variable for the regression.

    Returns:
    LinearRegression: A LinearRegression model.

    Requirements:
    - pandas
    - sklearn.linear_model.LinearRegression

    Examples:
    >>> data = [{'x': 1, 'y': 10, 'z': 5}, {'x': 3, 'y': 15, 'z': 6}, {'x': 2, 'y': 1, 'z': 7}]
    >>> model = task_func(data)
    >>> isinstance(model, LinearRegression)
    True

    >>> data = [{'x': 4, 'y': 20, 'z': 10}, {'x': 5, 'y': 25, 'z': 15}, {'x': 6, 'y': 5, 'z': 20}]
    >>> model = task_func(data, target='y')
    >>> isinstance(model, LinearRegression)
    True
    """

instruct prompt

Perform linear regression to "x," "y," against "z" from a list of dictionaries "d." >>> data = [{'x': 4, 'y': 20, 'z': 10}, {'x': 5, 'y': 25, 'z': 15}, {'x': 6, 'y': 5, 'z': 20}] >>> model = task_func(data, target='y') >>> isinstance(model, LinearRegression) True
The function should output with:
    LinearRegression: A LinearRegression model.
You should write self-contained code starting with:

Code

import pandas as pd
from sklearn.linear_model import LinearRegression
def task_func(d, target='z'):

code prompt

Code

import pandas as pd
from sklearn.linear_model import LinearRegression
def task_func(d, target='z'):

entry point

task_func

libs

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