benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 2a6fb183-b752-5259-bc59-d8056573cec3

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.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score

def task_func(data, columns, target_column):
    """
    Perform a logistic regression on a DataFrame to predict a specific target column.
    
    Parameters:
    - data (numpy.array): The input data as a NumPy array.
    - columns (list): The list of column names.
    - target_column (str): The target column name.

    Returns:
    - accuracy (float): The accuracy of the logistic regression model.

    Requirements:
    - pandas
    - sklearn
    
    Example:
    >>> import numpy as np
    >>> np.random.seed(42)
    >>> data = np.random.randint(0, 100, size=(100, 4))  # Using np to generate random data
    >>> columns = ['A', 'B', 'C', 'target']
    >>> task_func(data, columns, 'target')
    0.0
    """

instruct prompt

Perform a logistic regression on a DataFrame to predict a specific target column.
The function should output with:
    accuracy (float): The accuracy of the logistic regression model.
You should write self-contained code starting with:

Code

import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score
def task_func(data, columns, target_column):

code prompt

Code

import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score
def task_func(data, columns, target_column):

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