forked from psaris/funq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestsvm.q
21 lines (21 loc) · 967 Bytes
/
testsvm.q
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
\l svm.q
assert:{if[not x~y;'`fail]}
.svm.set_print_string_function `
assert[322i] .svm.version
assert[s] .svm.write_problem prob:.svm.read_problem s:read0 `heart_scale
assert[::] .svm.check_parameter[prob] param:.svm.defparam[prob] .svm.param
assert[prob] .svm.prob_inout prob
m1:.svm.train[prob;param]
m2:.svm.load_model `heart_scale.model
do[1000;m:.svm.load_model `heart_scale.model]
m3:{.svm.save_model[`model] x;m:.svm.load_model[`model];hdel`:model;m} m
mp:`svm_type`kernel_type`gamma
assert[@[m;`param;{y#x};mp]] @[m;`param;{y#x};mp]
do[1000;param ~ .svm.param_inout param]
assert[m] .svm.model_inout m
do[1000;.svm.model_inout m]
assert[1b] .8<avg prob.y=.svm.cross_validation[prob;param;2i]
assert[0i].svm.check_probability_model m
assert[.svm.predict[m;prob.x]] .svm.predict[m] each prob.x
assert[.svm.predict_values[m;prob.x]] flip .svm.predict_values[m] each prob.x
assert[.svm.predict_probability[m;prob.x]] flip .svm.predict_probability[m] each prob.x