#468easyMachine Learning
Feature Normalization
Time Limit: 2sMemory: 256MB
Problem
Given a feature vector, compute two normalizations commonly used in machine learning:
-
Z-score normalization (standardization): where is the mean and is the population standard deviation.
-
Min-max normalization: , scaling values to .
Input Format
Space-separated floats: the feature values.
Output Format
- Line 1: Z-score normalized values (space-separated, 4 decimal places)
- Line 2: Min-max normalized values (space-separated, 4 decimal places)
Examples
Example 1
Input(Space-separated floats: the feature values.)
1 2 3 4 5
Output
-1.4142 -0.7071 0.0000 0.7071 1.4142 0.0000 0.2500 0.5000 0.7500 1.0000
Mean=3, pop std=sqrt(2)=1.4142. Z-scores: (-1.4142,-0.7071,0,0.7071,1.4142). Min=1, Max=5. Min-max: (0,0.25,0.5,0.75,1).
Example 2
Input(Space-separated floats: the feature values.)
10 20 30
Output
-1.2247 0.0000 1.2247 0.0000 0.5000 1.0000
Mean=20, pop std=8.1650. Z-scores: (-1.2247,0,1.2247). Min=10, Max=30. Min-max: (0,0.5,1).
Constraints
- •2 ≤ number of values ≤ 50
- •-10000 ≤ each value ≤ 10000
- •Population standard deviation > 0 (not all values identical)
- •Max > Min (not all values identical)
- •Output to 4 decimal places
Loading interactive editor…