Skip to content

Commit

Permalink
Use helper routine
Browse files Browse the repository at this point in the history
  • Loading branch information
titsuki committed Jan 26, 2017
1 parent 1d5da15 commit 4c5f744
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion t/05-epssvr.t
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use Algorithm::LibSVM::Model;
my @train = (1..100).map: { ((2.0 * $_),"1:$_").join(" ") };
my Algorithm::LibSVM::Problem $problem = $libsvm.load-problem(@train);
my $model = $libsvm.train($problem, $parameter);
my Pair @test = @train.map(*.split(" ")[1]).pick.split(" ")>>.split(":").map: { .[0].Int => .[1].Num };
my Pair @test = parse-libsvmformat(@train.pick).head<pairs>.flat;
my $actual = $model.predict(features => @test)<label>;
my $expected = 2.0 * @test[0].value;
ok $expected - 0.1e0 <= $actual <= $expected + 0.1e0;
Expand Down
2 changes: 1 addition & 1 deletion t/06-nusvr.t
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use Algorithm::LibSVM::Model;
my @train = (1..100).map: { ((2.0 * $_),"1:$_").join(" ") };
my Algorithm::LibSVM::Problem $problem = $libsvm.load-problem(@train);
my $model = $libsvm.train($problem, $parameter);
my Pair @test = @train.map(*.split(" ")[1]).pick.split(" ")>>.split(":").map: { .[0].Int => .[1].Num };
my Pair @test = parse-libsvmformat(@train.pick).head<pairs>.flat;
my $actual = $model.predict(features => @test)<label>;
my $expected = 2.0 * @test[0].value;
ok $expected - 0.1e0 <= $actual <= $expected + 0.1e0;
Expand Down

0 comments on commit 4c5f744

Please sign in to comment.