benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf a70129c5-da1c-5a67-bb69-c07eab3c593b

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.preprocessing import MinMaxScaler


def task_func(data_dict, data_keys):
    """
    Normalize data specified by keys in a dictionary using MinMax scaling and plot the results. This function is
    useful for preprocessing data for machine learning models where data scaling can impact performance.

    Parameters:
    data_dict (dict): A dictionary where keys map to lists of numeric values.
    data_keys (list): Keys within the dictionary whose corresponding values are to be normalized.

    Returns:
    tuple: A tuple containing a DataFrame of normalized values and a matplotlib Axes object representing a plot of the
    normalized data.

    Requirements:
    - pandas
    - sklearn

    Raises:
    ValueError: If no keys in `data_keys` are found in `data_dict`.

    Example:
    >>> data_dict = {'A': [1, 2, 3], 'B': [4, 5, 6]}
    >>> data_keys = ['A', 'B']
    >>> normalized_df, ax = task_func(data_dict, data_keys)
    >>> print(normalized_df.to_string(index=False))
      A   B
    0.0 0.0
    0.5 0.5
    1.0 1.0
    """

instruct prompt

Normalize data specified by keys in a dictionary using MinMax scaling and plot the results. This function is useful for preprocessing data for machine learning models where data scaling can impact performance.
The function should raise the exception for: ValueError: If no keys in `data_keys` are found in `data_dict`.
The function should output with:
    tuple: A tuple containing a DataFrame of normalized values and a matplotlib Axes object representing a plot of the
    normalized data.
You should write self-contained code starting with:

Code

import pandas as pd
from sklearn.preprocessing import MinMaxScaler
def task_func(data_dict, data_keys):

code prompt

Code

import pandas as pd
from sklearn.preprocessing import MinMaxScaler
def task_func(data_dict, data_keys):

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