Sha256: 0f89174f0ef141e3a80e3f0794befc6f8af8235c9e0e4a3a4ffefda05aa84fff

Contents?: true

Size: 556 Bytes

Versions: 5

Compression:

Stored size: 556 Bytes

Contents

module XLearn
  class FFM < Model
    def initialize(**options)
      @model_type = "ffm"
      super
    end

    # shape is [i, j, k]
    # for v_{i}_{j}
    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
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
xlearn-0.1.5 lib/xlearn/ffm.rb
xlearn-0.1.4 lib/xlearn/ffm.rb
xlearn-0.1.3 lib/xlearn/ffm.rb
xlearn-0.1.2 lib/xlearn/ffm.rb
xlearn-0.1.1 lib/xlearn/ffm.rb