xlearn 0.1.0 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +28 -1
- data/LICENSE.txt +202 -22
- data/NOTICE.txt +14 -0
- data/README.md +121 -15
- data/lib/xlearn.rb +3 -1
- data/lib/xlearn/dmatrix.rb +42 -5
- data/lib/xlearn/ffi.rb +1 -6
- data/lib/xlearn/ffm.rb +19 -0
- data/lib/xlearn/fm.rb +12 -0
- data/lib/xlearn/model.rb +80 -12
- data/lib/xlearn/version.rb +1 -1
- data/vendor/LICENSE +201 -0
- data/vendor/NOTICE +108 -0
- data/vendor/libxlearn_api.dylib +0 -0
- data/vendor/libxlearn_api.so +0 -0
- data/vendor/xlearn_api.dll +0 -0
- metadata +53 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db5aa58044f0c7a4b39541599ac60363e32db0ef0583ea5ab2d200b5d355228d
|
4
|
+
data.tar.gz: 6d43254012b3ccf9a2ff23cceeff218e5260970d900d6b5634f122aa6c9b0127
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c539cdce4f80deab0306e45b32ed27a98d5e6e90151b7c8d1af4e06d90ed96c404b86beefd79b0d7018b757c2fcee5bf739fd6632dd0fc5baf12a30c5ac94c3b
|
7
|
+
data.tar.gz: 6b93fea811923b106daf660a0dd876ba1e79fcd525c6f8caca4fc1c83ca835caf60644e4db974a09a6bffc0718dcd0d8a41798745eeee818685ddd58d6bd89b4
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,30 @@
|
|
1
|
-
## 0.1.
|
1
|
+
## 0.1.5 (2020-08-22)
|
2
|
+
|
3
|
+
- Added support for Rover
|
4
|
+
- Improved error message when not fit
|
5
|
+
|
6
|
+
## 0.1.4 (2020-02-11)
|
7
|
+
|
8
|
+
- Fixed `Could not find xLearn` error on some Linux platforms
|
9
|
+
|
10
|
+
## 0.1.3 (2020-02-09)
|
11
|
+
|
12
|
+
- Fixed illegal instruction error on some Linux platforms
|
13
|
+
|
14
|
+
## 0.1.2 (2020-01-26)
|
15
|
+
|
16
|
+
- Changed to Apache 2.0 license to match xLearn
|
17
|
+
- Added shared libraries
|
18
|
+
- Don't save `bin` file by default
|
19
|
+
|
20
|
+
## 0.1.1 (2019-10-13)
|
21
|
+
|
22
|
+
- Added `cv` method
|
23
|
+
- Added `partial_fit` method
|
24
|
+
- Added `save_txt` method
|
25
|
+
- Added `bias_term`, `linear_term`, and `latent_factors` methods
|
26
|
+
- Added support for Daru and Numo
|
27
|
+
|
28
|
+
## 0.1.0 (2019-10-11)
|
2
29
|
|
3
30
|
- First release
|
data/LICENSE.txt
CHANGED
@@ -1,22 +1,202 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
1
|
+
|
2
|
+
Apache License
|
3
|
+
Version 2.0, January 2004
|
4
|
+
http://www.apache.org/licenses/
|
5
|
+
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
7
|
+
|
8
|
+
1. Definitions.
|
9
|
+
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
12
|
+
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
14
|
+
the copyright owner that is granting the License.
|
15
|
+
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
17
|
+
other entities that control, are controlled by, or are under common
|
18
|
+
control with that entity. For the purposes of this definition,
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
20
|
+
direction or management of such entity, whether by contract or
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
23
|
+
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
25
|
+
exercising permissions granted by this License.
|
26
|
+
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
28
|
+
including but not limited to software source code, documentation
|
29
|
+
source, and configuration files.
|
30
|
+
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
32
|
+
transformation or translation of a Source form, including but
|
33
|
+
not limited to compiled object code, generated documentation,
|
34
|
+
and conversions to other media types.
|
35
|
+
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
37
|
+
Object form, made available under the License, as indicated by a
|
38
|
+
copyright notice that is included in or attached to the work
|
39
|
+
(an example is provided in the Appendix below).
|
40
|
+
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
47
|
+
the Work and Derivative Works thereof.
|
48
|
+
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
50
|
+
the original version of the Work and any modifications or additions
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
62
|
+
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
65
|
+
subsequently incorporated within the Work.
|
66
|
+
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
73
|
+
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
79
|
+
where such license applies only to those patent claims licensable
|
80
|
+
by such Contributor that are necessarily infringed by their
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
83
|
+
institute patent litigation against any entity (including a
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
86
|
+
or contributory patent infringement, then any patent licenses
|
87
|
+
granted to You under this License for that Work shall terminate
|
88
|
+
as of the date such litigation is filed.
|
89
|
+
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
92
|
+
modifications, and in Source or Object form, provided that You
|
93
|
+
meet the following conditions:
|
94
|
+
|
95
|
+
(a) You must give any other recipients of the Work or
|
96
|
+
Derivative Works a copy of this License; and
|
97
|
+
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
99
|
+
stating that You changed the files; and
|
100
|
+
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
103
|
+
attribution notices from the Source form of the Work,
|
104
|
+
excluding those notices that do not pertain to any part of
|
105
|
+
the Derivative Works; and
|
106
|
+
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
109
|
+
include a readable copy of the attribution notices contained
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
112
|
+
of the following places: within a NOTICE text file distributed
|
113
|
+
as part of the Derivative Works; within the Source form or
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
115
|
+
within a display generated by the Derivative Works, if and
|
116
|
+
wherever such third-party notices normally appear. The contents
|
117
|
+
of the NOTICE file are for informational purposes only and
|
118
|
+
do not modify the License. You may add Your own attribution
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
121
|
+
that such additional attribution notices cannot be construed
|
122
|
+
as modifying the License.
|
123
|
+
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
125
|
+
may provide additional or different license terms and conditions
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
129
|
+
the conditions stated in this License.
|
130
|
+
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
134
|
+
this License, without any additional terms or conditions.
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
136
|
+
the terms of any separate license agreement you may have executed
|
137
|
+
with Licensor regarding such Contributions.
|
138
|
+
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
141
|
+
except as required for reasonable and customary use in describing the
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
143
|
+
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
153
|
+
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
159
|
+
incidental, or consequential damages of any character arising as a
|
160
|
+
result of this License or out of the use or inability to use the
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
163
|
+
other commercial damages or losses), even if such Contributor
|
164
|
+
has been advised of the possibility of such damages.
|
165
|
+
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
169
|
+
or other liability obligations and/or rights consistent with this
|
170
|
+
License. However, in accepting such obligations, You may act only
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
175
|
+
of your accepting any such warranty or additional liability.
|
176
|
+
|
177
|
+
END OF TERMS AND CONDITIONS
|
178
|
+
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
180
|
+
|
181
|
+
To apply the Apache License to your work, attach the following
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
183
|
+
replaced with your own identifying information. (Don't include
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
185
|
+
comment syntax for the file format. We also recommend that a
|
186
|
+
file or class name and description of purpose be included on the
|
187
|
+
same "printed page" as the copyright notice for easier
|
188
|
+
identification within third-party archives.
|
189
|
+
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
191
|
+
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
193
|
+
you may not use this file except in compliance with the License.
|
194
|
+
You may obtain a copy of the License at
|
195
|
+
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
197
|
+
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
201
|
+
See the License for the specific language governing permissions and
|
202
|
+
limitations under the License.
|
data/NOTICE.txt
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
Copyright XLearn contributors
|
2
|
+
Copyright 2019-2020 Andrew Kane
|
3
|
+
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
you may not use this file except in compliance with the License.
|
6
|
+
You may obtain a copy of the License at
|
7
|
+
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
See the License for the specific language governing permissions and
|
14
|
+
limitations under the License.
|
data/README.md
CHANGED
@@ -2,17 +2,15 @@
|
|
2
2
|
|
3
3
|
[xLearn](https://github.com/aksnzhy/xlearn) - the high performance machine learning library - for Ruby
|
4
4
|
|
5
|
-
:fire: Uses the C API for blazing performance
|
6
|
-
|
7
5
|
Supports:
|
8
6
|
|
9
7
|
- Linear models
|
10
8
|
- Factorization machines
|
11
9
|
- Field-aware factorization machines
|
12
10
|
|
13
|
-
|
11
|
+
[![Build Status](https://travis-ci.org/ankane/xlearn.svg?branch=master)](https://travis-ci.org/ankane/xlearn) [![Build status](https://ci.appveyor.com/api/projects/status/r7upg4073w7xct35/branch/master?svg=true)](https://ci.appveyor.com/project/ankane/xlearn/branch/master)
|
14
12
|
|
15
|
-
|
13
|
+
## Installation
|
16
14
|
|
17
15
|
Add this line to your application’s Gemfile:
|
18
16
|
|
@@ -22,8 +20,6 @@ gem 'xlearn'
|
|
22
20
|
|
23
21
|
## Getting Started
|
24
22
|
|
25
|
-
This library is modeled after the [Python Scikit-learn API](https://xlearn-doc.readthedocs.io/en/latest/python_api/index.html). Some methods are missing at the moment. PRs welcome!
|
26
|
-
|
27
23
|
Prep your data
|
28
24
|
|
29
25
|
```ruby
|
@@ -58,41 +54,141 @@ Load the model from a file
|
|
58
54
|
model.load_model("model.bin")
|
59
55
|
```
|
60
56
|
|
57
|
+
Save a text version of the model
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
model.save_txt("model.txt")
|
61
|
+
```
|
62
|
+
|
63
|
+
Pass a validation set
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
model.fit(x_train, y_train, eval_set: [x_val, y_val])
|
67
|
+
```
|
68
|
+
|
69
|
+
Train online
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
model.partial_fit(x_train, y_train)
|
73
|
+
```
|
74
|
+
|
75
|
+
Get the bias term, linear term, and latent factors
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
model.bias_term
|
79
|
+
model.linear_term
|
80
|
+
model.latent_factors # fm and ffm only
|
81
|
+
```
|
82
|
+
|
61
83
|
## Parameters
|
62
84
|
|
63
|
-
|
85
|
+
Pass parameters - default values below
|
64
86
|
|
65
87
|
```ruby
|
66
|
-
|
88
|
+
XLearn::FM.new(
|
89
|
+
task: "binary", # binary (classification), reg (regression)
|
90
|
+
metric: nil, # acc, prec, recall, f1, auc, mae, mape, rmse, rmsd
|
91
|
+
lr: 0.2, # learning rate
|
92
|
+
lambda: 0.00002, # lambda for l2 regularization
|
93
|
+
k: 4, # latent factors for fm and ffm
|
94
|
+
alpha: 0.3, # hyper parameter for ftrl
|
95
|
+
beta: 1.0, # hyper parameter for ftrl
|
96
|
+
lambda_1: 0.00001, # hyper parameter for ftrl
|
97
|
+
lambda_2: 0.00002, # hyper parameter for ftrl
|
98
|
+
epoch: 10, # number of epochs
|
99
|
+
fold: 3, # number of folds
|
100
|
+
opt: "adagrad", # sgd, adagrad, ftrl
|
101
|
+
block_size: 500, # block size for on-disk training in MB
|
102
|
+
early_stop: true, # use early stopping
|
103
|
+
stop_window: 2, # size of stop window for early stopping
|
104
|
+
sign: false, # convert predition output to 0 and 1
|
105
|
+
sigmoid: false, # convert predition output using sigmoid
|
106
|
+
seed: 1 # random seed to shuffle data set
|
107
|
+
)
|
67
108
|
```
|
68
109
|
|
69
|
-
|
110
|
+
## Cross-Validation
|
111
|
+
|
112
|
+
Cross-validation
|
70
113
|
|
71
|
-
|
114
|
+
```ruby
|
115
|
+
model.cv(x, y)
|
116
|
+
```
|
72
117
|
|
73
|
-
|
118
|
+
Specify the number of folds
|
74
119
|
|
75
120
|
```ruby
|
76
|
-
model.
|
121
|
+
model.cv(x, y, folds: 5)
|
122
|
+
```
|
123
|
+
|
124
|
+
## Data
|
125
|
+
|
126
|
+
Data can be an array of arrays
|
127
|
+
|
128
|
+
```ruby
|
129
|
+
[[1, 2, 3], [4, 5, 6]]
|
130
|
+
```
|
131
|
+
|
132
|
+
Or a Numo array
|
133
|
+
|
134
|
+
```ruby
|
135
|
+
Numo::NArray.cast([[1, 2, 3], [4, 5, 6]])
|
136
|
+
```
|
137
|
+
|
138
|
+
Or a Rover data frame
|
139
|
+
|
140
|
+
```ruby
|
141
|
+
Rover.read_csv("houses.csv")
|
142
|
+
```
|
143
|
+
|
144
|
+
Or a Daru data frame
|
145
|
+
|
146
|
+
```ruby
|
147
|
+
Daru::DataFrame.from_csv("houses.csv")
|
77
148
|
```
|
78
149
|
|
79
150
|
## Performance
|
80
151
|
|
81
|
-
For
|
152
|
+
For large datasets, read data directly from files
|
82
153
|
|
83
154
|
```ruby
|
84
155
|
model.fit("train.txt", eval_set: "validate.txt")
|
85
156
|
model.predict("test.txt")
|
157
|
+
model.cv("train.txt")
|
158
|
+
```
|
159
|
+
|
160
|
+
For linear models and factorization machines, use CSV:
|
161
|
+
|
162
|
+
```txt
|
163
|
+
label,value_1,value_2,...,value_n
|
164
|
+
```
|
165
|
+
|
166
|
+
Or the `libsvm` format (better for sparse data):
|
167
|
+
|
168
|
+
```txt
|
169
|
+
label index_1:value_1 index_2:value_2 ... index_n:value_n
|
170
|
+
```
|
171
|
+
|
172
|
+
> You can also use commas instead of spaces for separators
|
173
|
+
|
174
|
+
For field-aware factorization machines, use the `libffm` format:
|
175
|
+
|
176
|
+
```txt
|
177
|
+
label field_1:index_1:value_1 field_2:index_2:value_2 ...
|
86
178
|
```
|
87
179
|
|
88
|
-
|
180
|
+
> You can also use commas instead of spaces for separators
|
89
181
|
|
90
182
|
You can also write predictions directly to a file
|
91
183
|
|
92
184
|
```ruby
|
93
|
-
model.predict("test.txt",
|
185
|
+
model.predict("test.txt", out_path: "predictions.txt")
|
94
186
|
```
|
95
187
|
|
188
|
+
## Credits
|
189
|
+
|
190
|
+
This library is modeled after xLearn’s [Scikit-learn API](https://xlearn-doc.readthedocs.io/en/latest/python_api/index.html).
|
191
|
+
|
96
192
|
## History
|
97
193
|
|
98
194
|
View the [changelog](https://github.com/ankane/xlearn/blob/master/CHANGELOG.md)
|
@@ -105,3 +201,13 @@ Everyone is encouraged to help improve this project. Here are a few ways you can
|
|
105
201
|
- Fix bugs and [submit pull requests](https://github.com/ankane/xlearn/pulls)
|
106
202
|
- Write, clarify, or fix documentation
|
107
203
|
- Suggest or add new features
|
204
|
+
|
205
|
+
To get started with development and testing:
|
206
|
+
|
207
|
+
```sh
|
208
|
+
git clone https://github.com/ankane/xlearn.git
|
209
|
+
cd xlearn
|
210
|
+
bundle install
|
211
|
+
bundle exec rake vendor:all
|
212
|
+
bundle exec rake test
|
213
|
+
```
|
data/lib/xlearn.rb
CHANGED
@@ -21,7 +21,9 @@ module XLearn
|
|
21
21
|
class << self
|
22
22
|
attr_accessor :ffi_lib
|
23
23
|
end
|
24
|
-
|
24
|
+
lib_name = FFI.map_library_name("xlearn_api")
|
25
|
+
vendor_lib = File.expand_path("../vendor/#{lib_name}", __dir__)
|
26
|
+
self.ffi_lib = [vendor_lib]
|
25
27
|
|
26
28
|
# friendlier error message
|
27
29
|
autoload :FFI, "xlearn/ffi"
|
data/lib/xlearn/dmatrix.rb
CHANGED
@@ -5,14 +5,33 @@ module XLearn
|
|
5
5
|
def initialize(data, label: nil)
|
6
6
|
@handle = ::FFI::MemoryPointer.new(:pointer)
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
if matrix?(data)
|
9
|
+
nrow = data.row_count
|
10
|
+
ncol = data.column_count
|
11
|
+
flat_data = data.to_a.flatten
|
12
|
+
elsif daru?(data)
|
13
|
+
nrow, ncol = data.shape
|
14
|
+
flat_data = data.map_rows(&:to_a).flatten
|
15
|
+
elsif rover?(data)
|
16
|
+
nrow, ncol = data.shape
|
17
|
+
flat_data = data.each_row.map(&:values).flatten
|
18
|
+
elsif narray?(data)
|
19
|
+
nrow, ncol = data.shape
|
20
|
+
# TODO convert to SFloat and pass pointer
|
21
|
+
# for better performance
|
22
|
+
flat_data = data.flatten.to_a
|
23
|
+
else
|
24
|
+
nrow = data.count
|
25
|
+
ncol = data.first.count
|
26
|
+
flat_data = data.flatten
|
27
|
+
end
|
10
28
|
|
11
|
-
c_data = ::FFI::MemoryPointer.new(:float,
|
12
|
-
c_data.put_array_of_float(0,
|
29
|
+
c_data = ::FFI::MemoryPointer.new(:float, flat_data.size)
|
30
|
+
c_data.put_array_of_float(0, flat_data)
|
13
31
|
|
14
32
|
if label
|
15
|
-
|
33
|
+
label = label.to_a
|
34
|
+
c_label = ::FFI::MemoryPointer.new(:float, label.size)
|
16
35
|
c_label.put_array_of_float(0, label)
|
17
36
|
end
|
18
37
|
|
@@ -31,5 +50,23 @@ module XLearn
|
|
31
50
|
# must use proc instead of stabby lambda
|
32
51
|
proc { FFI.XlearnDataFree(pointer) }
|
33
52
|
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def matrix?(data)
|
57
|
+
defined?(Matrix) && data.is_a?(Matrix)
|
58
|
+
end
|
59
|
+
|
60
|
+
def daru?(data)
|
61
|
+
defined?(Daru::DataFrame) && data.is_a?(Daru::DataFrame)
|
62
|
+
end
|
63
|
+
|
64
|
+
def narray?(data)
|
65
|
+
defined?(Numo::NArray) && data.is_a?(Numo::NArray)
|
66
|
+
end
|
67
|
+
|
68
|
+
def rover?(data)
|
69
|
+
defined?(Rover::DataFrame) && data.is_a?(Rover::DataFrame)
|
70
|
+
end
|
34
71
|
end
|
35
72
|
end
|
data/lib/xlearn/ffi.rb
CHANGED
@@ -2,12 +2,7 @@ module XLearn
|
|
2
2
|
module FFI
|
3
3
|
extend ::FFI::Library
|
4
4
|
|
5
|
-
|
6
|
-
ffi_lib XLearn.ffi_lib
|
7
|
-
rescue LoadError => e
|
8
|
-
raise e if ENV["XLEARN_DEBUG"]
|
9
|
-
raise LoadError, "Could not find xLearn"
|
10
|
-
end
|
5
|
+
ffi_lib XLearn.ffi_lib
|
11
6
|
|
12
7
|
# https://github.com/aksnzhy/xlearn/blob/master/src/c_api/c_api.h
|
13
8
|
# keep same order
|
data/lib/xlearn/ffm.rb
CHANGED
@@ -4,5 +4,24 @@ module XLearn
|
|
4
4
|
@model_type = "ffm"
|
5
5
|
super
|
6
6
|
end
|
7
|
+
|
8
|
+
# shape is [i, j, k]
|
9
|
+
# for v_{i}_{j}
|
10
|
+
def latent_factors
|
11
|
+
factor = []
|
12
|
+
current = -1
|
13
|
+
read_txt do |line|
|
14
|
+
if line.start_with?("v_")
|
15
|
+
parts = line.split(": ")
|
16
|
+
i = parts.first.split("_")[1].to_i
|
17
|
+
if i != current
|
18
|
+
factor << []
|
19
|
+
current = i
|
20
|
+
end
|
21
|
+
factor.last << parts.last.split(" ").map(&:to_f)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
factor
|
25
|
+
end
|
7
26
|
end
|
8
27
|
end
|
data/lib/xlearn/fm.rb
CHANGED
@@ -4,5 +4,17 @@ module XLearn
|
|
4
4
|
@model_type = "fm"
|
5
5
|
super
|
6
6
|
end
|
7
|
+
|
8
|
+
# shape is [i, k]
|
9
|
+
# for v_{i}
|
10
|
+
def latent_factors
|
11
|
+
factor = []
|
12
|
+
read_txt do |line|
|
13
|
+
if line.start_with?("v_")
|
14
|
+
factor << line.split(": ").last.split(" ").map(&:to_f)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
factor
|
18
|
+
end
|
7
19
|
end
|
8
20
|
end
|
data/lib/xlearn/model.rb
CHANGED
@@ -9,7 +9,8 @@ module XLearn
|
|
9
9
|
|
10
10
|
options = {
|
11
11
|
task: "binary",
|
12
|
-
quiet: true
|
12
|
+
quiet: true,
|
13
|
+
bin_out: false
|
13
14
|
}.merge(options)
|
14
15
|
|
15
16
|
if options[:task] == "binary" && !options.key?(:sigmoid)
|
@@ -20,14 +21,14 @@ module XLearn
|
|
20
21
|
end
|
21
22
|
|
22
23
|
def fit(x, y = nil, eval_set: nil)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
24
|
+
@model_path = nil
|
25
|
+
partial_fit(x, y, eval_set: eval_set)
|
26
|
+
end
|
27
|
+
|
28
|
+
def partial_fit(x, y = nil, eval_set: nil)
|
29
|
+
check_call FFI.XLearnSetPreModel(@handle, @model_path || "")
|
30
|
+
|
31
|
+
set_train_set(x, y)
|
31
32
|
|
32
33
|
if eval_set
|
33
34
|
if eval_set.is_a?(String)
|
@@ -38,12 +39,17 @@ module XLearn
|
|
38
39
|
end
|
39
40
|
end
|
40
41
|
|
41
|
-
|
42
|
-
@
|
42
|
+
@txt_file ||= create_tempfile
|
43
|
+
check_call FFI.XLearnSetTXTModel(@handle, @txt_file.path)
|
44
|
+
|
45
|
+
@model_file ||= create_tempfile
|
43
46
|
check_call FFI.XLearnFit(@handle, @model_file.path)
|
47
|
+
@model_path = @model_file.path
|
44
48
|
end
|
45
49
|
|
46
50
|
def predict(x, out_path: nil)
|
51
|
+
raise Error, "Not trained" unless @model_file
|
52
|
+
|
47
53
|
if x.is_a?(String)
|
48
54
|
check_call FFI.XLearnSetTest(@handle, x)
|
49
55
|
check_call FFI.XLearnSetBool(@handle, "from_file", true)
|
@@ -63,24 +69,72 @@ module XLearn
|
|
63
69
|
end
|
64
70
|
end
|
65
71
|
|
72
|
+
def cv(x, y = nil, folds: nil)
|
73
|
+
set_params(fold: folds) if folds
|
74
|
+
set_train_set(x, y)
|
75
|
+
check_call FFI.XLearnCV(@handle)
|
76
|
+
end
|
77
|
+
|
66
78
|
def save_model(path)
|
67
79
|
raise Error, "Not trained" unless @model_file
|
68
80
|
FileUtils.cp(@model_file.path, path)
|
69
81
|
end
|
70
82
|
|
83
|
+
def save_txt(path)
|
84
|
+
raise Error, "Not trained" unless @txt_file
|
85
|
+
FileUtils.cp(@txt_file.path, path)
|
86
|
+
end
|
87
|
+
|
71
88
|
def load_model(path)
|
72
|
-
@model_file ||=
|
89
|
+
@model_file ||= create_tempfile
|
73
90
|
# TODO ensure tempfile is still cleaned up
|
74
91
|
FileUtils.cp(path, @model_file.path)
|
75
92
|
end
|
76
93
|
|
94
|
+
def bias_term
|
95
|
+
read_txt do |line|
|
96
|
+
return line.split(":").last.to_f if line.start_with?("bias:")
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def linear_term
|
101
|
+
term = []
|
102
|
+
read_txt do |line|
|
103
|
+
if line.start_with?("i_")
|
104
|
+
term << line.split(":").last.to_f
|
105
|
+
elsif line.start_with?("v_")
|
106
|
+
break
|
107
|
+
end
|
108
|
+
end
|
109
|
+
term
|
110
|
+
end
|
111
|
+
|
77
112
|
def self.finalize(pointer)
|
78
113
|
# must use proc instead of stabby lambda
|
79
114
|
proc { FFI.XLearnHandleFree(pointer) }
|
80
115
|
end
|
81
116
|
|
117
|
+
def self.finalize_file(file)
|
118
|
+
# must use proc instead of stabby lambda
|
119
|
+
proc do
|
120
|
+
file.close
|
121
|
+
file.unlink
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
82
125
|
private
|
83
126
|
|
127
|
+
def set_train_set(x, y)
|
128
|
+
if x.is_a?(String)
|
129
|
+
check_call FFI.XLearnSetTrain(@handle, x)
|
130
|
+
check_call FFI.XLearnSetBool(@handle, "from_file", true)
|
131
|
+
else
|
132
|
+
train_set = DMatrix.new(x, label: y)
|
133
|
+
check_call FFI.XLearnSetDMatrix(@handle, "train", train_set)
|
134
|
+
check_call FFI.XLearnSetBool(@handle, "from_file", false)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
84
138
|
def set_params(params)
|
85
139
|
params.each do |k, v|
|
86
140
|
k = k.to_s
|
@@ -100,5 +154,19 @@ module XLearn
|
|
100
154
|
check_call ret
|
101
155
|
end
|
102
156
|
end
|
157
|
+
|
158
|
+
def read_txt
|
159
|
+
if @txt_file
|
160
|
+
File.foreach(@txt_file.path) do |line|
|
161
|
+
yield line
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
def create_tempfile
|
167
|
+
file = Tempfile.new("xlearn")
|
168
|
+
ObjectSpace.define_finalizer(self, self.class.finalize_file(file))
|
169
|
+
file
|
170
|
+
end
|
103
171
|
end
|
104
172
|
end
|
data/lib/xlearn/version.rb
CHANGED
data/vendor/LICENSE
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
177
|
+
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
179
|
+
|
180
|
+
To apply the Apache License to your work, attach the following
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
182
|
+
replaced with your own identifying information. (Don't include
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
184
|
+
comment syntax for the file format. We also recommend that a
|
185
|
+
file or class name and description of purpose be included on the
|
186
|
+
same "printed page" as the copyright notice for easier
|
187
|
+
identification within third-party archives.
|
188
|
+
|
189
|
+
Copyright {yyyy} {name of copyright owner}
|
190
|
+
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192
|
+
you may not use this file except in compliance with the License.
|
193
|
+
You may obtain a copy of the License at
|
194
|
+
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
196
|
+
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200
|
+
See the License for the specific language governing permissions and
|
201
|
+
limitations under the License.
|
data/vendor/NOTICE
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
Copyright XLearn contributors
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
|
15
|
+
---
|
16
|
+
|
17
|
+
Copyright (C) 2011 Paul Mineiro
|
18
|
+
All rights reserved.
|
19
|
+
|
20
|
+
Redistribution and use in source and binary forms, with
|
21
|
+
or without modification, are permitted provided that the
|
22
|
+
following conditions are met:
|
23
|
+
|
24
|
+
* Redistributions of source code must retain the
|
25
|
+
above copyright notice, this list of conditions and
|
26
|
+
the following disclaimer.
|
27
|
+
|
28
|
+
* Redistributions in binary form must reproduce the
|
29
|
+
above copyright notice, this list of conditions and
|
30
|
+
the following disclaimer in the documentation and/or
|
31
|
+
other materials provided with the distribution.
|
32
|
+
|
33
|
+
* Neither the name of Paul Mineiro nor the names
|
34
|
+
of other contributors may be used to endorse or promote
|
35
|
+
products derived from this software without specific
|
36
|
+
prior written permission.
|
37
|
+
|
38
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
39
|
+
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
40
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
41
|
+
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
42
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
43
|
+
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
44
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
45
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
46
|
+
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
47
|
+
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
48
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
49
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
50
|
+
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
51
|
+
POSSIBILITY OF SUCH DAMAGE.
|
52
|
+
|
53
|
+
Contact: Paul Mineiro <paul@mineiro.com>
|
54
|
+
|
55
|
+
---
|
56
|
+
|
57
|
+
Copyright 2011 Martin T. Sandsmark <sandsmark@samfundet.no>
|
58
|
+
Redistribution and use in source and binary forms, with or without
|
59
|
+
modification, are permitted provided that the following conditions
|
60
|
+
are met:
|
61
|
+
1. Redistributions of source code must retain the above copyright
|
62
|
+
notice, this list of conditions and the following disclaimer.
|
63
|
+
2. Redistributions in binary form must reproduce the above copyright
|
64
|
+
notice, this list of conditions and the following disclaimer in the
|
65
|
+
documentation and/or other materials provided with the distribution.
|
66
|
+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
67
|
+
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
68
|
+
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
69
|
+
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
70
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
71
|
+
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
72
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
73
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
74
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
75
|
+
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
76
|
+
|
77
|
+
---
|
78
|
+
|
79
|
+
Protocol Buffers - Google's data interchange format
|
80
|
+
|
81
|
+
Copyright 2008 Google Inc. All rights reserved.
|
82
|
+
https://developers.google.com/protocol-buffers/
|
83
|
+
|
84
|
+
Redistribution and use in source and binary forms, with or without
|
85
|
+
modification, are permitted provided that the following conditions are
|
86
|
+
met:
|
87
|
+
|
88
|
+
* Redistributions of source code must retain the above copyright
|
89
|
+
notice, this list of conditions and the following disclaimer.
|
90
|
+
* Redistributions in binary form must reproduce the above
|
91
|
+
copyright notice, this list of conditions and the following disclaimer
|
92
|
+
in the documentation and/or other materials provided with the
|
93
|
+
distribution.
|
94
|
+
* Neither the name of Google Inc. nor the names of its
|
95
|
+
contributors may be used to endorse or promote products derived from
|
96
|
+
this software without specific prior written permission.
|
97
|
+
|
98
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
99
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
100
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
101
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
102
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
103
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
104
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
105
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
106
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
107
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
108
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
Binary file
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xlearn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -66,6 +66,48 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '5'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: daru
|
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
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: numo-narray
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rover-df
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
69
111
|
description:
|
70
112
|
email: andrew@chartkick.com
|
71
113
|
executables: []
|
@@ -74,6 +116,7 @@ extra_rdoc_files: []
|
|
74
116
|
files:
|
75
117
|
- CHANGELOG.md
|
76
118
|
- LICENSE.txt
|
119
|
+
- NOTICE.txt
|
77
120
|
- README.md
|
78
121
|
- lib/xlearn.rb
|
79
122
|
- lib/xlearn/dmatrix.rb
|
@@ -84,9 +127,14 @@ files:
|
|
84
127
|
- lib/xlearn/model.rb
|
85
128
|
- lib/xlearn/utils.rb
|
86
129
|
- lib/xlearn/version.rb
|
130
|
+
- vendor/LICENSE
|
131
|
+
- vendor/NOTICE
|
132
|
+
- vendor/libxlearn_api.dylib
|
133
|
+
- vendor/libxlearn_api.so
|
134
|
+
- vendor/xlearn_api.dll
|
87
135
|
homepage: https://github.com/ankane/xlearn
|
88
136
|
licenses:
|
89
|
-
-
|
137
|
+
- Apache-2.0
|
90
138
|
metadata: {}
|
91
139
|
post_install_message:
|
92
140
|
rdoc_options: []
|
@@ -103,8 +151,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
151
|
- !ruby/object:Gem::Version
|
104
152
|
version: '0'
|
105
153
|
requirements: []
|
106
|
-
rubygems_version: 3.
|
154
|
+
rubygems_version: 3.1.2
|
107
155
|
signing_key:
|
108
156
|
specification_version: 4
|
109
|
-
summary:
|
157
|
+
summary: High performance factorization machines for Ruby
|
110
158
|
test_files: []
|