benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 0e17f1be-7a42-5cc6-9b17-df8c0d45f2bb

Problem

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

complete prompt

import pandas as pd
import random
from sklearn.model_selection import train_test_split

def task_func(n_data_points=10000, min_value=0.0, max_value=10.0, test_size=0.2):
    '''
    Generate a random set of floating-point numbers within a specified range, truncate each value to 3 decimal places,
    and divide the data into train and test sets based on a given test size.

    Parameters:
    - n_data_points (int): Number of data points to generate. Default is 10000.
    - min_value (float): Minimum value of the generated data points. Default is 0.0.
    - max_value (float): Maximum value of the generated data points. Default is 10.0.
    - test_size (float): Proportion of the dataset to include in the test split. Default is 0.2.

    Returns:
    tuple: A tuple with two pandas DataFrames (train set, test set).

    Requirements:
    - pandas
    - random
    - sklearn.model_selection

    Note:
    - The function use "Value" for the column name in the DataFrames (train set, test set) that being returned.

    Example:
    >>> random.seed(0)
    >>> train_data, test_data = task_func()
    >>> print(train_data.shape[0])
    8000
    >>> print(test_data.shape[0])
    2000
    >>> random.seed(0)
    >>> train_data, test_data = task_func(n_data_points=500, min_value=1.0, max_value=1.0, test_size=0.3)
    >>> print(train_data.shape[0])
    350
    >>> print(test_data.shape[0])
    150
    >>> print(test_data.iloc[0]['Value'])
    1.0
    '''

instruct prompt

Generate a random set of floating-point numbers within a specified range, truncate each value to 3 decimal places, and divide the data into train and test sets based on a given test size.
Note that: The function use "Value" for the column name in the DataFrames (train set, test set) that being returned.
The function should output with:
    tuple: A tuple with two pandas DataFrames (train set, test set).
You should write self-contained code starting with:

Code

import pandas as pd
import random
from sklearn.model_selection import train_test_split
def task_func(n_data_points=10000, min_value=0.0, max_value=10.0, test_size=0.2):

code prompt

Code

import pandas as pd
import random
from sklearn.model_selection import train_test_split
def task_func(n_data_points=10000, min_value=0.0, max_value=10.0, test_size=0.2):

entry point

task_func

libs

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