class XLearn::FFM

Public Class Methods

new(**options) click to toggle source
Calls superclass method
# File lib/xlearn/ffm.rb, line 3
def initialize(**options)
  @model_type = "ffm"
  super
end

Public Instance Methods

latent_factors() click to toggle source

shape is [i, j, k] for v_{i}_{j}

# 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