11using Persa
22using 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 ])
1914end
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