-
Notifications
You must be signed in to change notification settings - Fork 80
/
demo.sh
58 lines (53 loc) · 2.74 KB
/
demo.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/sh
train=../mf-train
predict=../mf-predict
##########################################################################
# Build package if no binary found and this script is exectuted via the
# following command.
# libmf/demo > sh demo.sh
##########################################################################
if [ ! -s $train ] || [ ! -s $predict ]
then
(cd .. && make)
fi
##########################################################################
# Real-valued matrix factorization (RVMF)
##########################################################################
echo "--------------------------------"
echo "Real-valued matrix factorization"
echo "--------------------------------"
# In-memory training with holdout valudation
$train -f 0 -l2 0.05 -k 100 -t 10 -p real_matrix.te.txt real_matrix.tr.txt rvmf_model.txt
# Do prediction and show MAE
$predict -e 1 real_matrix.te.txt rvmf_model.txt rvmf_output.txt
##########################################################################
# Binary matrix factorization (BMF)
##########################################################################
echo "---------------------------"
echo "binary matrix factorization"
echo "---------------------------"
# In-memory training with holdout valudation
$train -f 5 -l2 0.01 -k 64 -p binary_matrix.te.txt binary_matrix.tr.txt bmf_model.txt
# Do prediction and show accuracy
$predict -e 6 binary_matrix.te.txt bmf_model.txt bmf_output.txt
##########################################################################
# One-class matrix factorization (OCMF)
##########################################################################
echo "-----------------------------------------------------------------"
echo "one-class matrix factorization using a stochastic gradient method"
echo "-----------------------------------------------------------------"
# In-memory training with holdout validation
$train -f 10 -l2 0.01 -k 32 -p all_one_matrix.te.txt all_one_matrix.tr.txt ocmf_model.txt
# Do prediction and show row-oriented MPR
$predict -e 10 all_one_matrix.te.txt ocmf_model.txt ocmf_output.txt
# Do prediction and show row-oriented AUC
$predict -e 12 all_one_matrix.te.txt ocmf_model.txt ocmf_output.txt
echo "----------------------------------------------------------------"
echo "one-class matrix factorization using a coordinate descent method"
echo "----------------------------------------------------------------"
# In-memory training with holdout validation
$train -f 12 -l2 0.01 -k 32 -a 0.001 -c 0.0001 -p all_one_matrix.te.txt all_one_matrix.tr.txt ocmf_model.txt
# Do prediction and show row-oriented MPR
$predict -e 10 all_one_matrix.te.txt ocmf_model.txt ocmf_output.txt
# Do prediction and show row-oriented AUC
$predict -e 12 all_one_matrix.te.txt ocmf_model.txt ocmf_output.txt