Class: XLearn::FFM
Instance Method Summary collapse
-
#initialize(**options) ⇒ FFM
constructor
A new instance of FFM.
-
#latent_factors ⇒ Object
shape is [i, j, k] for v_i_j.
Methods inherited from Model
#bias_term, #cv, finalize, finalize_file, #fit, #linear_term, #load_model, #partial_fit, #predict, #save_model, #save_txt
Constructor Details
#initialize(**options) ⇒ FFM
Returns a new instance of FFM.
3 4 5 6 |
# File 'lib/xlearn/ffm.rb', line 3 def initialize(**) @model_type = "ffm" super end |
Instance Method Details
#latent_factors ⇒ Object
shape is [i, j, k] for v_i_j
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/xlearn/ffm.rb', line 10 def latent_factors factor = [] current = -1 read_txt do |line| if line.start_with?("v_") parts = line.split(": ") i = parts.first.split("_")[1].to_i if i != current factor << [] current = i end factor.last << parts.last.split(" ").map(&:to_f) end end factor end |