lib/vowpalwabbit/model.rb in vowpalwabbit-0.1.3 vs lib/vowpalwabbit/model.rb in vowpalwabbit-0.2.0
- old
+ new
@@ -44,16 +44,23 @@
bin_str = output_data.read_pointer.read_string(output_size.read(:size_t))
FFI.VW_FreeIOBuf(buffer_handle.read_pointer)
File.binwrite(filename, bin_str)
nil
end
+ alias_method :save, :save_model
def load_model(filename)
bin_str = File.binread(filename)
model_data = ::FFI::MemoryPointer.new(:char, bin_str.bytesize)
model_data.put_bytes(0, bin_str)
@handle = FFI.VW_InitializeWithModel(param_str(@params), model_data, bin_str.bytesize)
nil
+ end
+
+ def self.load(filename)
+ model = new
+ model.load_model(filename)
+ model
end
private
# TODO clean-up handle