#467easyMachine Learning
K-Fold Cross-Validation
Time Limit: 2sMemory: 256MB
Problem
You are evaluating a model using -fold cross-validation on data points. Each fold produces a test error .
Compute:
-
The mean CV error:
-
The standard error: where
Input Format
- Line 1: Two space-separated integers
N K - Line 2: space-separated floats (the fold errors)
Output Format
Two space-separated values: mean_error standard_error, each to 4 decimal places.
Examples
Example 1
Input(Line 1: Two space-separated integers N K)
100 5 0.12 0.15 0.11 0.14 0.13
Output
0.1300 0.0071
Mean = 0.13. Sample var = 0.00025. SE = sqrt(0.00025/5) = 0.0071.
Example 2
Input(Line 1: Two space-separated integers N K)
90 10 0.20 0.18 0.22 0.19 0.21 0.17 0.20 0.23 0.18 0.22
Output
0.2000 0.0063
Mean = 0.20. Sample var = 0.000400/9 = 0.0000444. SE = sqrt(0.0000444/10) = 0.0021. Wait: s^2 = sum of (ei-0.2)^2 / 9. Let me recompute. Deviations: 0,-.02,.02,-.01,.01,-.03,0,.03,-.02,.02. Sum sq = .0004+.0004+.0001+.0001+.0009+0+.0009+.0004+.0004 = 0.0036. s^2 = 0.0036/9 = 0.0004. SE = sqrt(0.0004/10) = 0.0063.
Constraints
- •2 ≤ K ≤ N
- •2 ≤ N ≤ 100000
- •0 ≤ each error ≤ 1
- •Output mean error and standard error to 4 decimal places
Loading interactive editor…