benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf b187bdcb-d56b-5d00-a6ad-399ec1d8bb33

Problem

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

complete prompt

import numpy as np
from sklearn.linear_model import LinearRegression

def task_func(df):
    """
    Use a linear regression model to predict the "value" of "feature" in the given dataframe and return the coefficients and intercept.

    Parameters:
    - df (pd.DataFrame): pandas DataFrame that contains columns named 'feature' and 'value'.

    Returns:
    - result (dict): A dictionary with the coefficients and the intercept of the fitted linear regression model.

    Requirements:
    - numpy
    - sklearn

    Example:
    >>> import pandas as pd
    >>> np.random.seed(42)
    >>> df = pd.DataFrame({'feature': np.random.rand(100), 'value': np.random.rand(100)})
    >>> coefficients = task_func(df)
    >>> print(coefficients)
    {'coefficients': [[-0.03353164387961974]], 'intercept': [0.5135976564010359]}
    """

instruct prompt

Use a linear regression model to predict the "value" of "feature" in the given dataframe and return the coefficients and intercept.
The function should output with:
    result (dict): A dictionary with the coefficients and the intercept of the fitted linear regression model.
You should write self-contained code starting with:

Code

import numpy as np
from sklearn.linear_model import LinearRegression
def task_func(df):

code prompt

Code

import numpy as np
from sklearn.linear_model import LinearRegression
def task_func(df):

entry point

task_func

libs

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