Commit e2f7a45a authored by Stanislav Bohm's avatar Stanislav Bohm

TEST: Cross validation added

parent 8cf4ab31
......@@ -77,9 +77,11 @@ class RunTask(Task):
def map_file_in(self, task, filename):
self.file_ins.append((task, filename))
return self
def map_file_out(self, filename):
self.file_outs.append(filename)
return self
@property
def inputs(self):
......
......@@ -75,7 +75,6 @@ void RunTask::start(DataVector &inputs)
auto& input = *inputs[map.input_index()];
std::string path = get_path(map.filename());
std::string filename = input->get_filename(worker);
llog->alert("FILENAME = {} {}", filename, (unsigned long) &input);
assert(!filename.empty());
llog->debug("Creating symlink of '{}'", map.filename());
if (symlink(filename.c_str(), path.c_str())) {
......
from loomenv import loom_env, LOOM_TESTPROG, LOOM_TEST_DATA_DIR # noqa
import os
IRIS_DATA = os.path.join(LOOM_TEST_DATA_DIR, "iris.data")
loom_env # silence flake8
def test_cv_iris(loom_env):
CHUNKS = 5
CHUNK_SIZE = 150 / CHUNKS # There are 150 irises
loom_env.start(2)
p = loom_env.plan()
a = p.task_open(IRIS_DATA)
b = p.task_run(("sort", "--random-sort", "-"), stdin=a)
chunks = [p.task_split_lines(b, i * CHUNK_SIZE, (i + 1) * CHUNK_SIZE)
for i in xrange(CHUNKS)]
trainsets = [p.task_merge(chunks[:i] + chunks[i+1:])
for i in xrange(CHUNKS)]
models = []
for ts in trainsets:
model = p.task_run("svm-train data")
model.map_file_in(ts, "data")
model.map_file_out("data.model")
models.append(model)
predict = []
for chunk, model in zip(chunks, models):
task = p.task_run("svm-predict testdata model out")
task.map_file_in(chunk, "testdata")
task.map_file_in(model, "model")
predict.append(task)
results = loom_env.submit(p, predict)
assert len(results) == CHUNKS
for line in results:
assert line.startswith("Accuracy = ")
......@@ -6,7 +6,7 @@ import os
FILE1 = os.path.join(LOOM_TEST_DATA_DIR, "file1")
FILE2 = os.path.join(LOOM_TEST_DATA_DIR, "file2")
dir(loom_env) # silence flake8
loom_env # silence flake8
def pytestprog(sleep, op="copy", stamp=False, file_out=None, file_in=None):
......
1 1:-0.555556 2:0.25 3:-0.864407 4:-0.916667
1 1:-0.666667 2:-0.166667 3:-0.864407 4:-0.916667
1 1:-0.777778 3:-0.898305 4:-0.916667
1 1:-0.833333 2:-0.0833334 3:-0.830508 4:-0.916667
1 1:-0.611111 2:0.333333 3:-0.864407 4:-0.916667
1 1:-0.388889 2:0.583333 3:-0.762712 4:-0.75
1 1:-0.833333 2:0.166667 3:-0.864407 4:-0.833333
1 1:-0.611111 2:0.166667 3:-0.830508 4:-0.916667
1 1:-0.944444 2:-0.25 3:-0.864407 4:-0.916667
1 1:-0.666667 2:-0.0833334 3:-0.830508 4:-1
1 1:-0.388889 2:0.416667 3:-0.830508 4:-0.916667
1 1:-0.722222 2:0.166667 3:-0.79661 4:-0.916667
1 1:-0.722222 2:-0.166667 3:-0.864407 4:-1
1 1:-1 2:-0.166667 3:-0.966102 4:-1
1 1:-0.166667 2:0.666667 3:-0.932203 4:-0.916667
1 1:-0.222222 2:1 3:-0.830508 4:-0.75
1 1:-0.388889 2:0.583333 3:-0.898305 4:-0.75
1 1:-0.555556 2:0.25 3:-0.864407 4:-0.833333
1 1:-0.222222 2:0.5 3:-0.762712 4:-0.833333
1 1:-0.555556 2:0.5 3:-0.830508 4:-0.833333
1 1:-0.388889 2:0.166667 3:-0.762712 4:-0.916667
1 1:-0.555556 2:0.416667 3:-0.830508 4:-0.75
1 1:-0.833333 2:0.333333 3:-1 4:-0.916667
1 1:-0.555556 2:0.0833333 3:-0.762712 4:-0.666667
1 1:-0.722222 2:0.166667 3:-0.694915 4:-0.916667
1 1:-0.611111 2:-0.166667 3:-0.79661 4:-0.916667
1 1:-0.611111 2:0.166667 3:-0.79661 4:-0.75
1 1:-0.5 2:0.25 3:-0.830508 4:-0.916667
1 1:-0.5 2:0.166667 3:-0.864407 4:-0.916667
1 1:-0.777778 3:-0.79661 4:-0.916667
1 1:-0.722222 2:-0.0833334 3:-0.79661 4:-0.916667
1 1:-0.388889 2:0.166667 3:-0.830508 4:-0.75
1 1:-0.5 2:0.75 3:-0.830508 4:-1
1 1:-0.333333 2:0.833333 3:-0.864407 4:-0.916667
1 1:-0.666667 2:-0.0833334 3:-0.830508 4:-1
1 1:-0.611111 3:-0.932203 4:-0.916667
1 1:-0.333333 2:0.25 3:-0.898305 4:-0.916667
1 1:-0.666667 2:-0.0833334 3:-0.830508 4:-1
1 1:-0.944444 2:-0.166667 3:-0.898305 4:-0.916667
1 1:-0.555556 2:0.166667 3:-0.830508 4:-0.916667
1 1:-0.611111 2:0.25 3:-0.898305 4:-0.833333
1 1:-0.888889 2:-0.75 3:-0.898305 4:-0.833333
1 1:-0.944444 3:-0.898305 4:-0.916667
1 1:-0.611111 2:0.25 3:-0.79661 4:-0.583333
1 1:-0.555556 2:0.5 3:-0.694915 4:-0.75
1 1:-0.722222 2:-0.166667 3:-0.864407 4:-0.833333
1 1:-0.555556 2:0.5 3:-0.79661 4:-0.916667
1 1:-0.833333 3:-0.864407 4:-0.916667
1 1:-0.444444 2:0.416667 3:-0.830508 4:-0.916667
1 1:-0.611111 2:0.0833333 3:-0.864407 4:-0.916667
2 1:0.5 3:0.254237 4:0.0833333
2 1:0.166667 3:0.186441 4:0.166667
2 1:0.444444 2:-0.0833334 3:0.322034 4:0.166667
2 1:-0.333333 2:-0.75 3:0.0169491 4:-4.03573e-08
2 1:0.222222 2:-0.333333 3:0.220339 4:0.166667
2 1:-0.222222 2:-0.333333 3:0.186441 4:-4.03573e-08
2 1:0.111111 2:0.0833333 3:0.254237 4:0.25
2 1:-0.666667 2:-0.666667 3:-0.220339 4:-0.25
2 1:0.277778 2:-0.25 3:0.220339 4:-4.03573e-08
2 1:-0.5 2:-0.416667 3:-0.0169491 4:0.0833333
2 1:-0.611111 2:-1 3:-0.152542 4:-0.25
2 1:-0.111111 2:-0.166667 3:0.0847457 4:0.166667
2 1:-0.0555556 2:-0.833333 3:0.0169491 4:-0.25
2 1:-1.32455e-07 2:-0.25 3:0.254237 4:0.0833333
2 1:-0.277778 2:-0.25 3:-0.118644 4:-4.03573e-08
2 1:0.333333 2:-0.0833334 3:0.152542 4:0.0833333
2 1:-0.277778 2:-0.166667 3:0.186441 4:0.166667
2 1:-0.166667 2:-0.416667 3:0.0508474 4:-0.25
2 1:0.0555554 2:-0.833333 3:0.186441 4:0.166667
2 1:-0.277778 2:-0.583333 3:-0.0169491 4:-0.166667
2 1:-0.111111 3:0.288136 4:0.416667
2 1:-1.32455e-07 2:-0.333333 3:0.0169491 4:-4.03573e-08
2 1:0.111111 2:-0.583333 3:0.322034 4:0.166667
2 1:-1.32455e-07 2:-0.333333 3:0.254237 4:-0.0833333
2 1:0.166667 2:-0.25 3:0.118644 4:-4.03573e-08
2 1:0.277778 2:-0.166667 3:0.152542 4:0.0833333
2 1:0.388889 2:-0.333333 3:0.288136 4:0.0833333
2 1:0.333333 2:-0.166667 3:0.355932 4:0.333333
2 1:-0.0555556 2:-0.25 3:0.186441 4:0.166667
2 1:-0.222222 2:-0.5 3:-0.152542 4:-0.25
2 1:-0.333333 2:-0.666667 3:-0.0508475 4:-0.166667
2 1:-0.333333 2:-0.666667 3:-0.0847458 4:-0.25
2 1:-0.166667 2:-0.416667 3:-0.0169491 4:-0.0833333
2 1:-0.0555556 2:-0.416667 3:0.38983 4:0.25
2 1:-0.388889 2:-0.166667 3:0.186441 4:0.166667
2 1:-0.0555556 2:0.166667 3:0.186441 4:0.25
2 1:0.333333 2:-0.0833334 3:0.254237 4:0.166667
2 1:0.111111 2:-0.75 3:0.152542 4:-4.03573e-08
2 1:-0.277778 2:-0.166667 3:0.0508474 4:-4.03573e-08
2 1:-0.333333 2:-0.583333 3:0.0169491 4:-4.03573e-08
2 1:-0.333333 2:-0.5 3:0.152542 4:-0.0833333
2 1:-1.32455e-07 2:-0.166667 3:0.220339 4:0.0833333
2 1:-0.166667 2:-0.5 3:0.0169491 4:-0.0833333
2 1:-0.611111 2:-0.75 3:-0.220339 4:-0.25
2 1:-0.277778 2:-0.416667 3:0.0847457 4:-4.03573e-08
2 1:-0.222222 2:-0.166667 3:0.0847457 4:-0.0833333
2 1:-0.222222 2:-0.25 3:0.0847457 4:-4.03573e-08
2 1:0.0555554 2:-0.25 3:0.118644 4:-4.03573e-08
2 1:-0.555556 2:-0.583333 3:-0.322034 4:-0.166667
2 1:-0.222222 2:-0.333333 3:0.0508474 4:-4.03573e-08
3 1:0.111111 2:0.0833333 3:0.694915 4:1
3 1:-0.166667 2:-0.416667 3:0.38983 4:0.5
3 1:0.555555 2:-0.166667 3:0.661017 4:0.666667
3 1:0.111111 2:-0.25 3:0.559322 4:0.416667
3 1:0.222222 2:-0.166667 3:0.627119 4:0.75
3 1:0.833333 2:-0.166667 3:0.898305 4:0.666667
3 1:-0.666667 2:-0.583333 3:0.186441 4:0.333333
3 1:0.666667 2:-0.25 3:0.79661 4:0.416667
3 1:0.333333 2:-0.583333 3:0.627119 4:0.416667
3 1:0.611111 2:0.333333 3:0.728813 4:1
3 1:0.222222 3:0.38983 4:0.583333
3 1:0.166667 2:-0.416667 3:0.457627 4:0.5
3 1:0.388889 2:-0.166667 3:0.525424 4:0.666667
3 1:-0.222222 2:-0.583333 3:0.355932 4:0.583333
3 1:-0.166667 2:-0.333333 3:0.38983 4:0.916667
3 1:0.166667 3:0.457627 4:0.833333
3 1:0.222222 2:-0.166667 3:0.525424 4:0.416667
3 1:0.888889 2:0.5 3:0.932203 4:0.75
3 1:0.888889 2:-0.5 3:1 4:0.833333
3 1:-0.0555556 2:-0.833333 3:0.355932 4:0.166667
3 1:0.444444 3:0.59322 4:0.833333
3 1:-0.277778 2:-0.333333 3:0.322034 4:0.583333
3 1:0.888889 2:-0.333333 3:0.932203 4:0.583333
3 1:0.111111 2:-0.416667 3:0.322034 4:0.416667
3 1:0.333333 2:0.0833333 3:0.59322 4:0.666667
3 1:0.611111 3:0.694915 4:0.416667
3 1:0.0555554 2:-0.333333 3:0.288136 4:0.416667
3 1:-1.32455e-07 2:-0.166667 3:0.322034 4:0.416667
3 1:0.166667 2:-0.333333 3:0.559322 4:0.666667
3 1:0.611111 2:-0.166667 3:0.627119 4:0.25
3 1:0.722222 2:-0.333333 3:0.728813 4:0.5
3 1:1 2:0.5 3:0.830508 4:0.583333
3 1:0.166667 2:-0.333333 3:0.559322 4:0.75
3 1:0.111111 2:-0.333333 3:0.38983 4:0.166667
3 1:-1.32455e-07 2:-0.5 3:0.559322 4:0.0833333
3 1:0.888889 2:-0.166667 3:0.728813 4:0.833333
3 1:0.111111 2:0.166667 3:0.559322 4:0.916667
3 1:0.166667 2:-0.0833334 3:0.525424 4:0.416667
3 1:-0.0555556 2:-0.166667 3:0.288136 4:0.416667
3 1:0.444444 2:-0.0833334 3:0.491525 4:0.666667
3 1:0.333333 2:-0.0833334 3:0.559322 4:0.916667
3 1:0.444444 2:-0.0833334 3:0.38983 4:0.833333
3 1:-0.166667 2:-0.416667 3:0.38983 4:0.5
3 1:0.388889 3:0.661017 4:0.833333
3 1:0.333333 2:0.0833333 3:0.59322 4:1
3 1:0.333333 2:-0.166667 3:0.423729 4:0.833333
3 1:0.111111 2:-0.583333 3:0.355932 4:0.5
3 1:0.222222 2:-0.166667 3:0.423729 4:0.583333
3 1:0.0555554 2:0.166667 3:0.491525 4:0.833333
3 1:-0.111111 2:-0.166667 3:0.38983 4:0.416667
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment