libmf 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +125 -0
- data/ext/libmf/extconf.rb +18 -0
- data/lib/libmf.bundle +0 -0
- data/lib/libmf.rb +26 -0
- data/lib/libmf/ffi.rb +62 -0
- data/lib/libmf/model.rb +112 -0
- data/lib/libmf/version.rb +3 -0
- data/vendor/libmf/COPYRIGHT +31 -0
- data/vendor/libmf/Makefile +34 -0
- data/vendor/libmf/Makefile.win +36 -0
- data/vendor/libmf/README +637 -0
- data/vendor/libmf/demo/all_one_matrix.te.txt +1382 -0
- data/vendor/libmf/demo/all_one_matrix.tr.txt +5172 -0
- data/vendor/libmf/demo/binary_matrix.te.txt +1312 -0
- data/vendor/libmf/demo/binary_matrix.tr.txt +4937 -0
- data/vendor/libmf/demo/demo.bat +40 -0
- data/vendor/libmf/demo/demo.sh +58 -0
- data/vendor/libmf/demo/real_matrix.te.txt +794 -0
- data/vendor/libmf/demo/real_matrix.tr.txt +5000 -0
- data/vendor/libmf/mf-predict.cpp +207 -0
- data/vendor/libmf/mf-train.cpp +378 -0
- data/vendor/libmf/mf.cpp +4683 -0
- data/vendor/libmf/mf.def +21 -0
- data/vendor/libmf/mf.h +130 -0
- data/vendor/libmf/windows/mf-predict.exe +0 -0
- data/vendor/libmf/windows/mf-train.exe +0 -0
- data/vendor/libmf/windows/mf.dll +0 -0
- metadata +142 -0
data/vendor/libmf/mf.def
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
LIBRARY mf
|
2
|
+
EXPORTS
|
3
|
+
mf_get_default_param @1
|
4
|
+
read_problem @2
|
5
|
+
mf_save_model @3
|
6
|
+
mf_load_model @4
|
7
|
+
mf_destroy_model @5
|
8
|
+
mf_train @6
|
9
|
+
mf_train_on_disk @7
|
10
|
+
mf_train_with_validation @8
|
11
|
+
mf_train_with_validation_on_disk @9
|
12
|
+
mf_cross_validation @10
|
13
|
+
mf_cross_validation_on_disk @11
|
14
|
+
mf_predict @12
|
15
|
+
calc_rmse @13
|
16
|
+
calc_mae @14
|
17
|
+
calc_gkl @15
|
18
|
+
calc_logloss @16
|
19
|
+
calc_accuracy @17
|
20
|
+
calc_mpr @18
|
21
|
+
calc_auc @19
|
data/vendor/libmf/mf.h
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
#ifndef _LIBMF_H
|
2
|
+
#define _LIBMF_H
|
3
|
+
|
4
|
+
#include <string>
|
5
|
+
#include <utility>
|
6
|
+
|
7
|
+
#ifdef __cplusplus
|
8
|
+
extern "C"
|
9
|
+
{
|
10
|
+
|
11
|
+
namespace mf
|
12
|
+
{
|
13
|
+
#endif
|
14
|
+
|
15
|
+
typedef float mf_float;
|
16
|
+
typedef double mf_double;
|
17
|
+
typedef int mf_int;
|
18
|
+
typedef long long mf_long;
|
19
|
+
|
20
|
+
enum {P_L2_MFR=0, P_L1_MFR=1, P_KL_MFR=2, P_LR_MFC=5, P_L2_MFC=6, P_L1_MFC=7,
|
21
|
+
P_ROW_BPR_MFOC=10, P_COL_BPR_MFOC=11, P_L2_MFOC=12};
|
22
|
+
enum {RMSE=0, MAE=1, GKL=2, LOGLOSS=5, ACC=6, ROW_MPR=10, COL_MPR=11,
|
23
|
+
ROW_AUC=12, COL_AUC=13};
|
24
|
+
|
25
|
+
struct mf_node
|
26
|
+
{
|
27
|
+
mf_int u;
|
28
|
+
mf_int v;
|
29
|
+
mf_float r;
|
30
|
+
};
|
31
|
+
|
32
|
+
struct mf_problem
|
33
|
+
{
|
34
|
+
mf_int m;
|
35
|
+
mf_int n;
|
36
|
+
mf_long nnz;
|
37
|
+
struct mf_node *R;
|
38
|
+
};
|
39
|
+
|
40
|
+
struct mf_parameter
|
41
|
+
{
|
42
|
+
mf_int fun;
|
43
|
+
mf_int k;
|
44
|
+
mf_int nr_threads;
|
45
|
+
mf_int nr_bins;
|
46
|
+
mf_int nr_iters;
|
47
|
+
mf_float lambda_p1;
|
48
|
+
mf_float lambda_p2;
|
49
|
+
mf_float lambda_q1;
|
50
|
+
mf_float lambda_q2;
|
51
|
+
mf_float eta;
|
52
|
+
mf_float alpha;
|
53
|
+
mf_float c;
|
54
|
+
bool do_nmf;
|
55
|
+
bool quiet;
|
56
|
+
bool copy_data;
|
57
|
+
};
|
58
|
+
|
59
|
+
struct mf_parameter mf_get_default_param();
|
60
|
+
|
61
|
+
struct mf_model
|
62
|
+
{
|
63
|
+
mf_int fun;
|
64
|
+
mf_int m;
|
65
|
+
mf_int n;
|
66
|
+
mf_int k;
|
67
|
+
mf_float b;
|
68
|
+
mf_float *P;
|
69
|
+
mf_float *Q;
|
70
|
+
};
|
71
|
+
|
72
|
+
mf_problem read_problem(std::string path);
|
73
|
+
|
74
|
+
mf_int mf_save_model(struct mf_model const *model, char const *path);
|
75
|
+
|
76
|
+
struct mf_model* mf_load_model(char const *path);
|
77
|
+
|
78
|
+
void mf_destroy_model(struct mf_model **model);
|
79
|
+
|
80
|
+
struct mf_model* mf_train(
|
81
|
+
struct mf_problem const *prob,
|
82
|
+
struct mf_parameter param);
|
83
|
+
|
84
|
+
struct mf_model* mf_train_on_disk(
|
85
|
+
char const *tr_path,
|
86
|
+
struct mf_parameter param);
|
87
|
+
|
88
|
+
struct mf_model* mf_train_with_validation(
|
89
|
+
struct mf_problem const *tr,
|
90
|
+
struct mf_problem const *va,
|
91
|
+
struct mf_parameter param);
|
92
|
+
|
93
|
+
struct mf_model* mf_train_with_validation_on_disk(
|
94
|
+
char const *tr_path,
|
95
|
+
char const *va_path,
|
96
|
+
struct mf_parameter param);
|
97
|
+
|
98
|
+
mf_double mf_cross_validation(
|
99
|
+
struct mf_problem const *prob,
|
100
|
+
mf_int nr_folds,
|
101
|
+
struct mf_parameter param);
|
102
|
+
|
103
|
+
mf_double mf_cross_validation_on_disk(
|
104
|
+
char const *prob,
|
105
|
+
mf_int nr_folds,
|
106
|
+
mf_parameter param);
|
107
|
+
|
108
|
+
mf_float mf_predict(struct mf_model const *model, mf_int u, mf_int v);
|
109
|
+
|
110
|
+
mf_double calc_rmse(mf_problem *prob, mf_model *model);
|
111
|
+
|
112
|
+
mf_double calc_mae(mf_problem *prob, mf_model *model);
|
113
|
+
|
114
|
+
mf_double calc_gkl(mf_problem *prob, mf_model *model);
|
115
|
+
|
116
|
+
mf_double calc_logloss(mf_problem *prob, mf_model *model);
|
117
|
+
|
118
|
+
mf_double calc_accuracy(mf_problem *prob, mf_model *model);
|
119
|
+
|
120
|
+
mf_double calc_mpr(mf_problem *prob, mf_model *model, bool transpose);
|
121
|
+
|
122
|
+
mf_double calc_auc(mf_problem *prob, mf_model *model, bool transpose);
|
123
|
+
|
124
|
+
#ifdef __cplusplus
|
125
|
+
} // namespace mf
|
126
|
+
|
127
|
+
} // extern "C"
|
128
|
+
#endif
|
129
|
+
|
130
|
+
#endif // _LIBMF_H
|
Binary file
|
Binary file
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: libmf
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andrew Kane
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-11-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ffi
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '5'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '5'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake-compiler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description:
|
84
|
+
email: andrew@chartkick.com
|
85
|
+
executables: []
|
86
|
+
extensions:
|
87
|
+
- ext/libmf/extconf.rb
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- CHANGELOG.md
|
91
|
+
- LICENSE.txt
|
92
|
+
- README.md
|
93
|
+
- ext/libmf/extconf.rb
|
94
|
+
- lib/libmf.bundle
|
95
|
+
- lib/libmf.rb
|
96
|
+
- lib/libmf/ffi.rb
|
97
|
+
- lib/libmf/model.rb
|
98
|
+
- lib/libmf/version.rb
|
99
|
+
- vendor/libmf/COPYRIGHT
|
100
|
+
- vendor/libmf/Makefile
|
101
|
+
- vendor/libmf/Makefile.win
|
102
|
+
- vendor/libmf/README
|
103
|
+
- vendor/libmf/demo/all_one_matrix.te.txt
|
104
|
+
- vendor/libmf/demo/all_one_matrix.tr.txt
|
105
|
+
- vendor/libmf/demo/binary_matrix.te.txt
|
106
|
+
- vendor/libmf/demo/binary_matrix.tr.txt
|
107
|
+
- vendor/libmf/demo/demo.bat
|
108
|
+
- vendor/libmf/demo/demo.sh
|
109
|
+
- vendor/libmf/demo/real_matrix.te.txt
|
110
|
+
- vendor/libmf/demo/real_matrix.tr.txt
|
111
|
+
- vendor/libmf/mf-predict.cpp
|
112
|
+
- vendor/libmf/mf-train.cpp
|
113
|
+
- vendor/libmf/mf.cpp
|
114
|
+
- vendor/libmf/mf.def
|
115
|
+
- vendor/libmf/mf.h
|
116
|
+
- vendor/libmf/windows/mf-predict.exe
|
117
|
+
- vendor/libmf/windows/mf-train.exe
|
118
|
+
- vendor/libmf/windows/mf.dll
|
119
|
+
homepage: https://github.com/ankane/libmf
|
120
|
+
licenses:
|
121
|
+
- MIT
|
122
|
+
metadata: {}
|
123
|
+
post_install_message:
|
124
|
+
rdoc_options: []
|
125
|
+
require_paths:
|
126
|
+
- lib
|
127
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '2.4'
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
requirements: []
|
138
|
+
rubygems_version: 3.0.3
|
139
|
+
signing_key:
|
140
|
+
specification_version: 4
|
141
|
+
summary: LIBMF - large-scale sparse matrix factorization - for Ruby
|
142
|
+
test_files: []
|