benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 12e79bb8-974b-5170-89c5-3a535573de1e

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(df, target):
    """
    Perform a linear regression analysis on a given DataFrame.
    
    Parameters:
    - df (pd.DataFrame): The pandas DataFrame.
    - target (str): The target variable.
    
    Returns:
    - score (float): The R-squared score of the model.

    Requirements:
    - pandas
    - sklearn

    Example:
    >>> import numpy as np
    >>> np.random.seed(42)
    >>> df = pd.DataFrame({'feature': np.random.rand(100), 'target': np.random.rand(100)})  # Explicitly using pd
    >>> r_squared = task_func(df, 'target')
    >>> print(r_squared)
    0.0011582111228732872
    """

instruct prompt

Perform a linear regression analysis on a given DataFrame.
The function should output with:
    score (float): The R-squared score of the model.
You should write self-contained code starting with:

Code

import pandas as pd
from sklearn.linear_model import LinearRegression
def task_func(df, target):

code prompt

Code

import pandas as pd
from sklearn.linear_model import LinearRegression
def task_func(df, target):

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