Skip to content

Commit b2394b5

Browse files
committed
create first tests
1 parent be0e696 commit b2394b5

File tree

2 files changed

+36
-21
lines changed

2 files changed

+36
-21
lines changed

Project.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1111
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1212

1313
[compat]
14-
julia = "^1"
15-
Persa = "^0.1"
14+
julia = "1"
15+
Persa = "0.2"
1616
ProgressMeter = "^1.1"
1717

1818
[extras]
19-
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
19+
DatasetsCF = "6bac03b7-bcd8-55bf-9a08-86b9b673b6cc"
2020
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2121

2222
[targets]
23-
test = ["Test", "DataFrames"]
23+
test = ["Test", "DatasetsCF"]

test/runtests.jl

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,37 @@
11
using Persa
22
using Test
3-
using DataFrames
4-
5-
function createdummydatasetone()
6-
df = DataFrame()
7-
df[!, :user] = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7]
8-
df[!, :item] = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 4, 5, 6, 2, 4, 5]
9-
df[!, :rating] = [2.5, 3.5, 3.0, 3.5, 2.5, 3.0, 3, 3.5, 1.5, 5, 3, 3.5, 2.5, 3.0, 3.5, 4.0, 3.5, 3.0, 4.0, 2.5, 4.5, 3.0, 4.0, 2.0, 3.0, 2.0, 3.0, 3.0, 4.0, 5.0, 3.5, 3.0, 4.5, 4.0, 1.0]
10-
return df
11-
end
3+
using DatasetsCF
4+
5+
using ModelBasedCF
6+
7+
dataset = DatasetsCF.MovieLens()
128

13-
function createdummydatasettwo()
14-
df = DataFrame()
15-
df[!, :user] = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7]
16-
df[!, :item] = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 4, 5, 6, 2, 4, 5]
17-
df[!, :rating] = [2, 7, 3, 3, 8, 3, 3, 3, 1, 9, 3, 3, 2, 3, 10, 4, 3, 3, 4, 2, 4, 3, 4, 2, 3, 2, 3, 3, 4, 5, 9, 10, 7, 6, 8]
18-
return df
9+
@testset "Random Model Tests" begin
10+
model = ModelBasedCF.RandomModel(dataset)
11+
Persa.train!(model, dataset)
12+
13+
@test !isnan(model[1,1])
1914
end
20-
####
2115

22-
@test true
16+
@testset "Factorization Matrix Models Tests" begin
17+
@testset "Baseline Tests" begin
18+
model = ModelBasedCF.Baseline(dataset)
19+
Persa.train!(model, dataset, max_epochs = 1)
20+
21+
@test !isnan(model[1,1])
22+
end
23+
24+
@testset "RSVD Tests" begin
25+
model = ModelBasedCF.RSVD(dataset, 1)
26+
Persa.train!(model, dataset, max_epochs = 1)
27+
28+
@test !isnan(model[1,1])
29+
end
30+
31+
@testset "IRSVD Tests" begin
32+
model = ModelBasedCF.IRSVD(dataset, 1)
33+
Persa.train!(model, dataset, max_epochs = 1)
34+
35+
@test !isnan(model[1,1])
36+
end
37+
end

0 commit comments

Comments
 (0)