benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf c8892ed1-fa10-5118-9cfb-81eb690972c3

Problem

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

complete prompt

import numpy as np
from scipy import stats
from sklearn.preprocessing import MinMaxScaler
import matplotlib.pyplot as plt


def task_func(data_dict):
    """
    Performs the following operations on the input dictionary 'data_dict':
    1. Adds a key "a" with a value of 1.
    2. Conducts statistical analysis on its values (mean, median, mode), by rounding the mean to 2 decimal places.
    3. Normalizes the values using MinMaxScaler to a range of (0, 1).
    4. Plots a histogram of the normalized values, with the title "Histogram of Normalized Values", and x labels "Value" and y labels "Frequency".
    
    Parameters:
    data_dict (dict): The dictionary to be processed, containing numerical values.
    
    Returns:
    tuple: A tuple containing:
        - dict: The processed dictionary with key "a" added.
        - dict: A dictionary containing statistical properties (mean, median, mode).
        - matplotlib.axes.Axes: The histogram plot of normalized values.
    
    Requirements:
    - numpy
    - scipy
    - sklearn.preprocessing
    - matplotlib.pyplot
    
    Example:
    >>> data, stats, plot = task_func({'key': 5, 'another_key': 10})
    >>> data
    {'key': 5, 'another_key': 10, 'a': 1}
    >>> stats
    {'mean': 5.33, 'median': 5.0, 'mode': array([1])}
    """

instruct prompt

Performs the following operations on the input dictionary 'data_dict': 1. Adds a key "a" with a value of 1. 2. Conducts statistical analysis on its values (mean, median, mode), by rounding the mean to 2 decimal places. 3. Normalizes the values using MinMaxScaler to a range of (0, 1). 4. Plots a histogram of the normalized values, with the title "Histogram of Normalized Values", and x labels "Value" and y labels "Frequency".
The function should output with:
    tuple: A tuple containing:
    dict: The processed dictionary with key "a" added.
    dict: A dictionary containing statistical properties (mean, median, mode).
    matplotlib.axes.Axes: The histogram plot of normalized values.
You should write self-contained code starting with:

Code

import numpy as np
from scipy import stats
from sklearn.preprocessing import MinMaxScaler
import matplotlib.pyplot as plt
def task_func(data_dict):

code prompt

Code

import numpy as np
from scipy import stats
from sklearn.preprocessing import MinMaxScaler
import matplotlib.pyplot as plt
def task_func(data_dict):

entry point

task_func

libs

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