TensorTonic
Problems
Implement Min-Max Normalization
Data ProcessingFeature Engineering
Easy

Scale numeric data to the interval [0,1][0,1][0,1]. For each slice selected by axis, compute

x′=x−xmin⁡xmax⁡−xmin⁡x' = \frac{x - x_{\min}}{x_{\max} - x_{\min}}x′=xmax​−xmin​x−xmin​​

Here, xmin⁡x_{\min}xmin​ and xmax⁡x_{\max}xmax​ are the minimum and maximum of the same slice. Use column-wise slices when axis=0 and row-wise slices when axis=1. If a slice has range at most eps, return zeros for that slice. Return the scaled values as a NumPy array.

Loading visualization...

Examples

Input: X = [[1, 2], [3, 6], [5, 10]], axis = 0, eps = 1e-12

Output: [[0.0, 0.0], [0.5, 0.5], [1.0, 1.0]]

Explanation: Each column is scaled using its own minimum and maximum.

Input: X = [[1, 2], [3, 6], [5, 10]], axis = 1, eps = 1e-12

Output: [[0.0, 1.0], [0.0, 1.0], [0.0, 1.0]]

Hint 1

Use np.min(..., keepdims=True) and np.max(..., keepdims=True) along axis.

Hint 2

Use np.where(data_range > eps, data_range, 1.0) to build a safe denominator.

Requirements

  • Compute minima and maxima along the selected axis
  • Preserve dimensions during reductions so values broadcast back to X
  • Map every slice with range at most eps to zeros
  • Return a NumPy array of floating-point values

Constraints

  • X is a nonempty one-dimensional or two-dimensional numeric list
  • axis is 0 for one-dimensional inputs and either 0 or 1 for two-dimensional inputs
  • eps is positive
  • Use NumPy only
Try Similar Problems
Streaming Min-Max NormalizationMediumImplement Robust Scaling in PythonMediumMin-Max Scale Each Feature Column in PythonMediumOne-Hot Encoding (Multi-class)MediumImplement z-Score StandardizationEasyBinningEasyLog Transform Features in PythonEasyWinsorize Data by Percentile in PythonMediumMissing Value ImputationEasyAngle FeaturesEasyFeature ScalingEasyDistance MetricsEasy
Scratchpad

Accepts: array

Accepts: number

Accepts: number

You must run your code first.
Implement Min-Max Normalization

Implement Min-Max Normalization

Data ProcessingFeature Engineering
Easy

Scale numeric data to the interval [0,1][0,1][0,1]. For each slice selected by axis, compute

x′=x−xmin⁡xmax⁡−xmin⁡x' = \frac{x - x_{\min}}{x_{\max} - x_{\min}}x′=xmax​−xmin​x−xmin​​

Here, xmin⁡x_{\min}xmin​ and xmax⁡x_{\max}xmax​ are the minimum and maximum of the same slice. Use column-wise slices when axis=0 and row-wise slices when axis=1. If a slice has range at most eps, return zeros for that slice. Return the scaled values as a NumPy array.

Loading visualization...

Examples

Input: X = [[1, 2], [3, 6], [5, 10]], axis = 0, eps = 1e-12

Output: [[0.0, 0.0], [0.5, 0.5], [1.0, 1.0]]

Explanation: Each column is scaled using its own minimum and maximum.

Input: X = [[1, 2], [3, 6], [5, 10]], axis = 1, eps = 1e-12

Output: [[0.0, 1.0], [0.0, 1.0], [0.0, 1.0]]

Hint 1

Use np.min(..., keepdims=True) and np.max(..., keepdims=True) along axis.

Hint 2

Use np.where(data_range > eps, data_range, 1.0) to build a safe denominator.

Requirements

  • Compute minima and maxima along the selected axis
  • Preserve dimensions during reductions so values broadcast back to X
  • Map every slice with range at most eps to zeros
  • Return a NumPy array of floating-point values

Constraints

  • X is a nonempty one-dimensional or two-dimensional numeric list
  • axis is 0 for one-dimensional inputs and either 0 or 1 for two-dimensional inputs
  • eps is positive
  • Use NumPy only
Try Similar Problems
Streaming Min-Max NormalizationMediumImplement Robust Scaling in PythonMediumMin-Max Scale Each Feature Column in PythonMediumOne-Hot Encoding (Multi-class)MediumImplement z-Score StandardizationEasyBinningEasyLog Transform Features in PythonEasyWinsorize Data by Percentile in PythonMediumMissing Value ImputationEasyAngle FeaturesEasyFeature ScalingEasyDistance MetricsEasy
Scratchpad

Accepts: array

Accepts: number

Accepts: number

You must run your code first.
Problems
Loading...
1 / 1