Created
February 22, 2013 06:36
-
-
Save vabenjamin/5011261 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def test_n_fold_validation | |
data = [] | |
data << [4,3,1] << [1,1,3] << [5,2,1] << [6,9,7] << [9,8,9] << [7,3,5] << [11,4,2] << [12,1,8] << [3,8,6] | |
number_of_folds = 4 | |
folds = [] | |
folds << BrilliantRuby::ML.n_fold_validation(number_of_folds, data) | |
assert(folds.length == 4, "Unexpected number of folds created") | |
end | |
---------------------------- | |
def self.n_fold_validation(n_folds, data) | |
#create bins | |
p data | |
.. | |
output: | |
3 | |
1 | |
1 | |
1 | |
3 | |
5 | |
2 | |
1 | |
6 | |
9 | |
7 | |
9 | |
8 | |
9 | |
7 | |
3 | |
5 | |
11 | |
4 | |
2 | |
12 | |
1 | |
8 | |
3 | |
8 | |
6 | |
4 | |
3 | |
1 | |
1 | |
1 | |
3 | |
5 | |
2 | |
1 | |
6 | |
9 | |
7 | |
9 | |
8 | |
9 | |
7 | |
3 | |
5 | |
11 | |
4 | |
2 | |
12 | |
1 | |
8 | |
3 | |
8 | |
6 | |
4 | |
3 | |
1 | |
1 | |
1 | |
3 | |
5 | |
2 | |
1 | |
6 | |
9 | |
7 | |
9 | |
8 | |
9 | |
7 | |
3 | |
5 | |
11 | |
4 | |
2 | |
12 | |
1 | |
8 | |
3 | |
8 | |
6 | |
4 | |
3 | |
1 | |
1 | |
1 | |
3 | |
5 | |
2 | |
1 | |
6 | |
9 | |
7 | |
9 | |
8 | |
7 | |
3 | |
5 | |
11 | |
4 | |
2 | |
12 | |
1 | |
8 | |
6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment